Skip to content

Commit d90980b

Browse files
authored
Merge pull request #50576 from gsmet/specific-pom
Fix bootstrap when module is pointing to POM file directly
2 parents 588b2fd + ca8faa2 commit d90980b

File tree

16 files changed

+542
-5
lines changed

16 files changed

+542
-5
lines changed

independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ private static Path locateCurrentProjectPom(Path path) throws BootstrapMavenExce
7777
}
7878

7979
private final Deque<WorkspaceModulePom> moduleQueue = new ConcurrentLinkedDeque<>();
80+
// Map key is the normalized absolute Path to the module directory
8081
private final Map<Path, Model> loadedPoms = new ConcurrentHashMap<>();
8182
private final Map<GAV, Model> loadedModules = new ConcurrentHashMap<>();
8283
private final Consumer<WorkspaceModulePom> modelProcessor;
@@ -194,7 +195,12 @@ private Consumer<WorkspaceModulePom> getModelProcessor(BootstrapMavenContext ctx
194195
currentProject = project;
195196
}
196197
for (var module : project.getEffectiveModel().getModules()) {
197-
addModulePom(project.getDir().resolve(module).resolve(POM_XML));
198+
Path modulePath = project.getDir().resolve(module);
199+
if (Files.isDirectory(modulePath)) {
200+
addModulePom(modulePath.resolve(POM_XML));
201+
} else {
202+
addModulePom(modulePath);
203+
}
198204
}
199205
};
200206
}
@@ -250,9 +256,19 @@ private void loadModule(WorkspaceModulePom rawModule, Collection<WorkspaceModule
250256
}
251257
}
252258

253-
private void queueModule(Path dir) {
254-
if (!loadedPoms.containsKey(dir)) {
255-
moduleQueue.push(new WorkspaceModulePom(dir.resolve(POM_XML)));
259+
private void queueModule(Path module) {
260+
Path normalizedModuleDir = module.normalize().toAbsolutePath();
261+
final Path pom;
262+
if (Files.isDirectory(normalizedModuleDir)) {
263+
pom = normalizedModuleDir.resolve(POM_XML);
264+
} else {
265+
// it is valid in Maven to point directly to the POM file in the <module> so we need to take that case into account
266+
pom = normalizedModuleDir;
267+
normalizedModuleDir = normalizedModuleDir.getParent() != null ? normalizedModuleDir.getParent() : getFsRootDir();
268+
}
269+
270+
if (!loadedPoms.containsKey(normalizedModuleDir)) {
271+
moduleQueue.push(new WorkspaceModulePom(pom));
256272
}
257273
}
258274

independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceModulePom.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Path getParentPom() {
5050
parentPom = parentDir.resolve(WorkspaceLoader.POM_XML);
5151
}
5252
}
53-
return parentPom != null && Files.exists(parentPom) ? parentPom : null;
53+
return parentPom != null && Files.exists(parentPom) ? parentPom.normalize().toAbsolutePath() : null;
5454
}
5555

5656
void process(Consumer<WorkspaceModulePom> consumer) {

integration-tests/maven/src/test/java/io/quarkus/maven/it/BuildIT.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ void testFlattenMavenPlugin()
249249
build();
250250
}
251251

