Traincraft

Traincraft

1M Downloads

Missing source compatibility in build.gradle cause compile to fail in Linux Mint 19

Tsoccerguy3 opened this issue ยท 6 comments

commented

Add to build.gradle

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}


otal time: 1.034 secs
wds@wds-GP72-6QF:~/Dev/tc$ gradle build
:compileApiJava NO-SOURCE
:processApiResources NO-SOURCE
:apiClasses UP-TO-DATE
:sourceMainJava
:compileJava
Specifying the source path in the CompilerOptions compilerArgs property has been deprecated and is scheduled to be removed in Gradle 4.0. Instead, use the CompilerOptions sourcepath property directly.
warning: [options] bootstrap class path not set in conjunction with -source 1.6
/home/wds/Dev/tc/build/sources/java/train/common/core/handlers/RecipeHandler.java:36: error: diamond operator is not supported in -source 1.6
ArrayList entries = new ArrayList<>();
^
(use -source 7 or higher to enable diamond operator)
1 error
1 warning
:compileJava FAILED

FAILURE: Build failed with an exception.

commented

The source compatibility should be automatically defined from the project initialization.
Be sure to run the gradlewLinux file with the augments setupDecompWorkspace --refresh-dependencies eclipse

alternatively you can get the optional gradle import plugin for eclipse and use it, which is more reliable.

Additionally this project is developed for source compatibility to java 1.6, so be sure not to use any 1.7 or later code, or a similar error will occur.

commented

To automate a compile from command line please use
gradlew setupDecompWorkspace --refresh-dependencies build

in windows 10 you can try this from powershell
./gradlew setupDecompWorkspace --refresh-dependencies build

To automate it from terminal use
./gradlewLinux setupDecompWorkspace --refresh-dependencies build

Again, a lot of this is handled from the workspace setup, rather than the gradle file.
In addition to that target compatibility should be 1.6, and the gradle file hasn't been modified in 8 months.

commented

I checked Windows 10x64 and Linux Mint 19
I now have to edit the build.gradle after a Git Pull . I can not automate a compile from the command line .
It's fine in eclipse and idea because the settings are saved

but to automate a script or batch i think this should be in the build.gradle
everything works fine with these 2 entries . idk , something has change in the last week with Gradle

targetCompatibility = '1.8'
sourceCompatibility = '1.8'

commented

Apparently , Gradle 4.10 needs
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
The only thing that changed in the last week , was Gradle 4.9 was updated to 4.10 on my Windows OS and Linux . I recieved the same error on Both OS's with Gradle 4.10 . Maybe some internal changes on Gradle 4.10 . Guessing Gradle 5 will be the same

C:\Users\ASUS\Dev\TC5>gradlew setupDecompWorkspace --refresh-dependencies build


Powered By MCP:
http://modcoderpack.com/
Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
MCP Data version : unknown


:extractMcpData UP-TO-DATE
:getVersionJson
:extractUserDev UP-TO-DATE
:genSrgs SKIPPED
:extractNatives UP-TO-DATE
:getAssetsIndex
:getAssets
:makeStart
[ant:javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[ant:javac] 1 warning
:downloadMcpTools SKIPPED
:downloadClient SKIPPED
:downloadServer SKIPPED
:mergeJars SKIPPED
:deobfuscateJar SKIPPED
:decompile SKIPPED
:processSources SKIPPED
:remapJar SKIPPED
:extractMinecraftSrc SKIPPED
:recompMinecraft SKIPPED
:repackMinecraft SKIPPED
:setupDecompWorkspace
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava UP-TO-DATE
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\ASUS\Dev\TC5\build\sources\java\train\common\core\handlers\RecipeHandler.java:36: error: diamond operator is not supported in -source 1.6
ArrayList entries = new ArrayList<>();
^
(use -source 7 or higher to enable diamond operator)
1 error
1 warning
:compileJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileJava'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 47.49 secs

commented

Whoopsie, that one was my bad. There's a java 7 command floating around in there.

This should fix it. Or point out another java 7 initializer that was left in by accident.

commented

Fixed