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.