Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using IntelliJ Javac2 compiler instead of standard compiler in Gradle

I have a project that contains IntelliJ forms and need to compile it with the javac2 compiler. This used to be done as an Ant task as described here: Ant task for compiling GUI forms (Intellij IDEA)

Is there a way how to replace the standard java compiler with the javac2 compiler in Gradle?

like image 580
MartinTeeVarga Avatar asked Nov 05 '25 16:11

MartinTeeVarga


1 Answers

This is the best I could do in Gradle. The Java classes are first compiled and then instrumented by javac2:

configurations {
    intellij
}

dependencies {
    intellij 'com.intellij:javac2:13'
}

compileJava {
    doLast() {
        project.ant.taskdef name: 'javac2', classname: 'com.intellij.ant.Javac2', classpath: project.configurations.intellij.asPath
        project.ant.javac2 srcdir: project.sourceSets.main.java.srcDirs.join(':'),
                includes: 'yourpackage/**/*.form',
                classpath: project.sourceSets.main.runtimeClasspath.asPath,
                destdir: project.sourceSets.main.output.classesDir,
                source: project.sourceCompatibility,
                target: project.targetCompatibility,
                includeAntRuntime: false,
                instrumentnotnull: project.ext.instrument
    }
}
like image 63
MartinTeeVarga Avatar answered Nov 07 '25 11:11

MartinTeeVarga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!