Skip to content

@CompileStatic type-checking fails on task.config.ext property access #3

Closed

Description

@scttfrdmn

Summary

After the Gradle 7+ build fix (#1), gradle jar reaches compileGroovy and fails with 4 static type-checking errors in SpawnTaskHandler.groovy:

SpawnTaskHandler.groovy: 33: [Static type checking] - No such property: instanceType for class: java.lang.Object
SpawnTaskHandler.groovy: 34: [Static type checking] - No such property: region for class: java.lang.Object
SpawnTaskHandler.groovy: 35: [Static type checking] - No such property: ttl for class: java.lang.Object
SpawnTaskHandler.groovy: 36: [Static type checking] - No such property: spot for class: java.lang.Object

Root cause

The class is @CompileStatic. Nextflow's TaskConfig.getExt() returns an untyped value (effectively Object/dynamic map), so dotted property access like task.config.ext?.instanceType cannot be resolved at compile time under static type checking:

String instanceType = task.config.ext?.instanceType ?: 't3.medium'
String region       = task.config.ext?.region       ?: 'us-east-1'
String ttl          = task.config.ext?.ttl          ?: '2h'
boolean spot        = task.config.ext?.spot          ? true : false

Fix options

  1. Cast ext to Map and use subscript access: ((Map) task.config.ext)?.get('instanceType') — keeps @CompileStatic.
  2. Read via the config getter that returns a Map of ext properties, then index it.

Option 1 is minimal and preserves static compilation.

Context

https://github.com/scttfrdmn/aws-microbiome-demo — second blocker (after #1) when building nf-spawn during the AMI bake.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions