ENT-1467: Make the deterministic JDK image compatible with IntelliJ. (#3416)

* Expand the deterministic JDK image to make it friendlier to IntelliJ.
* Fix Gradle always to use the latest deterministic rt.jar available.
* Write JDK items directly from Gradle.
This commit is contained in:
Chris Rankin 2018-06-26 11:53:16 +01:00 committed by GitHub
parent 4ea8091667
commit a4d2acbea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 37 deletions

View File

@ -83,7 +83,6 @@ buildscript {
ext.jcabi_manifests_version = '1.1'
ext.picocli_version = '3.0.0'
ext.deterministic_rt_version = '1.0-SNAPSHOT'
// Name of the IntelliJ SDK created for the deterministic Java rt.jar.
// ext.deterministic_idea_sdk = '1.8 (Deterministic)'

View File

@ -48,6 +48,7 @@ task makeJdk(type: Exec) {
task runtimeJar(type: Jar, dependsOn: makeJdk) {
baseName 'deterministic-rt'
inputs.dir "libs"
from(zipTree("libs/rt.jar"))
from(zipTree("libs/jce.jar"))

View File

@ -104,6 +104,24 @@ This is possible, but slightly tricky to configure because IntelliJ will not rec
Gradle be configured to use the Project's SDK.
Creating the Deterministic SDK
Gradle creates a suitable JDK image in the project's ``jdk8u-deterministic/jdk`` directory, and you can
configure IntelliJ to use this location for this SDK. However, you should also be aware that IntelliJ SDKs
are available for *all* projects to use.
To create this JDK image, execute the following:
.. code-block:: bash
$ gradlew jdk8u-deterministic:copyJdk
..
Now select ``File/Project Structure/Platform Settings/SDKs`` and add a new JDK SDK with the
``jdk8u-deterministic/jdk`` directory as its home. Rename this SDK to something like "1.8 (Deterministic)".
This *should* be sufficient for IntelliJ. However, if IntelliJ realises that this SDK does not contain a
full JDK then you will need to configure the new SDK by hand:
#. Create a JDK Home directory with the following contents:
``jre/lib/rt.jar``
@ -120,18 +138,6 @@ Creating the Deterministic SDK
..
.. note:: Gradle already creates this JDK in the project's ``jdk8u-deterministic/jdk`` directory, and you could
configure IntelliJ to use this location as well. However, you should also be aware that IntelliJ SDKs
are available for *all* projects to use.
To create this deterministic JDK image, execute the following:
.. code-block:: bash
$ gradlew jdk8u-deterministic:copyJdk
..
#. While IntelliJ is *not* running, locate the ``config/options/jdk.table.xml`` file in IntelliJ's configuration
directory. Add an empty ``<jdk>`` section to this file:
@ -148,10 +154,10 @@ Creating the Deterministic SDK
..
#. Open IntelliJ and select ``File/Project Structure/Platform Settings/SDKs``. The "1.8 (Deterministic)" SDK should
now be present. Select it and then click on the ``Classpath`` tab. Press the "Add" / "Plus" button to add
``rt.jar`` to the SDK's classpath. Then select the ``Annotations`` tab and include the same JAR(s) as the other
SDKs.
#. Open IntelliJ and select ``File/Project Structure/Platform Settings/SDKs``. The "1.8 (Deterministic)" SDK
should now be present. Select it and then click on the ``Classpath`` tab. Press the "Add" / "Plus" button to
add ``rt.jar`` to the SDK's classpath. Then select the ``Annotations`` tab and include the same JAR(s) as
the other SDKs.
Configuring the Corda Project
#. Open the root ``build.gradle`` file and define this property:

View File

@ -8,23 +8,39 @@ repositories {
}
ext {
jdk_home = "$projectDir/jdk"
jdk_home = "$projectDir/jdk".toString()
rt_jar = "$jdk_home/jre/lib/rt.jar".toString()
}
configurations {
jdk
jdk.resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
}
dependencies {
jdk "net.corda:deterministic-rt:$deterministic_rt_version:api"
// Ensure everyone uses the latest SNAPSHOT.
jdk "net.corda:deterministic-rt:latest.integration:api"
}
task copyJdk(type: Copy) {
outputs.dir jdk_home
from(configurations.jdk.asPath) {
rename 'deterministic-rt-(.*).jar', 'rt.jar'
}
into "$jdk_home/jre/lib"
doLast {
def eol = System.getProperty('line.separator')
file("$jdk_home/release").write "JAVA_VERSION=\"1.8.0_172\"$eol"
mkdir "$jdk_home/bin"
file("$jdk_home/bin/javac").with {
write "#!/bin/sh\necho \"javac 1.8.0_172\"\n"
setExecutable true, false
return
}
}
}
assemble.dependsOn copyJdk