Skip to content

Commit

Permalink
Modular JAR: Add module-info module descriptor and require Java 9+
Browse files Browse the repository at this point in the history
We've waited long enough for the ecosystem and tools such as Android to
catch up. Making it proper modular means people can run jlink on it.
Fixes #125.
  • Loading branch information
robinst committed Mar 1, 2023
1 parent dfd95d0 commit e495b8d
Show file tree
Hide file tree
Showing 49 changed files with 101 additions and 194 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html),
with the exception that 0.x versions can break between minor versions.

## Unreleased
### Changed
- Modular JAR: Require at least Java 9 and add a module descriptor (module-info),
remove no longer necessary `Automatic-Module-Name` header
- New package `org.commonmark.parser.beta` containing classes that are not part of
the stable API but are exported from the module (because they might be useful for
extension parsers).

## [0.21.0] - 2022-11-17
### Added
- GitHub strikethrough: With the previous version we adjusted the
Expand Down Expand Up @@ -379,6 +387,7 @@ API breaking changes (caused by changes in spec):
Initial release of commonmark-java, a port of commonmark.js with extensions
for autolinking URLs, GitHub flavored strikethrough and tables.

[0.22.0]: https://github.com/commonmark/commonmark-java/compare/commonmark-parent-0.21.0...commonmark-parent-0.22.0
[0.21.0]: https://github.com/commonmark/commonmark-java/compare/commonmark-parent-0.20.0...commonmark-parent-0.21.0
[0.20.0]: https://github.com/commonmark/commonmark-java/compare/commonmark-parent-0.19.0...commonmark-parent-0.20.0
[0.19.0]: https://github.com/commonmark/commonmark-java/compare/commonmark-parent-0.18.2...commonmark-parent-0.19.0
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ full library with a nice API and the following features:
* Flexible (manipulate the AST after parsing, customize HTML rendering)
* Extensible (tables, strikethrough, autolinking and more, see below)

The library is supported on Java 8 or later. It should work on Java 7
and Android too, but that is on a best-effort basis, please report
problems. For Android the minimum API level is 19, see the
[commonmark-android-test](commonmark-android-test) directory.
The library is supported on Java 9 or later. It works on Android too, but
that is currently not part of the builds and so only supported on a best-effort
basis, please report any problems. For Android the minimum API level is 19, see
the [commonmark-android-test](commonmark-android-test)
directory.

Coordinates for core library (see all on [Maven Central]):

Expand All @@ -43,7 +44,8 @@ The module names to use in Java 9 are `org.commonmark`,

Note that for 0.x releases of this library, the API is not considered stable
yet and may break between minor releases. After 1.0, [Semantic Versioning] will
be followed.
be followed. A package containing `beta` means it's not subject to stable API
guarantees yet; but for normal usage it should not be necessary to use.

See the [spec.txt](commonmark-test-util/src/main/resources/spec.txt)
file if you're wondering which version of the spec is currently
Expand Down Expand Up @@ -383,7 +385,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) file.
License
-------

Copyright (c) 2015-2019 Atlassian and others.
Copyright (c) Atlassian and others.

BSD (2-clause) licensed, see LICENSE.txt file.

Expand Down
18 changes: 1 addition & 17 deletions commonmark-ext-autolink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<description>commonmark-java extension for turning plain URLs and email addresses into links</description>

<properties>
<autolink.version>0.10.0</autolink.version>
<autolink.version>0.11.0</autolink.version>
</properties>

