Problems with Tasks unable to find outputs

I am trying to implement a gradle plugin for JavaCard. Currently I am writing a translation task for JavaClass files to Cap files (comparable to Jar).

The task class looks nice:

class Cap extends DefaultTask {

@Input

String sourcePackage

@Input

String classesDir

@Input

String capsDir

@InputDirectory

File sourcePackagePath() {

new File(classesDir.getPath() + sourcePackage.rplace(".", “/”))

}

@OutputFile

File capFile() {

new File(capsDir + “/” + sourcePackage.replace(".", “/”) + “/javacard/ndef.cap”) // FIXME: hard coded stuff

}

@TaskAction

def create() {

// random operartions

}

}

Now I want to add this task to the project in the apply of the plugin

void apply(Project project) {

project.getTasks().create(‘cap’, Cap.class) {

dependsOn(project.compileJava)

sourcePackage = “de.spline.uves.ndef”

classesDir = project.sourceSets.main.output.classesDir.getPath()

capsDir = project.getBuildDir().getPath() + “/caps”

}

}

But if I run gradle now with ‘gradle cap --debug’

13:25:12.444 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :cap

13:25:12.444 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ‘:cap’

13:25:12.446 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ‘:cap’ is up-to-date

13:25:12.448 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Executing task ‘:cap’ (up-to-date check took 0.001 secs) due to:

Task has not declared any outputs.

These need to be JavaBeans getter methods (‘getSourcePackagePath’, ‘getCapFile’).

Thank you, works charmingly.

In the same class I need to call an external program. What is the most elegant solution? Extending Exec, appending an Exec instance with doLast?

Preferably a separate ‘Exec’ task added by the plugin. Alternatively, call ‘project.exec {}’ inside the task action. PS: This should have been a new topic.