-
Notifications
You must be signed in to change notification settings - Fork 9
[MJMOD-20] set jmod --main-class argument if it is set. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
986732e
[MJMOD-20] set jmod --main-class argument if it is set.
andretadeu a18c2d5
[MJMOD-20] Replace String.isBlank() from Java 11 with String.trim().i…
andretadeu 7383ba0
[MJMOD-20] Add integration test.
andretadeu d667b59
Fix test pom.xml.
andretadeu 2665133
[MJMOD-20] Clean up pom.xml to remove Maven plugins from pluginManage…
andretadeu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| 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. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jmod-plugin-mjmod-20</artifactId> | ||
| <version>99.0</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>myproject.greetings</artifactId> | ||
| <packaging>jmod</packaging> | ||
|
|
||
| <name>myproject.greetings</name> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>myproject.world</artifactId> | ||
| <type>jmod</type> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jar-plugin</artifactId> | ||
| <configuration> | ||
| <archive> | ||
| <manifest> | ||
| <addClasspath>true</addClasspath> | ||
| <mainClass>myproject.greetings.Main</mainClass> | ||
| </manifest> | ||
| </archive> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <phase>package</phase> | ||
| <goals> | ||
| <goal>jar</goal> | ||
| </goals> | ||
| <configuration> | ||
| <classifier>client</classifier> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jmod-plugin</artifactId> | ||
| <configuration> | ||
| <mainClass>myproject.greetings.Main</mainClass> | ||
| <modulePath>target/jmods</modulePath> | ||
| <moduleVersion>${project.version}</moduleVersion> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <id>list</id> | ||
| <goals> | ||
| <goal>list</goal> | ||
| </goals> | ||
| <phase>verify</phase> | ||
| </execution> | ||
| <execution> | ||
| <id>describe</id> | ||
| <goals> | ||
| <goal>describe</goal> | ||
| </goals> | ||
| <phase>verify</phase> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
22 changes: 22 additions & 0 deletions
22
src/it/mjmod-20-set-main-class/greetings/src/main/java/module-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| module myproject.greetings { | ||
| requires myproject.world; | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/it/mjmod-20-set-main-class/greetings/src/main/java/myproject/greetings/Main.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| package myproject.greetings; | ||
|
|
||
| import myproject.world.World; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
| System.out.format("Greetings %s!%n", World.name()); | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
| invoker.java.version = 9+ | ||
| invoker.goals = package | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| 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. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jmod-plugin-mjmod-20</artifactId> | ||
| <version>99.0</version> | ||
| <packaging>pom</packaging> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
|
|
||
| <dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>myproject.world</artifactId> | ||
| <version>${project.version}</version> | ||
| <type>jmod</type> | ||
| </dependency> | ||
| </dependencies> | ||
| </dependencyManagement> | ||
|
|
||
| <build> | ||
| <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.8.0</version> | ||
| <configuration> | ||
| <release>9</release> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </pluginManagement> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jmod-plugin</artifactId> | ||
| <version>@project.version@</version> | ||
| <extensions>true</extensions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| <modules> | ||
| <module>world</module> | ||
| <module>greetings</module> | ||
| </modules> | ||
|
|
||
| </project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| import java.util.jar.JarEntry | ||
| import java.util.jar.JarFile | ||
|
|
||
| def validateArtifact( String module, List<String> artifactNames ) | ||
| { | ||
| println( "Checking if ${basedir}/${module}/target exists." ) | ||
| File target = new File( basedir, "/${module}/target" ) | ||
| assert target.isDirectory() | ||
|
|
||
| File artifact = new File( target, "/jmods/myproject.${module}.jmod" ) | ||
| assert artifact.isFile() | ||
|
|
||
| Set contents = new HashSet() | ||
|
|
||
| JarFile jar = new JarFile( artifact ) | ||
| Enumeration jarEntries = jar.entries() | ||
| while ( jarEntries.hasMoreElements() ) | ||
| { | ||
| JarEntry entry = (JarEntry) jarEntries.nextElement() | ||
| println( "Current entry: ${entry}" ) | ||
| if ( !entry.isDirectory() ) | ||
| { | ||
| // Only compare files | ||
| contents.add( entry.getName() ) | ||
| } | ||
| } | ||
|
|
||
| assert artifactNames.size() == contents.size() | ||
|
|
||
| artifactNames.each{ artifactName -> | ||
| assert contents.contains( artifactName ) | ||
| } | ||
| } | ||
|
|
||
| validateArtifact( "world", [ "classes/module-info.class", "classes/myproject/world/World.class" ] ) | ||
| validateArtifact( "greetings", [ "classes/module-info.class", "classes/myproject/greetings/Main.class" ] ) | ||
|
|
||
| def sout = new StringBuilder(), serr = new StringBuilder() | ||
| def proc = "jmod describe ${basedir}/greetings/target/jmods/myproject.greetings.jmod".execute() | ||
| proc.consumeProcessOutput( sout, serr ) | ||
| proc.waitForOrKill( 1000 ) | ||
| if ( ! sout.toString().trim().isEmpty() && serr.toString().trim().isEmpty() ) | ||
| { | ||
| Set<String> expectedLines = new HashSet( | ||
| Arrays.asList( | ||
| "myproject.greetings@99.0", | ||
| "requires java.base mandated", | ||
| "requires myproject.world", | ||
| "contains myproject.greetings", | ||
| "main-class myproject.greetings.Main" ) ) | ||
| String[] lines = sout.toString().split("\n") | ||
| for ( String line : lines ) | ||
| { | ||
| if ( ! line.trim().isEmpty() && !expectedLines.contains(line) ) | ||
| { | ||
| System.err.println( "This line was not returned from jmod: ${line}" ) | ||
| return false | ||
| } | ||
| else | ||
| { | ||
| expectedLines.remove(line) | ||
| } | ||
| } | ||
| if (!expectedLines.isEmpty()) { | ||
| System.err.println( "This module does not the following items:" ) | ||
| for ( String line : expectedLines ) | ||
| { | ||
| System.err.println( line ) | ||
| } | ||
| return false | ||
| } | ||
| } | ||
| else | ||
| { | ||
| System.err.println( "Some error happened while trying to run 'jmod describe " | ||
| + "${target}/jmods/myproject.greetings.jmod'" ) | ||
| System.err.println( serr ) | ||
| return false | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.