Git Product home page Git Product logo

Comments (22)

fommil avatar fommil commented on June 27, 2024

note the suggestion to look for a .java-home file on startup of sbt. Is this something you would consider supporting?

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

We know it's running the right java binary, after that it's in sbt's hands. It's a bug in sbt if it doesn't use the javac which corresponds to the running java.

In principle I could modify the path when JAVA_HOME or -java-home is encountered, but I am leery that this may have unanticipated consequences and I don't want to have to wonder about it.

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

See sbt/sbt#510 which indicates "If you specify javaHome explicitly (such as in your ~/.sbt/global.sbt configuration file), it will construct the path to the binary directly. I expect that would be a suitable workaround."

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

I can maybe add the javaHome setting to the command line when -java-home is given.

from sbt-extras.

fommil avatar fommil commented on June 27, 2024

This is how I'm currently dealing with it, which is nice because I have project-specific java requirements (which can't be committed to SCM because of local paths) and I rarely remember to augment sbt with the correct -java-home anyway:

https://github.com/fommil/unix/blob/master/bin/sbt#L8

It would be awesome if you could take the same concept and put it in sbt-extras (no change to current behaviour if .javahome is not present).

I'll do a quick grep of sbt's sources to see where they might be calling javac without the path.

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

If sbt/sbt#510 can be believed, they are intentionally calling javac without a path.

from sbt-extras.

fommil avatar fommil commented on June 27, 2024

That's awful

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

My enthusiasm didn't extend all the way to writing a test, but as of 2e2280f this behaves as described. I verified the change in behavior.

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

I'm reopening this because I won't pay the price of six lines of new noise every time I start sbt. So if we want this to stick around it would be great if someone would investigate how to shut it up for a while, then let it speak.

[info] Set current project to root (in build file:/mirror/forks/wartremover/)
[info] Defining {.}/*:javaHome
[info] The new value will be used by core/*:compilers, core/*:console::compilers and 24 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to root (in build file:/mirror/forks/wartremover/)

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

A likely outcome is for me to only set javaHome when -java-home is given, but not based on JAVA_HOME.

from sbt-extras.

dwijnand avatar dwijnand commented on June 27, 2024

How about the necessary bash magic to only set javaHome from JAVA_HOME when java and JAVA_HOME/bin/java are not the same?

That way for you and me there's no spam and for people with JAVA_HOME's pointing to alternative java binaries to PATH it's consistent (same java & javac versions) and explicit.

from sbt-extras.

fommil avatar fommil commented on June 27, 2024

does this mean you've found out how to convince sbt to use the javaHome version of javac? Because if that is not the case, then setting PATH and JAVA_HOME is the only way to guarantee a good build (see my customisation to your script above which reads the java home from a project specific .javahome file)

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

@fommil Setting javaHome is enough to convince sbt to use the javaHome version of javac, that's the point of the commit.

from sbt-extras.

dwijnand avatar dwijnand commented on June 27, 2024

Well can't do it via path, at least not for me on Mac OS X, as my java is /usr/bin/java, which through Mac voodoo is also my JAVA_HOME/bin/java.

Perhaps test -version results? I guess technically people could have different java installations, perhaps with JCE, or dropped in jars.. but I guess they can open tickets, or be explicit with -java-home.

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

@dwijnand If you're up for investigating, forget about javaHome and consider the larger question: my script piles up a list of sbt settings which need to be run. What is the fastest and quietest way to accomplish that.

from sbt-extras.

dwijnand avatar dwijnand commented on June 27, 2024

I'm sure I know sbt much less than you.

However, I think the script should continue to have the sbt commands be temporary only, ie. not saving them to disk (which it currently only does for explicit sbt versions written to build.properties). So if you want to keep that, I don't see any other option for sbt commands in general.

--warn "set javaHome in ThisBuild := Some(blah)" --info doesn't work :(

from sbt-extras.

paulp avatar paulp commented on June 27, 2024

Ah, but you gave me the idea which does work.

java -jar ~/.sbt/launchers/0.13.5/sbt-launch.jar \
  '; -- error ;  set javaHome in ThisBuild := Some(file("/tmp/bippy")) ; -- info ; about '

from sbt-extras.

dwijnand avatar dwijnand commented on June 27, 2024

Aw yiss! Excellent. And as far as my test can tell me this doesn't interfere with setting -w/--warn or -d/--debug before or after that command chain.

from sbt-extras.

dwijnand avatar dwijnand commented on June 27, 2024

Oh no, it does :-/

  > java -jar ~/.sbt/launchers/0.13.5/sbt-launch.jar --warn \
"; -- warn ; set javaHome in ThisBuild := Some(file(\"/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home\")) ; -- info" shell
  root#test> show javaHome
  [info] root/*:javaHome
  [info]    Some(/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home)
  [info] test/*:javaHome
  [info]    Some(/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home)

from sbt-extras.

JurajBurian avatar JurajBurian commented on June 27, 2024

I am dealing with same problem. In my opinion,
the location of javac should be derived from value of the JAVA_HOME variable - if exists.
If JAVA_HOME variable doesn't exists, then location of javac should be derived from the path of used java executable.
If there is not derived value of javac (from java executable), then PATH may be used, but as last choice.

On linux, I am must use next workaround:
#!/usr/bin/env bash
export PATH=$JAVA_HOME/bin:$PATH
/opt/sbt/bin/sbt -java-home $JAVA_HOME "$@"

from sbt-extras.

fommil avatar fommil commented on June 27, 2024

any progress on this? I'm still using my .javahome hack in my custom sbt launcher.

from sbt-extras.

dwijnand avatar dwijnand commented on June 27, 2024

@fommil Do you mind seeing if my branch attached to #95 works for you?

from sbt-extras.

Related Issues (20)

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.