<dependencies>
Expand All @@ -33,20 +33,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.ext.autolink</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
4 changes: 4 additions & 0 deletions commonmark-ext-autolink/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module org.commonmark.ext.autolink {
requires org.commonmark;
requires org.nibor.autolink;
}
16 changes: 0 additions & 16 deletions commonmark-ext-gfm-strikethrough/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.ext.gfm.strikethrough</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.commonmark.ext.gfm.strikethrough {
requires org.commonmark;
}
16 changes: 0 additions & 16 deletions commonmark-ext-gfm-tables/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.ext.gfm.tables</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
3 changes: 3 additions & 0 deletions commonmark-ext-gfm-tables/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.commonmark.ext.gfm.tables {
requires org.commonmark;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.commonmark.ext.gfm.tables.internal;

import org.commonmark.ext.gfm.tables.*;
import org.commonmark.internal.util.Parsing;
import org.commonmark.node.Block;
import org.commonmark.node.Node;
import org.commonmark.node.SourceSpan;
import org.commonmark.parser.InlineParser;
import org.commonmark.parser.SourceLine;
import org.commonmark.parser.SourceLines;
import org.commonmark.parser.beta.Parsing;
import org.commonmark.parser.block.*;

import java.util.ArrayList;
Expand Down
16 changes: 0 additions & 16 deletions commonmark-ext-heading-anchor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.ext.heading.anchor</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
3 changes: 3 additions & 0 deletions commonmark-ext-heading-anchor/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.commonmark.ext.heading.anchor {
requires org.commonmark;
}
16 changes: 0 additions & 16 deletions commonmark-ext-image-attributes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.ext.image.attributes</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.commonmark.ext.image.attributes {
requires org.commonmark;
}
16 changes: 0 additions & 16 deletions commonmark-ext-ins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.ext.ins</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
3 changes: 3 additions & 0 deletions commonmark-ext-ins/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.commonmark.ext.ins {
requires org.commonmark;
}
16 changes: 0 additions & 16 deletions commonmark-ext-task-list-items/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.ext.task.list.items</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
3 changes: 3 additions & 0 deletions commonmark-ext-task-list-items/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.commonmark.ext.task.list.items {
requires org.commonmark;
}
16 changes: 0 additions & 16 deletions commonmark-ext-yaml-front-matter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.ext.front.matter</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.commonmark.ext.front.matter {
requires org.commonmark;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import org.commonmark.ext.front.matter.YamlFrontMatterBlock;
import org.commonmark.ext.front.matter.YamlFrontMatterNode;
import org.commonmark.internal.DocumentBlockParser;
import org.commonmark.node.Block;
import org.commonmark.node.Document;
import org.commonmark.parser.InlineParser;
import org.commonmark.parser.SourceLine;
import org.commonmark.parser.block.*;
Expand Down Expand Up @@ -119,7 +119,7 @@ public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockPar
CharSequence line = state.getLine().getContent();
BlockParser parentParser = matchedBlockParser.getMatchedBlockParser();
// check whether this line is the first line of whole document or not
if (parentParser instanceof DocumentBlockParser && parentParser.getBlock().getFirstChild() == null &&
if (parentParser.getBlock() instanceof Document && parentParser.getBlock().getFirstChild() == null &&
REGEX_BEGIN.matcher(line).matches()) {
return BlockStart.of(new YamlFrontMatterBlockParser()).atIndex(state.getNextNonSpaceIndex());
}
Expand Down
16 changes: 0 additions & 16 deletions commonmark-test-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark.testutil</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
3 changes: 3 additions & 0 deletions commonmark-test-util/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.commonmark.testutil {
requires junit;
}
16 changes: 0 additions & 16 deletions commonmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.commonmark</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>benchmark</id>
Expand Down
11 changes: 11 additions & 0 deletions commonmark/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module org.commonmark {
exports org.commonmark;
exports org.commonmark.node;
exports org.commonmark.parser;
exports org.commonmark.parser.beta;
exports org.commonmark.parser.block;
exports org.commonmark.parser.delimiter;
exports org.commonmark.renderer;
exports org.commonmark.renderer.html;
exports org.commonmark.renderer.text;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.commonmark.internal;

import org.commonmark.internal.util.Parsing;
import org.commonmark.node.Block;
import org.commonmark.node.BlockQuote;
import org.commonmark.parser.beta.Parsing;
import org.commonmark.parser.block.*;

public class BlockQuoteParser extends AbstractBlockParser {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.commonmark.internal;

import org.commonmark.internal.inline.Position;
import org.commonmark.node.Text;
import org.commonmark.parser.beta.Position;

/**
* Opening bracket for links (<code>[</code>) or images (<code>![</code>).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.commonmark.internal;

import org.commonmark.internal.util.Parsing;
import org.commonmark.node.*;
import org.commonmark.parser.*;
import org.commonmark.parser.beta.Parsing;
import org.commonmark.parser.block.*;
import org.commonmark.parser.delimiter.DelimiterProcessor;

Expand Down

0 comments on commit e495b8d

Please sign in to comment.