jprante / gradle-plugin-jflex

A JFlex plugin for Gradle
Apache License 2.0
8 stars 6 forks source link

Sometimes gradle-plugin-jflex overwrites sourceset modifications made by previous plugins or task #22

Open stalb opened 1 year ago

stalb commented 1 year ago

Problem:

Sometime the gradle-plugin-jflex overwrites modifications made by plugins or tasks (applied before gradle-plugin-jflex plugin).

An example can be found in stalb/JFlex_Example:

plugins {
    id 'java'
    id "org.xbib.gradle.plugin.jflex" version "1.7.0" apply false
}
repositories {
    mavenCentral()
}
def copyJava = tasks.register("copyJava", Copy) {
    from 'src/main/custom/'
    into "${project.buildDir}/generated/sources/custom/java/testJFlex"
}
sourceSets {
    main {
        java {
            srcDir copyJava
        }
    }
}
apply plugin: "org.xbib.gradle.plugin.jflex"

The main Java SourceDirectorySet should contains copyJava output and generateJflex output, However when gradle-plugin-jflex plugin is applied after the main Java SourceDirectorySet configuration, the output of copyJava disappears from the SourceDirectorySet.

In fact, since the output of the copyJava task is not in the main java SourceDirectorySet anymore, it will not be even considered as a dependency of compileJava. So running ./gradlew compileJava will not trigger the copyJava task which output will not be compiled.

If plugins which modify the java SourceDirectorySet are applied before gradle-plugin-jflex plugin, their modifications can also be overwritten.

Expected behavior:

gradle-plugin-jflex plugin should not overwrite SourceDirectorySet additions made by plugins or tasks applied previously.

In the example, running the compileJava task should trigger both generateJflex and copyJava tasks and all their Java outputs should be compiled by compileJava.