252+
@Test
253+
void testPomReference() throws Exception {
254+
testDir = initProject("projects/multimodule-pom-reference", "projects/project-with-pom-reference");
255+
running = new RunningInvoker(testDir, false);
256+
MavenProcessInvocationResult result = running
257+
.execute(List.of("clean", "package", "-Dquarkus.analytics.disabled=true"), Map.of());
258+
assertThat(result.getProcess().waitFor()).isZero();
259+
}
260+
252261
private void launch() throws IOException {
253262
launch(TestContext.FAST_NO_PREFIX, "", "hello, from foo");
254263
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.acme</groupId>
7+
<artifactId>quarkus-quickstart-multimodule-parent</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<groupId>org.acme</groupId>
11+
<artifactId>quarkus-quickstart-multimodule-dependency</artifactId>
12+
<version>1.0-SNAPSHOT</version>
13+
14+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.acme</groupId>
7+
<artifactId>quarkus-quickstart-multimodule-parent</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
11+
<groupId>org.acme</groupId>
12+
<artifactId>quarkus-quickstart-multimodule-html</artifactId>
13+
<version>1.0-SNAPSHOT</version>
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.junit.jupiter</groupId>
17+
<artifactId>junit-jupiter</artifactId>
18+
<version>5.8.2</version>
19+
</dependency>
20+
</dependencies>
21+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sadfasdfasdfas
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>getting-started - 1.0-SNAPSHOT</title>
6+
<style>
7+
h1, h2, h3, h4, h5, h6 {
8+
margin-bottom: 0.5rem;
9+
font-weight: 400;
10+
line-height: 1.5;
11+
}
12+
13+
h1 {
14+
font-size: 2.5rem;
15+
}
16+
17+
h2 {
18+
font-size: 2rem
19+
}
20+
21+
h3 {
22+
font-size: 1.75rem
23+
}
24+
25+
h4 {
26+
font-size: 1.5rem
27+
}
28+
29+
h5 {
30+
font-size: 1.25rem
31+
}
32+
33+
h6 {
34+
font-size: 1rem
35+
}
36+
37+
.lead {
38+
font-weight: 300;
39+
font-size: 2rem;
40+
}
41+
42+
.banner {
43+
font-size: 2.7rem;
44+
margin: 0;
45+
padding: 2rem 1rem;
46+
background-color: #00A1E2;
47+
color: white;
48+
}
49+
50+
body {
51+
margin: 0;
52+
font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
53+
}
54+
55+
code {
56+
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
57+
font-size: 87.5%;
58+
color: #e83e8c;
59+
word-break: break-word;
60+
}
61+
62+
.left-column {
63+
padding: .75rem;
64+
max-width: 75%;
65+
min-width: 55%;
66+
}
67+
68+
.right-column {
69+
padding: .75rem;
70+
max-width: 25%;
71+
}
72+
73+
.container {
74+
display: flex;
75+
width: 100%;
76+
}
77+
78+
li {
79+
margin: 0.75rem;
80+
}
81+
82+
.right-section {
83+
margin-left: 1rem;
84+
padding-left: 0.5rem;
85+
}
86+
87+
.right-section h3 {
88+
padding-top: 0;
89+
font-weight: 200;
90+
}
91+
92+
.right-section ul {
93+
border-left: 0.3rem solid #00A1E2;
94+
list-style-type: none;
95+
padding-left: 0;
96+
}
97+
98+
</style>
99+
</head>
100+
<body>
101+
102+
<div class="banner lead">
103+
Your new Cloud-Native a is ready!
104+
</div>
105+
106+
<div class="container">
107+
<div class="left-column">
108+
<p class="lead"> Congratulations, you have created a new Quarkus application.</p>
109+
110+
<h2>Why do you see this?</h2>
111+
112+
<p>This page is served by Quarkus. The source is in
113+
<code>src/main/resources/META-INF/resources/index.html</code>.</p>
114+
115+
<h2>What can I do from here?</h2>
116+
117+
<p>If not already done, run the application in <em>dev mode</em> using: <code>mvn quarkus:dev</code>.
118+
</p>
119+
<ul>
120+
<li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li>
121+
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
122+
<li>Configure your application in <code>src/main/resources/META-INF/microprofile-config.properties</code>.
123+
</li>
124+
</ul>
125+
126+
<h2>Do you like Quarkus?</h2>
127+
<p>Go give it a star on <a href="https://github.com/quarkusio/quarkus">GitHub</a>.</p>
128+
129+
<h2>How do I get rid of this page?</h2>
130+
<p>Just delete the <code>src/main/resources/META-INF/resources/index.html</code> file.</p>
131+
</div>
132+
<div class="right-column">
133+
<div class="right-section">
134+
<h3>Application</h3>
135+
<ul>
136+
<li>GroupId: org.acme</li>
137+
<li>ArtifactId: getting-started</li>
138+
<li>Version: 1.0-SNAPSHOT</li>
139+
<li>Quarkus Version: 0.11.0</li>
140+
</ul>
141+
</div>
142+
<div class="right-section">
143+
<h3>Next steps</h3>
144+
<ul>
145+
<li><a href="https://quarkus.io/guides/maven-tooling">Setup your IDE</a></li>
146+
<li><a href="https://quarkus.io/guides/getting-started">Getting started</a></li>
147+
<li><a href="https://quarkus.io">Quarkus Web Site</a></li>
148+
</ul>
149+
</div>
150+
</div>
151+
</div>
152+
153+
154+
</body>
155+
</html>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.acme</groupId>
7+
<artifactId>quarkus-quickstart-multimodule-parent</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<packaging>pom</packaging>
10+
11+
<properties>
12+
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
13+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
14+
<quarkus.platform.version>@project.version@</quarkus.platform.version>
15+
<quarkus-plugin.version>@project.version@</quarkus-plugin.version>
16+
<compiler-plugin.version>${compiler-plugin.version}</compiler-plugin.version>
17+
<surefire-plugin.version>${version.surefire.plugin}</surefire-plugin.version>
18+
<maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
19+
<maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
</properties>
22+
<modules>
23+
<module>dependency/specific-pom.xml</module>
24+
<module>rest</module>
25+
<module>html</module>
26+
<module>runner</module>
27+
</modules>
28+
29+
<build>
30+
<pluginManagement>
31+
<plugins>
32+
<plugin>
33+
<artifactId>maven-compiler-plugin</artifactId>
34+
<version>\${compiler-plugin.version}</version>
35+
<configuration>
36+
<parameters>true</parameters>
37+
</configuration>
38+
</plugin>
39+
<plugin>
40+
<groupId>io.quarkus</groupId>
41+
<artifactId>quarkus-maven-plugin</artifactId>
42+
<version>\${quarkus-plugin.version}</version>
43+
</plugin>
44+
</plugins>
45+
</pluginManagement>
46+
</build>
47+
48+
<dependencyManagement>
49+
<dependencies>
50+
<dependency>
51+
<groupId>\${quarkus.platform.group-id}</groupId>
52+
<artifactId>\${quarkus.platform.artifact-id}</artifactId>
53+
<version>\${quarkus.platform.version}</version>
54+
<type>pom</type>
55+
<scope>import</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.acme</groupId>
59+
<artifactId>quarkus-quickstart-multimodule-html</artifactId>
60+
<version>1.0-SNAPSHOT</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.acme</groupId>
64+
<artifactId>quarkus-quickstart-multimodule-rest</artifactId>
65+
<version>1.0-SNAPSHOT</version>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.acme</groupId>
69+
<artifactId>quarkus-quickstart-multimodule-dependency</artifactId>
70+
<version>1.0-SNAPSHOT</version>
71+
</dependency>
72+
</dependencies>
73+
</dependencyManagement>
74+
75+
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.acme</groupId>
7+
<artifactId>quarkus-quickstart-multimodule-parent</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<groupId>org.acme</groupId>
11+
<artifactId>quarkus-quickstart-multimodule-rest</artifactId>
12+
<version>1.0-SNAPSHOT</version>
13+
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>io.quarkus</groupId>
18+
<artifactId>quarkus-rest</artifactId>
19+
</dependency>
20+
<dependency>
21+
<groupId>io.quarkus</groupId>
22+
<artifactId>quarkus-junit5</artifactId>
23+
<scope>test</scope>
24+
</dependency>
25+
</dependencies>
26+
</project>

0 commit comments

Comments
 (0)