I have a Gradle-managed multi-project setup that relies on the new Java 8 -parameters
compiler flag. I need 2 ways of including the compiler flag:
I've tried this:
tasks.withType(JavaCompile) { options.compilerArgs << '-parameters' options.fork = true options.forkOptions.executable = 'javac' }
...but it does not seem to be working properly.
Gradle is not actually using javac (the executable). Rather, it uses the compiler classes programmatically. By default, Gradle will use the classes from the JDK you use for running Gradle. You can check the version by running gradlew --version .
The javac -Xlint options control warnings for all files compiled in a particular run of javac . You may have identified specific locations in source code that generate warnings that you no longer want to see. You can use the @SuppressWarnings annotation to suppress warnings whenever that code is compiled.
Gradle requires a Java JDK or JRE to be installed, version 6 or higher (to check, use java -version ). Gradle ships with its own Groovy library, therefore Groovy does not need to be installed. Any existing Groovy installation is ignored by Gradle. Gradle uses whatever JDK it finds in your path.
In Gradle, For java plugin, We need provide java version in build gradle for compile and generate class files. Java installation is required for building gradle project and running gradle build. to compile files in java, we use javac command and it has source and target arguments for javac command
to compile files in java, we use javac command and it has source and target arguments for javac command source tells to compiler to compile with specific version target tells to compiler to support lowest java version to support
This component includes the runtime dependency information for the JAR. See also the java extension. Gradle comes with a sophisticated incremental Java compiler that is active by default. Incremental builds are much faster. The smallest possible number of class files are changed.
Passing Arguments to Other Applications In some cases, we might want to pass some arguments to a third-party application from Gradle. Here, we use the commandLine property of the task to pass the executable along with any arguments. Again, we split the input based on spaces.
You should use standard way of configuring Java compile plugin:
apply plugin: 'java' compileJava { options.compilerArgs << '-parameters' }
For Android projects, one can add e.g. the below in the gradle android scope.
// Used to get more info from dagger regarding binding compile errors // see https://github.com/google/dagger/wiki/Dagger-2.17-@Binds-bugs tasks.withType(JavaCompile) { options.compilerArgs += ["-Adagger.floatingBindsMethods=enabled"] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With