Skip to content

Commit

Permalink
Merge pull request #2302 from sgammon:feat/annotations-jpms
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 613986788
  • Loading branch information
Copybara-Service committed Mar 8, 2024
2 parents cafcb24 + d0aafde commit d3c2ca6
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 4 deletions.
2 changes: 1 addition & 1 deletion annotations/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="lib" path="build_result/j2objc_annotations.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build_result/eclipse"/>
<classpathentry kind="output" path="build_result/eclipse"/>
</classpath>
1 change: 1 addition & 0 deletions annotations/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
15 changes: 12 additions & 3 deletions annotations/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,26 @@ DIST_JAR = $(DIST_JAR_DIR)/$(JAR_NAME)

CLASSES_DIR = $(BUILD_DIR)/classes
JAVA_SOURCE_DIR = src/main/java
JAVA9_CLASSES_DIR = $(BUILD_DIR)/classes-java9
JPMS_CLASS = $(JAVA9_CLASSES_DIR)/module-info.class

SOURCE_JAVA_FULL = $(ANNOTATION_SOURCE_JAVA:%=$(JAVA_SOURCE_DIR)/%)
SOURCE_JAVA9_MODULE = $(ANNOTATION_MODULE_INFO:%=$(JAVA_SOURCE_DIR)/%)

$(BUILD_DIR) $(CLASSES_DIR) $(DIST_JAR_DIR):
$(BUILD_DIR) $(CLASSES_DIR) $(JAVA9_CLASSES_DIR) $(DIST_JAR_DIR):
@mkdir -p $@

$(JAR): $(SOURCE_JAVA_FULL) | $(BUILD_DIR) $(CLASSES_DIR)
$(JPMS_CLASS):
@echo Building j2objc annotations JPMS module
@$(JAVAC) -sourcepath $(JAVA_SOURCE_DIR) -encoding UTF-8 --release 9 -d $(JAVA9_CLASSES_DIR) \
-nowarn $(SOURCE_JAVA9_MODULE)
@rm -fr $(JAVA9_CLASSES_DIR)/com

$(JAR): $(SOURCE_JAVA_FULL) | $(BUILD_DIR) $(CLASSES_DIR) $(JAVA9_CLASSES_DIR) $(JPMS_CLASS)
@echo Building j2objc annotations
@$(JAVAC) -encoding UTF-8 -d $(CLASSES_DIR) -source 1.8 -target 1.8 \
-nowarn $^
@jar cf $(JAR) -C $(CLASSES_DIR) .
@jar cf $(JAR) -C $(CLASSES_DIR) . --release 9 -C $(JAVA9_CLASSES_DIR) .

$(DIST_JAR): $(JAR) | $(DIST_JAR_DIR)
@install -m 0644 $< $@
Expand Down
3 changes: 3 additions & 0 deletions annotations/classes.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ANNOTATION_MODULE_INFO = \
module-info.java

ANNOTATION_SOURCE_JAVA = \
com/google/j2objc/annotations/AutoreleasePool.java \
com/google/j2objc/annotations/GenerateObjectiveCGenerics.java \
Expand Down
43 changes: 43 additions & 0 deletions annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,49 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<source>1.8</source>
<target>1.8</target>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>compile-java9</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>9</release>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<excludes>
<exclude>META-INF/versions/9/com/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down
20 changes: 20 additions & 0 deletions annotations/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2012 Google Inc. All Rights Reserved.
*
* 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
*
* http://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.
*/

open module com.google.j2objc.annotations {
requires java.base;
exports com.google.j2objc.annotations;
}

0 comments on commit d3c2ca6

Please sign in to comment.