Skip to content

Commit

Permalink
feat: jpms support
Browse files Browse the repository at this point in the history
- feat: add `module-info.java` descriptor
- fix!: update annotation package path to `o.a.v.annotations.*`
- chore: upgrade all maven plugins to latest
- chore: centralize maven plugin versions
- chore: centralize dependency versions
- chore: refactor build to fix dependency on old plugin version

This changeset introduces support for the Java Platform Module
System, or JPMS, within the ANTLR v4 runtime and annotations
packages.

The runtime package can now be depended on in downstream modules
with a `requires antlr.runtime` directive.

To facilitate this functionality, a breaking change had to be made
with regard to packages used for annotations. The following package
changes were made:

- `o.a.v.misc.NotNull` → `org.antlr.v4.annotations.NotNull`
- `o.a.v.misc.Nullable` → `org.antlr.v4.annotations.Nullable`
- `o.a.v.r.NullUsageProcessor` → `...processors.NullUsageProcessor`

Code generators, service definitions, and other references to these
classes were updated accordingly. This change was made to fix split
package issues between the ANTLR runtime and annotations modules,
which is banned under JPMS.

Additionally, the codebase now uses a bootstrap JAR to facilitate
code-gen in `antlr4-runtime`; this bootstrap JAR is located in the
`lib/` folder and automatically installed for the developer if they
use either `./mvnw` (also added) or `./bootstrap.sh`.

This bootstrap JAR will allow iteration on the code generator
without needing to release a new plugin version.

Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Mar 1, 2024
1 parent 1de7b24 commit 6f28560
Show file tree
Hide file tree
Showing 162 changed files with 1,373 additions and 365 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ nbactions*.xml
# Playground
#/tool/playground/

.vscode/
.vscode/
.boot
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
distributionUrl=https://maven.pkg.st/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://maven.pkg.st/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
36 changes: 7 additions & 29 deletions antlr4-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
<parent>
<groupId>com.tunnelvisionlabs</groupId>
<artifactId>antlr4-master</artifactId>
<version>4.9.1-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
</parent>

<artifactId>antlr4-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>

<name>ANTLR 4 Maven plugin</name>
<description>Maven plugin for ANTLR 4 grammars</description>
<url>http://www.antlr.org</url>
<url>https://www.antlr.org</url>

<prerequisites>
<maven>3.0</maven>
</prerequisites>

<!-- Ancilliary information for completeness
<!-- Ancillary information for completeness
-->
<inceptionYear>2009</inceptionYear>

Expand All @@ -48,20 +48,17 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.5</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>2.2</version>
</dependency>

<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>

<!--
Expand All @@ -79,73 +76,60 @@
Testing requirements...
-->
<dependency>

<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>

</dependency>

<dependency>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-plugin-testing</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.0.5</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.15</version>
<scope>provided</scope>
<scope>test</scope>
</dependency>

<!-- Must be last or tests will fail -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>

</dependencies>

<profiles>
<profile>
<id>maven-plugin-no-tests</id>
<activation>
<jdk>1.6</jdk>
</activation>
<properties>
<skipTests>true</skipTests>
</properties>
</profile>

<profile>
<id>maven-plugin-tests</id>
<activation>
<jdk>!1.6</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<version>1.11.12</version>
<extensions>true</extensions>
<executions>
<execution>
<id>testProperties</id>
Expand Down Expand Up @@ -184,7 +168,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
Expand All @@ -208,13 +191,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
Expand All @@ -229,13 +210,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<quiet>true</quiet>
</configuration>
Expand All @@ -244,7 +223,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.antlr.mojo.antlr4;

import org.antlr.v4.Tool;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.annotations.NotNull;
import org.antlr.v4.tool.ANTLRMessage;
import org.antlr.v4.tool.ANTLRToolListener;
import org.apache.maven.plugin.logging.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.antlr.v4.Tool;
import org.antlr.v4.codegen.CodeGenerator;
import org.antlr.v4.runtime.misc.MultiMap;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.annotations.NotNull;
import org.antlr.v4.runtime.misc.Utils;
import org.antlr.v4.tool.Grammar;
import org.apache.maven.plugin.AbstractMojo;
Expand Down
25 changes: 6 additions & 19 deletions antlr4-testgen-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
<parent>
<groupId>com.tunnelvisionlabs</groupId>
<artifactId>antlr4-master</artifactId>
<version>4.9.1-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
</parent>

<artifactId>antlr4-testgen-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>

<name>ANTLR 4 Test Generator Maven plugin</name>
<description>Maven plugin for generating ANTLR 4 runtime tests</description>
<url>http://www.antlr.org</url>
<url>https://www.antlr.org</url>

<prerequisites>
<maven>3.0</maven>
</prerequisites>

<!-- Ancilliary information for completeness
<!-- Ancillary information for completeness
-->
<inceptionYear>2009</inceptionYear>

<!-- ============================================================================= -->

<!--
What are we depedent on for the Mojos to execute? We need the
What are we dependent on for the Mojos to execute? We need the
plugin API itself and of course we need the ANTLR Tool and runtime
and any of their dependencies, which we inherit. The Tool itself provides
us with all the dependencies, so we need only name it here.
Expand All @@ -44,32 +44,28 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.5</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>2.2</version>
</dependency>

<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>

<dependency>
<groupId>org.antlr</groupId>
<artifactId>ST4</artifactId>
<version>4.0.8</version>
</dependency>

<dependency>
Expand All @@ -84,21 +80,18 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>

Expand All @@ -118,7 +111,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
Expand All @@ -142,13 +134,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
Expand All @@ -163,13 +153,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<quiet>true</quiet>
</configuration>
Expand All @@ -178,7 +166,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
Expand Down
19 changes: 19 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

VERSION="4.10.0-BOOTSTRAP"

echo "Installing boostrap runtime JAR...";
mvn install:install-file \
-Dfile="./lib/antlr4-bootstrap.jar" \
-DgroupId="com.tunnelvisionlabs" \
-DartifactId="antlr4-runtime" \
-Dversion="$VERSION" \
-Dpackaging=jar

echo "Installing boostrap Maven plugin JAR...";
mvn install:install-file \
-Dfile="./lib/antlr4-bootstrap-maven-plugin.jar" \
-DgroupId="com.tunnelvisionlabs" \
-DartifactId="antlr4-maven-plugin" \
-Dversion="$VERSION" \
-Dpackaging=jar
Binary file added lib/antlr4-bootstrap-maven-plugin.jar
Binary file not shown.
Binary file added lib/antlr4-bootstrap.jar
Binary file not shown.
Loading

0 comments on commit 6f28560

Please sign in to comment.