Skip to content

A Gradle plugin for using the Eclipse Compiler for Java (ECJ) for compiling Java files.

License

Notifications You must be signed in to change notification settings

TheMrMilchmann/gradle-ecj

Repository files navigation

Gradle Eclipse Compiler for Java Plugin

License Maven Central Gradle Plugin Portal Gradle Java

A Gradle plugin for using the Eclipse Compiler for Java (ECJ) for compiling Java files.

This plugin is loosely based on Niklas Walter's Gradle Eclipse Compiler for Java Plugin.

Usage

Gradle Groovy DSL

plugins {
    id "io.github.themrmilchmann.ecj" version "0.2.0"
}

Usually, simply applying the plugin is enough to cover most use-cases. However, in some scenarios, the ECJ artifact may be changed.

Configuring ECJ (via dependency)

dependencies {
    ecj "org.eclipse.jdt:ecj:3.32.0"
}

Configuring ECJ (via extension)

ecj {
    compilerGroupId = "org.eclipse.jdt"
    compilerArtifactId = "ecj"
    compilerVersion = "3.32.0"
}

Gradle Kotlin DSL

Applying the plugin

plugins {
    id("io.github.themrmilchmann.ecj") version "0.2.0"
}

Usually, simply applying the plugin is enough to cover most use-cases. However, in some scenarios, the ECJ artifact may be changed.

Configuring ECJ (via dependency)

dependencies {
    ecj("org.eclipse.jdt:ecj:3.32.0")
}

Configuring ECJ (via extension)

ecj {
    compilerGroupId.set("org.eclipse.jdt")
    compilerArtifactId.set("ecj")
    compilerVersion.set("3.32.0")
}

Compatibility Map

Gradle Minimal plugin version
8.0 0.2.0
7.4 0.1.0

Plugin defaults

Plugin version Default ECJ version
0.2.0+ 3.32.0
0.1.0+ 3.30.0

Building from source

Setup

This project uses Gradle's toolchain support to detect and select the JDKs required to run the build. Please refer to the build scripts to find out which toolchains are requested.

An installed JDK 1.8 (or later) is required to use Gradle.

Building

Once the setup is complete, invoke the respective Gradle tasks using the following command on Unix/macOS:

./gradlew <tasks>

or the following command on Windows:

gradlew <tasks>

Important Gradle tasks to remember are:

  • clean - clean build results
  • build - assemble and test the Java library
  • publishToMavenLocal - build and install all public artifacts to the local maven repository

Additionally tasks may be used to print a list of all available tasks.

License

Copyright (c) 2022-2024 Leon Linhart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.