Coder Social home page Coder Social logo

themrmilchmann / gradle-ecj Goto Github PK

View Code? Open in Web Editor NEW
10.0 5.0 2.0 447 KB

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

Home Page: https://plugins.gradle.org/plugin/io.github.themrmilchmann.ecj

License: MIT License

Kotlin 100.00%
ecj eclipse-compiler gradle java compile

gradle-ecj's Introduction

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.

gradle-ecj's People

Contributors

arturbosch avatar dependabot[bot] avatar renovate[bot] avatar themrmilchmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gradle-ecj's Issues

add support for compiler participants ?

Thanks so much for creating this new ecj plugin ! Do you think there's a possibility to allow execution of ecj compiler participants ? These are normally bundled as regular eclipse plugins, and the one I'm familiar with is https://github.com/java2script/java2script/ - which transpiles Java code to .js files, allowing Java swing apps to run in the browser (I develop this one: https://www.jalview.org/jalview-js/JalviewJS.shtml but the plugin's main developer is @BobHanson, who also develops https://chemapps.stolaf.edu/jmol/jsmol/jsmol.htm ).

Use of eclipse settings "org.eclipse.jdt.core.prefs"

I am currently using your plugin and previously used the plugin de.set.ecj. The Eclipse settings were used there. Can I configure your plugin so that the Eclipse settings are used?

compileJava {
options.compilerArgs << '-properties' << '$projectDir/.settings/org.eclipse.jdt.core.prefs'
}

The background is that I need source compatibility on Java 11, but target compatibility on 17 and compliance on Java 17. Unfortunately, this cannot be mapped with the Gradle settings.
The goal is that my library can be used in Java 11 projects

Investigate CI flakiness

(Note that CI is failing due to hardware constraints on GHA runners and Gradle's TestKit being a bit resource hungry. This is not actually a bug in the plugin.)

Migrate to Gradle's "official" support for custom compilers

While it remains to be seen if this ends up being merged, gradle/gradle#24649 looks like a promising solution for custom compiler jars. It makes sense to test against this change to check if everything works as intended. Using a custom Gradle build should hopefully not be too tricky but might require some more work.

If this test succeeds and when the change is merged, I should finally be able to release a stable version of this plugin. ๐Ÿฅณ

Cannot use ECJ 3.36.0 to compile Java 17 sources

I set in my build.gradle the ECJ version to 3.36.0 to use it for compiling Java 17 source files.

I get this error:

$ ./gradlew build

> Task :compileJava FAILED
source level should be comprised in between '1.3' and '1.8' (or '5', '5.0', ..., '8' or '8.0'): 17

Is compiling Java 17 source code not possible?

Gradle 8 compatibility

Gradle 8 changed a lot of internals to use the property&provider API more extensively. This has caused the configuration applied by this plugin to break. I'm aware that the configuration could be considered hacky but, unfortunately, I'm not aware of a public API to implement the plugin properly.

Specifically, the plugin currently sets the javaCompiler property of JavaCompile tasks to null to avoid some default configuration. The ECJ is later plugged in using the forkOptions. This works on Gradle 7.x but not on later versions. Adjustments are necessary to fix this.

  • [ ] Reenable CI checks for the samples

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.