Skip to content

Commit

Permalink
Proper JPMS module
Browse files Browse the repository at this point in the history
  • Loading branch information
amaembo committed Mar 19, 2021
1 parent 5efd267 commit e1f9f35
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 11 deletions.
49 changes: 42 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2020 JetBrains s.r.o.
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,18 +47,54 @@ subprojects {
project(':java5').archivesBaseName = 'annotations-java5'
project(':java8').archivesBaseName = 'annotations'

def jdk5Home = System.getenv("JDK_5")
if (hasProperty("JDK_5")) {
jdk5Home = JDK_5
}
if (jdk5Home == null) {
throw new GradleException('JDK_5 environment variable is not defined. It must point to any JDK that ' +
'is capable to compile with Java 5 target (Any JDK version from 1.5 to 1.8)')
}

configure(project(':module-info')) {
dependencies {
compile project(':common')
}

compileJava {
// Without common sources, compiler complains that exported packages don't exist
source = [sourceSets.main.java, project(':common').sourceSets.main.java]
}

task mainJar(type: Jar) {
}
}

configure([project(':java5'), project(':java8')]) {
dependencies {
compile project(':module-info')
}

task mainJar(type: Jar) {
manifest {
attributes('Automatic-Module-Name': 'org.jetbrains.' + archivesBaseName.replace('-', '_'))
}
into ("META-INF/versions/9", {
from (project(':module-info').sourceSets.main.output, {
// Skip extra files from common sources compiled with Java 9 target
include("module-info.class")
})
})
duplicatesStrategy = DuplicatesStrategy.FAIL
}

task sourceJar(type: Jar) {
into ("META-INF/versions/9", {
from project(':module-info').sourceSets.main.java
})
duplicatesStrategy = DuplicatesStrategy.FAIL
baseName = archivesBaseName + '-sources'
}

task javadocJar(type: Jar) {
duplicatesStrategy = DuplicatesStrategy.FAIL
from javadoc
}

Expand Down Expand Up @@ -144,6 +180,8 @@ configure(project(':java5')) {
}

compileJava {
options.fork = true
options.forkOptions.executable = "$jdk5Home/bin/javac"
dependsOn(generateSrc)
source sourceSets.generated.java
}
Expand All @@ -163,9 +201,6 @@ configure(project(':java5')) {
}

configure(project(':java8')) {
dependencies {
compile project(':common')
}

mainJar {
from sourceSets.main.output
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2000-2020 JetBrains s.r.o.
# Copyright 2000-2021 JetBrains s.r.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,4 +14,5 @@
# limitations under the License.
#

projectVersion=20.1.0
projectVersion=20.2.0
#JDK_5=<path-to-older-java-version>
18 changes: 17 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
#
# Copyright 2000-2021 JetBrains s.r.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#Fri Feb 16 15:00:47 MSK 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
17 changes: 17 additions & 0 deletions module-info/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

sourceCompatibility = 1.9
20 changes: 20 additions & 0 deletions module-info/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2000-2020 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module org.jetbrains.annotations {
exports org.intellij.lang.annotations;
exports org.jetbrains.annotations;
requires java.desktop;

This comment has been minimized.

Copy link
@Glavo

Glavo Mar 22, 2021

Maybe it's better to use requires static here?

This comment has been minimized.

Copy link
@amaembo

amaembo Mar 22, 2021

Author Collaborator

Good idea, thanks

}
18 changes: 17 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

rootProject.name = 'annotations-parent'

include 'common', 'java5', 'java8'
include 'common', 'java5', 'java8', 'module-info'

0 comments on commit e1f9f35

Please sign in to comment.