Author Topic: Java version used in gradle builds?  (Read 101 times)

rowbearto

  • Senior Community Member
  • Posts: 1541
  • Hero Points: 113
Java version used in gradle builds?
« on: November 26, 2019, 03:48:48 pm »
When I setup a new Java-Gradle project, how do I specify which java executable to build my code with?

I notice in Tools->Options->Languages->Application Languages->Java->Compiler properties that one can specify a compiler. However the documentation at the bottom of this screen indicates it is not for building, just preprocessing, parsing, analysis and cross-referencing.

Is the "java" that is used for building the gradle simply the one found in the PATH?

I would prefer to have a way to tell SlickEdit which java to use for gradle builds instead of making sure my PATH is properly set before invoking SE.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1164
  • Hero Points: 110
Re: Java version used in gradle builds?
« Reply #1 on: November 26, 2019, 04:45:12 pm »
Hmm, what's supposed to happen is it uses what's set in the Compiler dropdown of the Compile/Link tab in project properties.  That can also depend on what Java compilers that are set up Languages -> Java -> Compiler Properties.  But I can see the setting isn't taking effect.

I'll work on a hotfix for this.  In the meantime, you can work around it by going to the tools tab, select "Build", and click on Advanced, and add a JAVA_HOME that points to the java version you want. 

rowbearto

  • Senior Community Member
  • Posts: 1541
  • Hero Points: 113
Re: Java version used in gradle builds?
« Reply #2 on: November 26, 2019, 04:48:27 pm »
OK, thanks! May also want to add this to the description of "Compiler properties" in the tools->options->...

Marcel

  • Senior Community Member
  • Posts: 224
  • Hero Points: 26
Re: Java version used in gradle builds?
« Reply #3 on: November 27, 2019, 04:18:47 pm »
Because of the 6-month release cycle for new JDKs (currently at Java 13), I am driving all my Java builds (gradle and ordinary) with an externally set JAVA_HOME.
Each project has an opening script that prefixes JAVA_HOME/bin to the path, a measure that I am not happy with.
Every 6 months after a JDK upgrade, I have to go and muck around with the Java compiler settings in every project. Can you think of a way to have project->compile/link to use the JDK pointed to by JAVA_HOME, and if necessary, build the compiler tag file?  I am also not sure why we still have the JDK settings in build->Java options, they clearly counteract the settings made in the project.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1164
  • Hero Points: 110
Re: Java version used in gradle builds?
« Reply #4 on: November 27, 2019, 05:30:58 pm »
You can tell a project to use the latest JDK version in the Compile/Link tab of the project properties.  But it only knows about the compilers that have been added in the Languages -> Java -> Compiler Properties, so you'd still need to go there every time there's another JDK release.

I think it's possible to add a project compile/link setting that says "Use JAVA_HOME" if we add some plumbing to keep up with the JAVA_HOME the editor started up with.   That would sidestep having to enter it into the known compiler list.

I'll have to check and see what is using the JDK set in the Java Options dialog.  I think most things should reference either the project's settings, or use the JDK set as default in the Java Compiler Properties page.