New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable testing jdk9 things if JDK9 is used #7

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@ktoso
Member

ktoso commented Aug 28, 2017

No description provided.

@ktoso

Requesting help, see my comment in line - is this a bad way of trying to do this?

If on JDK9 I want to include those sources / tests basically

cc @dwijnand @eed3si9n @2m

Keys.`package` :=
(Keys.`package` in Compile).dependsOn(
compile in Compile,
compile in MultiReleaseJar
).value
) ++ Seq(
// ---- testing configuration ----
sourceDirectories in Test ++= {

This comment has been minimized.

@ktoso

ktoso Aug 28, 2017

Member

I'm somewhat confused why this "works" but "has no effect".

If I show test:SourceDirectories I get:

[info] [info] Loading settings from build.sbt ...
[info] [info] Set current project to jdk9-testing-test (in build file:/private/var/folders/6w/p7yjvbwd14v4jh29ytjsq11m0000gn/T/sbt_b9ac51af/jdk9-testing-test/)
[info] [info] * /private/var/folders/6w/p7yjvbwd14v4jh29ytjsq11m0000gn/T/sbt_b9ac51af/jdk9-testing-test/src/test/scala-2.12
[info] [info] * /private/var/folders/6w/p7yjvbwd14v4jh29ytjsq11m0000gn/T/sbt_b9ac51af/jdk9-testing-test/src/test/scala
[info] [info] * /private/var/folders/6w/p7yjvbwd14v4jh29ytjsq11m0000gn/T/sbt_b9ac51af/jdk9-testing-test/src/test/java
[info] [info] * /private/var/folders/6w/p7yjvbwd14v4jh29ytjsq11m0000gn/T/sbt_b9ac51af/jdk9-testing-test/target/scala-2.12/src_managed/test
[info] [info] * /private/var/folders/6w/p7yjvbwd14v4jh29ytjsq11m0000gn/T/sbt_b9ac51af/jdk9-testing-test/src/test/java-jdk9
[info] [info] * /private/var/folders/6w/p7yjvbwd14v4jh29ytjsq11m0000gn/T/sbt_b9ac51af/jdk9-testing-test/src/test/scala-jdk9

Which should do the trick I thought, but it does not attempt to compile the source in that directory at all hmmm

This comment has been minimized.

@jrudolph

jrudolph Aug 28, 2017

Member

Which effect did you expect and what did happen instead?

This comment has been minimized.

@ktoso

ktoso Aug 28, 2017

Member

Not only should it be included in that list, but those files (in those directories) should also be compiled is what I expected. If classpath will end up wrong I can fix that, but I don't get why it's listing the dirs correctly, but not compiling things from them - specifically the jdk9-testing-test/src/test/scala-jdk9/com/example/Jdk9VersionOfSomeTests.scala

This comment has been minimized.

@jrudolph

jrudolph Aug 28, 2017

Member

I guess it's because this setting is not used for compiling ;)

I think it should be managedSourceDirectories instead.

This comment has been minimized.

@jrudolph

jrudolph Aug 28, 2017

Member

Eh, I mean unmanagedSourceDirectories if the user puts files into it.

This comment has been minimized.

@jrudolph

jrudolph Aug 28, 2017

Member

I guess one reason why that's so hard to find out is that inspect tree "misses" some edges when the keys delegate to something else. This can be configured by passing actual = true to Def.compiled which inspect does but inspect tree does not so it's hard to trace back the actual dependency path from compileIncremental to unmanagedSourceDependencies.

I built a better inspect2 tree (subtle naming, huh?) that will follow the delegations as well. Can be copied to any project for now from here: https://gist.github.com/jrudolph/9e0e0e8a0df35c23713dfc314670db87

This comment has been minimized.

@jrudolph

jrudolph Aug 28, 2017

Member

While at it I went a step further and implemented an inspect2 how command that shows paths from a goal setting to a transitive dependency. E.g. for test:compile and test:unmanagedSourceDirectories:

> inspect2 how test:compile test:unmanagedSourceDirectories
[info] backend/test:compile -> backend/test:manipulateBytecode -> backend/test:compileIncremental -> backend/test:compile::compileInputs -> backend/test:sources -> backend/test:unmanagedSources -> backend/test:unmanagedSourceDirectories
[info] backend/test:compile -> backend/test:manipulateBytecode -> backend/test:compileIncremental -> backend/test:compile::compileInputs -> backend/test:scalariformFormat -> backend/test:sourceDirectories -> backend/test:unmanagedSourceDirectories

If the output is empty, the two settings don't relate.

This comment has been minimized.

@ktoso

ktoso Aug 29, 2017

Member

StackOverflow answers lied to me, damn them! :) (I guess it was about some ancient version...)
Indeed the unmanaged seems to do the trick, thanks

// (test in MultiReleaseJarTest).dependsOn(
// test in Test
// ).value,

This comment has been minimized.

@eed3si9n

eed3si9n Aug 28, 2017

Member

Does:

test in Test := {
  val _ = (test in MultiReleaseJarTest).value
  (test in Test).value
}

work?

This comment has been minimized.

@ktoso

ktoso Aug 28, 2017

Member

Oh it does, thanks! Will change the other place too where I used this weird pattern

@ktoso

This comment has been minimized.

Member

ktoso commented Aug 29, 2017

Thanks guys, almost there - now just need to fix the classpath during test execution. I made a new branch since this one got a bit messy. Closing

@ktoso ktoso closed this Aug 29, 2017

@ktoso ktoso deleted the one-small-step-for-man-one-giant-leap-for-jdk9-compatibility branch Aug 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment