Skip to content

Commit 5bc95b2

Browse files
committed
[#519] Add moditect-generated module-info.java files and a simple IT.
- uses lots of more profiles - requires Java 8+ for a release - requires Java 9+ for running the integration test - does not deploy integration tests - maven.compiler.release is set instead of source and target for Java9+ - maven.compiler.source/target is now only set on Java7 and Java8 so the javadoc and sources plugin will work correctly. - Does not contain ITs for neither GSON nor org.json. - Ugly workaround for the fact that the old bundle-plugin crashes on Java9+ module-info.java files, had to provide an empty static MANIFEST.MF file and disable the bundle-plugin on ITs. - I found it odd that the extensions do not reference their correct parent pom as parent pom, instead the root is chosen. This is probably a maven anti-pattern and was corrected by khmarbaise for Shiro. - parentLocation = ../pom.xml is redundant for /api and /impl, but did not bother to correct it here - some pom.xml files were missing a final line break as required by unix spec.
1 parent 20b0437 commit 5bc95b2

File tree

12 files changed

+363
-10
lines changed

12 files changed

+363
-10
lines changed

api/pom.xml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,41 @@
5050
</plugins>
5151
</build>
5252

53-
</project>
53+
<profiles>
54+
<profile>
55+
<id>nonJDK7</id>
56+
<activation>
57+
<jdk>[1.8,)</jdk>
58+
</activation>
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<groupId>org.moditect</groupId>
63+
<artifactId>moditect-maven-plugin</artifactId>
64+
<executions>
65+
<execution>
66+
<id>add-module-infos</id>
67+
<phase>package</phase>
68+
<goals>
69+
<goal>add-module-info</goal>
70+
</goals>
71+
<configuration>
72+
<module>
73+
<moduleInfo>
74+
<name>io.jsonwebtoken.jjwt.api</name>
75+
<exports>
76+
io.jsonwebtoken;
77+
io.jsonwebtoken.*;
78+
</exports>
79+
</moduleInfo>
80+
</module>
81+
</configuration>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
</plugins>
86+
</build>
87+
</profile>
88+
</profiles>
89+
90+
</project>

extensions/gson/pom.xml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,37 @@
4444
</dependency>
4545
</dependencies>
4646

47-
</project>
47+
<profiles>
48+
<profile>
49+
<id>nonJDK7</id>
50+
<activation>
51+
<jdk>[1.8,)</jdk>
52+
</activation>
53+
<build>
54+
<plugins>
55+
<plugin>
56+
<groupId>org.moditect</groupId>
57+
<artifactId>moditect-maven-plugin</artifactId>
58+
<executions>
59+
<execution>
60+
<id>add-module-infos</id>
61+
<phase>package</phase>
62+
<goals>
63+
<goal>add-module-info</goal>
64+
</goals>
65+
<configuration>
66+
<module>
67+
<moduleInfo>
68+
<name>io.jsonwebtoken.jjwt.ext.gson</name>
69+
</moduleInfo>
70+
</module>
71+
</configuration>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
</profile>
78+
</profiles>
79+
80+
</project>

extensions/jackson/pom.xml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,37 @@
7777
</plugin>
7878
</plugins>
7979
</build>
80-
</project>
80+
81+
<profiles>
82+
<profile>
83+
<id>nonJDK7</id>
84+
<activation>
85+
<jdk>[1.8,)</jdk>
86+
</activation>
87+
<build>
88+
<plugins>
89+
<plugin>
90+
<groupId>org.moditect</groupId>
91+
<artifactId>moditect-maven-plugin</artifactId>
92+
<executions>
93+
<execution>
94+
<id>add-module-infos</id>
95+
<phase>package</phase>
96+
<goals>
97+
<goal>add-module-info</goal>
98+
</goals>
99+
<configuration>
100+
<module>
101+
<moduleInfo>
102+
<name>io.jsonwebtoken.jjwt.ext.jackson</name>
103+
</moduleInfo>
104+
</module>
105+
</configuration>
106+
</execution>
107+
</executions>
108+
</plugin>
109+
</plugins>
110+
</build>
111+
</profile>
112+
</profiles>
113+
</project>

extensions/orgjson/pom.xml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,37 @@
7777
</plugin>
7878
</plugins>
7979
</build>
80-
</project>
80+
81+
<profiles>
82+
<profile>
83+
<id>nonJDK7</id>
84+
<activation>
85+
<jdk>[1.8,)</jdk>
86+
</activation>
87+
<build>
88+
<plugins>
89+
<plugin>
90+
<groupId>org.moditect</groupId>
91+
<artifactId>moditect-maven-plugin</artifactId>
92+
<executions>
93+
<execution>
94+
<id>add-module-infos</id>
95+
<phase>package</phase>
96+
<goals>
97+
<goal>add-module-info</goal>
98+
</goals>
99+
<configuration>
100+
<module>
101+
<moduleInfo>
102+
<name>io.jsonwebtoken.jjwt.ext.orgjson</name>
103+
</moduleInfo>
104+
</module>
105+
</configuration>
106+
</execution>
107+
</executions>
108+
</plugin>
109+
</plugins>
110+
</build>
111+
</profile>
112+
</profiles>
113+
</project>

impl/pom.xml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,44 @@
6666
</dependency>
6767
</dependencies>
6868

69-
</project>
69+
<profiles>
70+
<profile>
71+
<id>nonJDK7</id>
72+
<activation>
73+
<jdk>[1.8,)</jdk>
74+
</activation>
75+
<build>
76+
<plugins>
77+
<plugin>
78+
<groupId>org.moditect</groupId>
79+
<artifactId>moditect-maven-plugin</artifactId>
80+
<executions>
81+
<execution>
82+
<id>add-module-infos</id>
83+
<phase>package</phase>
84+
<goals>
85+
<goal>add-module-info</goal>
86+
</goals>
87+
<configuration>
88+
<module>
89+
<moduleInfo>
90+
<name>io.jsonwebtoken.jjwt.impl</name>
91+
<requires>
92+
io.jsonwebtoken.jjwt.api;
93+
</requires>
94+
<uses>
95+
io.jsonwebtoken.CompressionCodec;
96+
io.jsonwebtoken.io.Deserializer;
97+
io.jsonwebtoken.io.Serializer;
98+
</uses>
99+
</moduleInfo>
100+
</module>
101+
</configuration>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
</plugins>
106+
</build>
107+
</profile>
108+
</profiles>
109+
</project>

integration-tests/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>io.jsonwebtoken</groupId>
9+
<artifactId>jjwt-root</artifactId>
10+
<version>0.11.3-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>jjwt-integration-tests</artifactId>
14+
<name>JJWT :: Integration-Tests</name>
15+
<packaging>pom</packaging>
16+
17+
<properties>
18+
<maven.deploy.skip>true</maven.deploy.skip>
19+
</properties>
20+
21+
<modules>
22+
<module>unsigned-jackson</module>
23+
</modules>
24+
25+
</project>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>io.jsonwebtoken</groupId>
9+
<artifactId>jjwt-integration-tests</artifactId>
10+
<version>0.11.3-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>jjwt-integration-tests-unsigned-jackson</artifactId>
14+
<name>JJWT :: Integration-Tests :: unsigned-jackson</name>
15+
<description>Create and parse an unsigned JWT using Jackson and JPMS.</description>
16+
<packaging>jar</packaging>
17+
18+
<properties>
19+
<maven.compiler.release>9</maven.compiler.release>
20+
<maven.deploy.skip>true</maven.deploy.skip>
21+
</properties>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>io.jsonwebtoken</groupId>
26+
<artifactId>jjwt-api</artifactId>
27+
</dependency>
28+
<dependency>
29+
<groupId>io.jsonwebtoken</groupId>
30+
<artifactId>jjwt-impl</artifactId>
31+
<version>0.11.3-SNAPSHOT</version>
32+
<scope>runtime</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>io.jsonwebtoken</groupId>
36+
<artifactId>jjwt-jackson</artifactId>
37+
<scope>runtime</scope>
38+
</dependency>
39+
</dependencies>
40+
41+
<build>
42+
<plugins>
43+
<plugin>
44+
<groupId>org.apache.maven.plugins</groupId>
45+
<artifactId>maven-javadoc-plugin</artifactId>
46+
<configuration>
47+
<skip>true</skip>
48+
<detectJavaApiLink>false</detectJavaApiLink>
49+
</configuration>
50+
</plugin>
51+
<!--
52+
this plugin needs to be disabled as long as we are stuck with plugin version 3.3.0, as it cannot
53+
handle Java 9 module-info.class files.
54+
This will also use an empty MANIFEST.MF file, since there is no way in maven to unsetting
55+
an entry (like archive/manifestFile for the jar plugin).
56+
-->
57+
<plugin>
58+
<groupId>org.apache.felix</groupId>
59+
<artifactId>maven-bundle-plugin</artifactId>
60+
<executions>
61+
<execution>
62+
<id>bundle-manifest</id>
63+
<phase>none</phase>
64+
</execution>
65+
</executions>
66+
</plugin>
67+
</plugins>
68+
</build>
69+
70+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.jsonwebtoken.it.unsigned;
2+
3+
import io.jsonwebtoken.*;
4+
5+
import java.time.Instant;
6+
import java.util.Date;
7+
import java.util.List;
8+
9+
public class UnsignedJwtCreator {
10+
11+
public UnsignedJwtCreator() {
12+
// explicit
13+
}
14+
15+
public String create() {
16+
return Jwts.builder()
17+
.claim("roles", List.of("admin"))
18+
.setSubject("jjwt")
19+
.setId("jjwt-0")
20+
.setIssuedAt(Date.from(Instant.now()))
21+
.setNotBefore(Date.from(Instant.now()))
22+
.compact();
23+
}
24+
25+
public Jwt<Header, Claims> read(String jwt) {
26+
final JwtParser jwtParser = Jwts.parserBuilder()
27+
.requireSubject("jjwt")
28+
.build();
29+
30+
return jwtParser.parseClaimsJwt(jwt);
31+
}
32+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module io.jsonwebtoken.jjwt.it.unsigned {
2+
requires io.jsonwebtoken.jjwt.api;
3+
4+
}

integration-tests/unsigned-jackson/src/main/resources/META-INF/MANIFEST.MF

Whitespace-only changes.

0 commit comments

Comments
 (0)