mirror of
https://github.com/corda/corda.git
synced 2024-12-19 21:17:58 +00:00
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:
parent
4ea8091667
commit
a4d2acbea2
@ -83,7 +83,6 @@ buildscript {
|
|||||||
ext.jcabi_manifests_version = '1.1'
|
ext.jcabi_manifests_version = '1.1'
|
||||||
ext.picocli_version = '3.0.0'
|
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.
|
// Name of the IntelliJ SDK created for the deterministic Java rt.jar.
|
||||||
// ext.deterministic_idea_sdk = '1.8 (Deterministic)'
|
// ext.deterministic_idea_sdk = '1.8 (Deterministic)'
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ task makeJdk(type: Exec) {
|
|||||||
|
|
||||||
task runtimeJar(type: Jar, dependsOn: makeJdk) {
|
task runtimeJar(type: Jar, dependsOn: makeJdk) {
|
||||||
baseName 'deterministic-rt'
|
baseName 'deterministic-rt'
|
||||||
|
inputs.dir "libs"
|
||||||
|
|
||||||
from(zipTree("libs/rt.jar"))
|
from(zipTree("libs/rt.jar"))
|
||||||
from(zipTree("libs/jce.jar"))
|
from(zipTree("libs/jce.jar"))
|
||||||
|
@ -104,54 +104,60 @@ This is possible, but slightly tricky to configure because IntelliJ will not rec
|
|||||||
Gradle be configured to use the Project's SDK.
|
Gradle be configured to use the Project's SDK.
|
||||||
|
|
||||||
Creating the Deterministic SDK
|
Creating the Deterministic SDK
|
||||||
#. Create a JDK Home directory with the following contents:
|
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.
|
||||||
|
|
||||||
``jre/lib/rt.jar``
|
To create this JDK image, execute the following:
|
||||||
|
|
||||||
where ``rt.jar`` here is this renamed artifact:
|
.. code-block:: bash
|
||||||
|
|
||||||
.. code-block:: xml
|
$ gradlew jdk8u-deterministic:copyJdk
|
||||||
|
|
||||||
<dependency>
|
..
|
||||||
<groupId>net.corda</groupId>
|
|
||||||
<artifactId>deterministic-rt</artifactId>
|
|
||||||
<classifier>api</classifier>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
..
|
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)".
|
||||||
|
|
||||||
.. note:: Gradle already creates this JDK in the project's ``jdk8u-deterministic/jdk`` directory, and you could
|
This *should* be sufficient for IntelliJ. However, if IntelliJ realises that this SDK does not contain a
|
||||||
configure IntelliJ to use this location as well. However, you should also be aware that IntelliJ SDKs
|
full JDK then you will need to configure the new SDK by hand:
|
||||||
are available for *all* projects to use.
|
|
||||||
|
|
||||||
To create this deterministic JDK image, execute the following:
|
#. Create a JDK Home directory with the following contents:
|
||||||
|
|
||||||
.. code-block:: bash
|
``jre/lib/rt.jar``
|
||||||
|
|
||||||
$ gradlew jdk8u-deterministic:copyJdk
|
where ``rt.jar`` here is this renamed artifact:
|
||||||
|
|
||||||
..
|
.. code-block:: xml
|
||||||
|
|
||||||
#. While IntelliJ is *not* running, locate the ``config/options/jdk.table.xml`` file in IntelliJ's configuration
|
<dependency>
|
||||||
directory. Add an empty ``<jdk>`` section to this file:
|
<groupId>net.corda</groupId>
|
||||||
|
<artifactId>deterministic-rt</artifactId>
|
||||||
|
<classifier>api</classifier>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
.. code-block:: xml
|
..
|
||||||
|
|
||||||
<jdk version="2">
|
#. While IntelliJ is *not* running, locate the ``config/options/jdk.table.xml`` file in IntelliJ's configuration
|
||||||
<name value="1.8 (Deterministic)"/>
|
directory. Add an empty ``<jdk>`` section to this file:
|
||||||
<type value="JavaSDK"/>
|
|
||||||
<version value="java version "1.8.0""/>
|
|
||||||
<homePath value=".. path to the deterministic JDK directory .."/>
|
|
||||||
<roots>
|
|
||||||
</roots>
|
|
||||||
</jdk>
|
|
||||||
|
|
||||||
..
|
.. code-block:: xml
|
||||||
|
|
||||||
#. Open IntelliJ and select ``File/Project Structure/Platform Settings/SDKs``. The "1.8 (Deterministic)" SDK should
|
<jdk version="2">
|
||||||
now be present. Select it and then click on the ``Classpath`` tab. Press the "Add" / "Plus" button to add
|
<name value="1.8 (Deterministic)"/>
|
||||||
``rt.jar`` to the SDK's classpath. Then select the ``Annotations`` tab and include the same JAR(s) as the other
|
<type value="JavaSDK"/>
|
||||||
SDKs.
|
<version value="java version "1.8.0""/>
|
||||||
|
<homePath value=".. path to the deterministic JDK directory .."/>
|
||||||
|
<roots>
|
||||||
|
</roots>
|
||||||
|
</jdk>
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
#. 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
|
Configuring the Corda Project
|
||||||
#. Open the root ``build.gradle`` file and define this property:
|
#. Open the root ``build.gradle`` file and define this property:
|
||||||
|
@ -8,23 +8,39 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
jdk_home = "$projectDir/jdk"
|
jdk_home = "$projectDir/jdk".toString()
|
||||||
rt_jar = "$jdk_home/jre/lib/rt.jar".toString()
|
rt_jar = "$jdk_home/jre/lib/rt.jar".toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
jdk
|
jdk.resolutionStrategy {
|
||||||
|
cacheChangingModulesFor 0, 'seconds'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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) {
|
task copyJdk(type: Copy) {
|
||||||
|
outputs.dir jdk_home
|
||||||
|
|
||||||
from(configurations.jdk.asPath) {
|
from(configurations.jdk.asPath) {
|
||||||
rename 'deterministic-rt-(.*).jar', 'rt.jar'
|
rename 'deterministic-rt-(.*).jar', 'rt.jar'
|
||||||
}
|
}
|
||||||
into "$jdk_home/jre/lib"
|
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
|
assemble.dependsOn copyJdk
|
||||||
|
Loading…
Reference in New Issue
Block a user