Skip to content

Commit d0aafde

Browse files
committed
feat: support jpms in annotations module
- feat: add `module-info.java` to `annotations` - chore: wire up build support for building `java9` root in MRJAR - chore: apply java9 jpms changes to both maven and makefile build Signed-off-by: Sam Gammon <[email protected]>
1 parent cafcb24 commit d0aafde

File tree

6 files changed

+80
-4
lines changed

6 files changed

+80
-4
lines changed

annotations/.classpath

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
<classpathentry kind="src" path="src/main/java"/>
44
<classpathentry kind="lib" path="build_result/j2objc_annotations.jar"/>
55
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6-
<classpathentry kind="output" path="build_result/eclipse"/>
6+
<classpathentry kind="output" path="build_result/eclipse"/>
77
</classpath>

annotations/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

annotations/Makefile

+12-3
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,26 @@ DIST_JAR = $(DIST_JAR_DIR)/$(JAR_NAME)
2525

2626
CLASSES_DIR = $(BUILD_DIR)/classes
2727
JAVA_SOURCE_DIR = src/main/java
28+
JAVA9_CLASSES_DIR = $(BUILD_DIR)/classes-java9
29+
JPMS_CLASS = $(JAVA9_CLASSES_DIR)/module-info.class
2830

2931
SOURCE_JAVA_FULL = $(ANNOTATION_SOURCE_JAVA:%=$(JAVA_SOURCE_DIR)/%)
32+
SOURCE_JAVA9_MODULE = $(ANNOTATION_MODULE_INFO:%=$(JAVA_SOURCE_DIR)/%)
3033

31-
$(BUILD_DIR) $(CLASSES_DIR) $(DIST_JAR_DIR):
34+
$(BUILD_DIR) $(CLASSES_DIR) $(JAVA9_CLASSES_DIR) $(DIST_JAR_DIR):
3235
@mkdir -p $@
3336

34-
$(JAR): $(SOURCE_JAVA_FULL) | $(BUILD_DIR) $(CLASSES_DIR)
37+
$(JPMS_CLASS):
38+
@echo Building j2objc annotations JPMS module
39+
@$(JAVAC) -sourcepath $(JAVA_SOURCE_DIR) -encoding UTF-8 --release 9 -d $(JAVA9_CLASSES_DIR) \
40+
-nowarn $(SOURCE_JAVA9_MODULE)
41+
@rm -fr $(JAVA9_CLASSES_DIR)/com
42+
43+
$(JAR): $(SOURCE_JAVA_FULL) | $(BUILD_DIR) $(CLASSES_DIR) $(JAVA9_CLASSES_DIR) $(JPMS_CLASS)
3544
@echo Building j2objc annotations
3645
@$(JAVAC) -encoding UTF-8 -d $(CLASSES_DIR) -source 1.8 -target 1.8 \
3746
-nowarn $^
38-
@jar cf $(JAR) -C $(CLASSES_DIR) .
47+
@jar cf $(JAR) -C $(CLASSES_DIR) . --release 9 -C $(JAVA9_CLASSES_DIR) .
3948

4049
$(DIST_JAR): $(JAR) | $(DIST_JAR_DIR)
4150
@install -m 0644 $< $@

annotations/classes.mk

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13+
ANNOTATION_MODULE_INFO = \
14+
module-info.java
15+
1316
ANNOTATION_SOURCE_JAVA = \
1417
com/google/j2objc/annotations/AutoreleasePool.java \
1518
com/google/j2objc/annotations/GenerateObjectiveCGenerics.java \

annotations/pom.xml

+43
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,49 @@
5858

5959
<build>
6060
<plugins>
61+
<plugin>
62+
<groupId>org.apache.maven.plugins</groupId>
63+
<artifactId>maven-compiler-plugin</artifactId>
64+
<version>3.12.1</version>
65+
<executions>
66+
<execution>
67+
<id>default-compile</id>
68+
<configuration>
69+
<source>1.8</source>
70+
<target>1.8</target>
71+
<excludes>
72+
<exclude>module-info.java</exclude>
73+
</excludes>
74+
</configuration>
75+
</execution>
76+
<execution>
77+
<id>compile-java9</id>
78+
<phase>compile</phase>
79+
<goals>
80+
<goal>compile</goal>
81+
</goals>
82+
<configuration>
83+
<release>9</release>
84+
<multiReleaseOutput>true</multiReleaseOutput>
85+
</configuration>
86+
</execution>
87+
</executions>
88+
</plugin>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-jar-plugin</artifactId>
92+
<version>3.3.0</version>
93+
<configuration>
94+
<archive>
95+
<manifestEntries>
96+
<Multi-Release>true</Multi-Release>
97+
</manifestEntries>
98+
</archive>
99+
<excludes>
100+
<exclude>META-INF/versions/9/com/**</exclude>
101+
</excludes>
102+
</configuration>
103+
</plugin>
61104
<plugin>
62105
<groupId>org.apache.maven.plugins</groupId>
63106
<artifactId>maven-javadoc-plugin</artifactId>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
open module com.google.j2objc.annotations {
18+
requires java.base;
19+
exports com.google.j2objc.annotations;
20+
}

0 commit comments

Comments
 (0)