typescript-generator icon indicating copy to clipboard operation
typescript-generator copied to clipboard

Incremental builds

Open cowwoc opened this issue 5 years ago • 10 comments

The plugin always runs regardless of whether the inputs have changed. When running with gradle --info I see:

Task ':trading:websocket-protocol:generateTypeScript' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Running TypeScriptGenerator version 2.11.472
...

I am expecting generateTypeScript.outputFile to be used as the declared output.

cowwoc avatar Apr 29 '19 15:04 cowwoc

I tried to add generateTsTask.getOutputs().file(...); to TypeScriptGeneratorPlugin class. It worked on Gradle 4 but failed on Gradle 5 with error:

java.lang.NoSuchMethodError: org.gradle.api.internal.TaskOutputsInternal.file(Ljava/lang/Object;)Lorg/gradle/api/tasks/TaskOutputs;

vojtechhabarta avatar May 02 '19 07:05 vojtechhabarta

@vojtechhabarta Your return type is incorrect. See https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/TaskOutputs.html

cowwoc avatar May 02 '19 11:05 cowwoc

Return type changed between versions 2 and 5. https://docs.gradle.org/2.1/javadoc/org/gradle/api/tasks/TaskOutputs.html https://docs.gradle.org/3.0/javadoc/org/gradle/api/tasks/TaskOutputs.html https://docs.gradle.org/4.0/javadoc/org/gradle/api/tasks/TaskOutputs.html https://docs.gradle.org/5.0/javadoc/org/gradle/api/tasks/TaskOutputs.html So when the code was compiled against version 2.1 it didn't work with version 5.

vojtechhabarta avatar May 02 '19 14:05 vojtechhabarta

I assume you're able to fix the plugin code then?

Another (related) suggestions: the plugin execution should dependsOn the jar task of any Java compile dependencies. Currently, you load all classes found on the classpath based on all compile dependencies. However, in our project the build was doing a clean build so you were trying to load a class after it was deleted but before it was recreated so we were getting a NoClassDefException. If you dependsOn the jar task of such dependencies the problem goes away.

cowwoc avatar May 02 '19 15:05 cowwoc

I think it is not possible to make it work without updating the version.

For your second suggestion PR is welcomed if you want to spend some time with it. It also should be possible to achieve this in build.gradle file.

vojtechhabarta avatar May 02 '19 15:05 vojtechhabarta

@vojtechhabarta Why not just update the version then?

cowwoc avatar May 02 '19 22:05 cowwoc

I assume your question is rhetorical and you know the answer 😏 Anyway, I will consider updating it. It should also be possible to set the output in build script (as well as dependsOn).

vojtechhabarta avatar May 03 '19 05:05 vojtechhabarta

I agree it'd be nice if the plugin set the inputs and outputs by default, but its pretty easy to do yourself.

Here's a sample

generateTypeScript.inputs.dir(file('src/main/java/com/something'))
generateTypeScript.inputs.property('classPatterns', generateTypeScript.classPatterns)
generateTypeScript.outputs.file(generateTypeScript.outputFile)

You may have multiple input directories, they would need to be specified, and if you have other configuration options that have the potential to change, you'd want to add them as input properties too.

bschlosser avatar May 16 '19 13:05 bschlosser

@bschlosser thanks for sharing the example.

vojtechhabarta avatar May 16 '19 14:05 vojtechhabarta

Shouldn't outputFile field be marked with @OutputFiles annotation?

olegshtch avatar Jul 24 '19 11:07 olegshtch