jprante / gradle-plugin-jflex

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

Pb when configuring JFlexTask directly #24

Open stalb opened 1 year ago

stalb commented 1 year ago

Problem description

If you configure JFlexTask directly (not using the jflex extension) this can lead to unexpected behavior.

Example 1 (see stalb/JFlex_Example3)

When using the following configuration (build.gradle)

plugins {
    id "org.xbib.gradle.plugin.jflex" version "1.7.0"
}

repositories {
    mavenCentral()
}

tasks.named('generateJflex').configure {
   // write output into custom location .
   target = file("${project.buildDir}/generated/sources/jflexCustom/")
}

the JFlex java source file is generated into ${project.buildDir}/generated/sources/jflexCustom/ as expected but it is not compiled by the compileJava task, which actually looks into ${project.buildDir}/generated/sources/main/.

Example 2 (see stalb/JFlex_Example4)

When using the following configuration (build.gradle)

plugins {
    id "org.xbib.gradle.plugin.jflex" version "1.7.0"
}

repositories {
    mavenCentral()
}

tasks.named('generateJflex').configure {
   // enable legacy behavior of writing directly into Java source directory
   writeIntoJavaSrc = true
}

the JFlex java source file is generated into ${project.buildDir}/generated/sources/main/ instead of src/main/java/. So the writeIntoJavaSrc flag specified for the generateJflex task is not taken into account as I would expect it to be.

Expected behavior

Example1: the java compiler should compile the java file produced by the JFlexTask.

Example 2: the java file produced by the JFlexTask should written in the Java source directory.