-
Notifications
You must be signed in to change notification settings - Fork 52
feat: multimodule maven support #330
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
Open
iloveitaly
wants to merge
6
commits into
railwayapp:main
Choose a base branch
from
iloveitaly:java-maven-multimodule-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
46ad509
feat: add Java multimodule example
derkoe d5e93ba
fix: use HasFile for an exact file match
iloveitaly 64113d2
fix: detect multi-module maven projects and include the app source
iloveitaly f4510ca
test: snapshot update
iloveitaly 4813026
docs: multi-module java docs
iloveitaly 65ce946
docs: fix ai slop
iloveitaly 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
125 changes: 125 additions & 0 deletions
125
core/__snapshots__/TestGenerateBuildPlanForExamples_java-maven-multimodule_1.snap.json
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,125 @@ | ||
| { | ||
| "caches": { | ||
| "maven": { | ||
| "directory": ".m2/repository", | ||
| "type": "shared" | ||
| } | ||
| }, | ||
| "deploy": { | ||
| "base": { | ||
| "image": "ghcr.io/railwayapp/railpack-runtime:latest" | ||
| }, | ||
| "inputs": [ | ||
| { | ||
| "include": [ | ||
| "/mise/shims", | ||
| "/mise/installs", | ||
| "/usr/local/bin/mise", | ||
| "/etc/mise/config.toml", | ||
| "/root/.local/state/mise" | ||
| ], | ||
| "step": "packages:mise:runtime" | ||
| }, | ||
| { | ||
| "include": [ | ||
| "." | ||
| ], | ||
| "step": "build" | ||
| } | ||
| ], | ||
| "startCommand": "java $JAVA_OPTS -jar $(find */target -name '*-jar-with-dependencies.jar' -o -name '*-spring-boot*.jar' | head -1)" | ||
| }, | ||
| "steps": [ | ||
| { | ||
| "assets": { | ||
| "mise.toml": "[mise.toml]" | ||
| }, | ||
| "commands": [ | ||
| { | ||
| "path": "/mise/shims" | ||
| }, | ||
| { | ||
| "customName": "create mise config", | ||
| "name": "mise.toml", | ||
| "path": "/etc/mise/config.toml" | ||
| }, | ||
| { | ||
| "cmd": "sh -c 'mise trust -a \u0026\u0026 mise install'", | ||
| "customName": "install mise packages: java, maven" | ||
| } | ||
| ], | ||
| "inputs": [ | ||
| { | ||
| "image": "ghcr.io/railwayapp/railpack-builder:latest" | ||
| } | ||
| ], | ||
| "name": "packages:mise", | ||
| "variables": { | ||
| "MISE_CACHE_DIR": "/mise/cache", | ||
| "MISE_CONFIG_DIR": "/mise", | ||
| "MISE_DATA_DIR": "/mise", | ||
| "MISE_INSTALLS_DIR": "/mise/installs", | ||
| "MISE_NODE_VERIFY": "false", | ||
| "MISE_SHIMS_DIR": "/mise/shims" | ||
| } | ||
| }, | ||
| { | ||
| "caches": [ | ||
| "maven" | ||
| ], | ||
| "commands": [ | ||
| { | ||
| "cmd": "mvn -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction" | ||
| } | ||
| ], | ||
| "inputs": [ | ||
| { | ||
| "step": "packages:mise" | ||
| }, | ||
| { | ||
| "include": [ | ||
| "." | ||
| ], | ||
| "local": true | ||
| } | ||
| ], | ||
| "name": "build", | ||
| "secrets": [ | ||
| "*" | ||
| ] | ||
| }, | ||
| { | ||
| "assets": { | ||
| "mise.toml": "[mise.toml]" | ||
| }, | ||
| "commands": [ | ||
| { | ||
| "path": "/mise/shims" | ||
| }, | ||
| { | ||
| "customName": "create mise config", | ||
| "name": "mise.toml", | ||
| "path": "/etc/mise/config.toml" | ||
| }, | ||
| { | ||
| "cmd": "sh -c 'mise trust -a \u0026\u0026 mise install'", | ||
| "customName": "install mise packages: java" | ||
| } | ||
| ], | ||
| "inputs": [ | ||
| { | ||
| "image": "ghcr.io/railwayapp/railpack-builder:latest" | ||
| } | ||
| ], | ||
| "name": "packages:mise:runtime", | ||
| "variables": { | ||
| "MISE_CACHE_DIR": "/mise/cache", | ||
| "MISE_CONFIG_DIR": "/mise", | ||
| "MISE_DATA_DIR": "/mise", | ||
| "MISE_INSTALLS_DIR": "/mise/installs", | ||
| "MISE_NODE_VERIFY": "false", | ||
| "MISE_SHIMS_DIR": "/mise/shims" | ||
| } | ||
| } | ||
| ] | ||
| } |
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
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
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
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,2 @@ | ||
| !test/ | ||
| target/ |
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,47 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <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> | ||
| <parent> | ||
| <groupId>com.railpack</groupId> | ||
| <artifactId>java-maven-multimodule</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| </parent> | ||
| <artifactId>java-maven-app</artifactId> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>java-maven-lib</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| </dependencies> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-assembly-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <phase>package</phase> | ||
| <goals> | ||
| <goal>single</goal> | ||
| </goals> | ||
| <configuration> | ||
| <archive> | ||
| <manifest> | ||
| <mainClass> | ||
| com.railpack.app.App | ||
| </mainClass> | ||
| </manifest> | ||
| </archive> | ||
| <descriptorRefs> | ||
| <descriptorRef>jar-with-dependencies</descriptorRef> | ||
| </descriptorRefs> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
13 changes: 13 additions & 0 deletions
13
examples/java-maven-multimodule/app/src/main/java/com/railpack/app/App.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,13 @@ | ||
| package com.railpack.app; | ||
|
|
||
| import com.railpack.lib.Util; | ||
|
|
||
| /** | ||
| * Hello world! | ||
| */ | ||
| public class App { | ||
|
|
||
| public static void main(String[] args) { | ||
| System.out.println(Util.getMessage()); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
examples/java-maven-multimodule/app/src/test/java/com/railpack/app/AppTest.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,19 @@ | ||
| package com.railpack.app; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Unit test for simple App. | ||
| */ | ||
| public class AppTest { | ||
|
|
||
| /** | ||
| * Rigorous Test :-) | ||
| */ | ||
| @Test | ||
| public void shouldAnswerWithTrue() { | ||
| assertTrue(true); | ||
| } | ||
| } |
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,11 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <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> | ||
| <parent> | ||
| <groupId>com.railpack</groupId> | ||
| <artifactId>java-maven-multimodule</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| </parent> | ||
| <artifactId>java-maven-lib</artifactId> | ||
| </project> |
8 changes: 8 additions & 0 deletions
8
examples/java-maven-multimodule/lib/src/main/java/lib/Util.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,8 @@ | ||
| package com.railpack.lib; | ||
|
|
||
| public class Util { | ||
|
|
||
| public static String getMessage() { | ||
| return "Hello Railpack!"; | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@derkoe I don't have a lot of experience with Java. I'm curious what you think of this approach and if this makes sense for your particular use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@derkoe friendly reminder here! I'm planning on merging this in this week and getting it into next week's railpack release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iloveitaly I've tried it and I think you will have to redo the whole pack implementation for Java.
I've tried it on https://github.com/porscheinformatik/angular-spring-heroes/ and when you look in the container image I can see the following ending in there:
Here is a screenshot from dive:

The built app ends up in
/app/heroes-webapp/target/heroes-webapp-1.0.0.BUILD-SNAPSHOT.jarbut this is not found by the launcher: