Skip to content

Commit 6080e77

Browse files
committed
more
1 parent c55a361 commit 6080e77

File tree

3 files changed

+76
-19
lines changed

3 files changed

+76
-19
lines changed

independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/configuration/WorkspaceQuarkusInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public static void main(String[] args) throws Exception {
2929
//MavenProjectConfigurationLoader.load(Path.of("/home/aloubyansky/git/insights-runtimes-inventory"));
3030
//MavenProjectConfigurationLoader.load(Path.of("/home/aloubyansky/git/keycloak"));
3131
//loadAndLog(Path.of("/home/aloubyansky/git/camel-quarkus"));
32-
//loadAndLog(Path.of("/home/aloubyansky/git/camel-quarkus/integration-tests/sql"));
33-
loadAndLog(Path.of("/home/aloubyansky/git/quarkus-super-heroes/"));
32+
loadAndLog(Path.of("/home/aloubyansky/git/camel-quarkus/integration-tests/sql"));
33+
//loadAndLog(Path.of("/home/aloubyansky/git/quarkus-super-heroes/"));
3434
//loadAndLog(Path.of("/home/aloubyansky/playground/quarkus-update-projects/parent-direct-extension-dep/app"));
3535
//generateUpdateRecipe(Path.of("/home/aloubyansky/playground/code-with-quarkus"));
3636
//load(Path.of("/home/aloubyansky/git/quarkus-todo-app/quarkus-todo-reactive"));

independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/configuration/maven/MavenConfiguredApplicationResolver.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import io.quarkus.bootstrap.resolver.maven.EffectiveModelResolver;
2525
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
2626
import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject;
27+
import io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace;
2728
import io.quarkus.bootstrap.util.IoUtils;
2829
import io.quarkus.bootstrap.workspace.WorkspaceModuleId;
2930
import io.quarkus.devtools.messagewriter.MessageWriter;
@@ -68,7 +69,11 @@ private MavenConfiguredApplicationResolver(BootstrapMavenContext mavenContext, M
6869
}
6970

7071
private ConfiguredProject loadInternal(Path projectDir) {
71-
final Collection<LocalProject> modules = mavenContext.getWorkspace().getProjects().values();
72+
final LocalWorkspace workspace = mavenContext.getWorkspace();
73+
if (workspace == null) {
74+
throw new RuntimeException("Failed to load workspace from " + projectDir);
75+
}
76+
final Collection<LocalProject> modules = workspace.getProjects().values();
7277
final List<Path> createdDirs = ensureResolvable(modules);
7378
try {
7479
int i = 1;

independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/configuration/maven/ProjectModuleContainer.java

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.Properties;
99
import java.util.concurrent.ConcurrentHashMap;
1010

11+
import org.apache.maven.model.BuildBase;
1112
import org.apache.maven.model.Dependency;
1213
import org.apache.maven.model.Model;
1314
import org.apache.maven.model.Plugin;
@@ -283,17 +284,58 @@ private ConfiguredBom locateBomImport(ArtifactCoords platformBom, boolean inPare
283284
throw new RuntimeException("Failed to locate the source of " + platformBom.toCompactCoords() + " import");
284285
}
285286

287+
private void getManagedPluginVersion(ArtifactKey pluginKey) {
288+
var managedPlugins = getRawManagedPlugins();
289+
290+
}
291+
292+
private List<Plugin> getRawManagedPlugins() {
293+
List<Plugin> managedPlugins = getRawManagedPlugins(module.getRawModel().getBuild());
294+
final List<Profile> profiles = getActivePomProfiles();
295+
if (profiles.isEmpty()) {
296+
return managedPlugins;
297+
}
298+
List<Plugin> combined = null;
299+
for (Profile p : profiles) {
300+
var profileManagedPlugins = getRawManagedPlugins(p.getBuild());
301+
if (!profileManagedPlugins.isEmpty()) {
302+
if (combined == null) {
303+
combined = new ArrayList<>();
304+
combined.addAll(managedPlugins);
305+
}
306+
combined.addAll(profileManagedPlugins);
307+
}
308+
}
309+
return combined == null ? managedPlugins : combined;
310+
}
311+
312+
private static List<Plugin> getRawManagedPlugins(BuildBase build) {
313+
if (build == null) {
314+
return List.of();
315+
}
316+
var pm = build.getPluginManagement();
317+
return pm == null ? List.of() : pm.getPlugins();
318+
}
319+
286320
private List<Dependency> getRawDirectDeps() {
287321
if (rawDirectDeps == null) {
288322
final List<Profile> profiles = getActivePomProfiles();
289323
if (profiles.isEmpty()) {
290324
rawDirectDeps = module.getRawModel().getDependencies();
291325
} else {
292-
rawDirectDeps = new ArrayList<>();
293-
rawDirectDeps.addAll(module.getRawModel().getDependencies());
326+
List<Dependency> combined = null;
294327
for (Profile p : profiles) {
295-
rawDirectDeps.addAll(p.getDependencies());
328+
final List<Dependency> profileDeps = p.getDependencies();
329+
if (!profileDeps.isEmpty()) {
330+
if (combined == null) {
331+
combined = new ArrayList<>();
332+
combined.addAll(module.getRawModel().getDependencies());
333+
}
334+
combined.addAll(profileDeps);
335+
}
336+
296337
}
338+
rawDirectDeps = combined == null ? module.getRawModel().getDependencies() : combined;
297339
}
298340
}
299341
return rawDirectDeps;
@@ -305,32 +347,42 @@ private Properties getRawProperties() {
305347
if (profiles.isEmpty()) {
306348
rawProperties = module.getRawModel().getProperties();
307349
} else {
308-
rawProperties = new Properties();
309-
rawProperties.putAll(module.getRawModel().getProperties());
310-
for (Profile p : profiles) {
311-
rawProperties.putAll(p.getProperties());
350+
Properties combined = null;
351+
for (Profile profile : profiles) {
352+
if (!profile.getProperties().isEmpty()) {
353+
if (combined == null) {
354+
combined = new Properties();
355+
combined.putAll(module.getRawModel().getProperties());
356+
}
357+
combined.putAll(profile.getProperties());
358+
}
312359
}
360+
rawProperties = combined == null ? module.getRawModel().getProperties() : combined;
313361
}
314362
}
315363
return rawProperties;
316364
}
317365

318366
private List<Dependency> getRawManagedDeps() {
319367
if (rawManagedDeps == null) {
368+
final List<Dependency> mainManagedDeps = module.getRawModel().getDependencyManagement() == null ? List.of()
369+
: module.getRawModel().getDependencyManagement().getDependencies();
320370
final List<Profile> profiles = getActivePomProfiles();
321371
if (profiles.isEmpty()) {
322-
rawManagedDeps = module.getRawModel().getDependencyManagement() == null ? List.of()
323-
: module.getRawModel().getDependencyManagement().getDependencies();
372+
rawManagedDeps = mainManagedDeps;
324373
} else {
325-
rawManagedDeps = new ArrayList<>();
326-
if (module.getRawModel().getDependencyManagement() != null) {
327-
rawManagedDeps.addAll(module.getRawModel().getDependencyManagement().getDependencies());
328-
}
329-
for (Profile p : profiles) {
330-
if (p.getDependencyManagement() != null) {
331-
rawManagedDeps.addAll(p.getDependencyManagement().getDependencies());
374+
List<Dependency> combined = null;
375+
for (Profile profile : profiles) {
376+
final List<Dependency> profileManagedDeps = profile.getDependencyManagement() == null ? List.of()
377+
: profile.getDependencyManagement().getDependencies();
378+
if (!profileManagedDeps.isEmpty()) {
379+
if (combined == null) {
380+
combined = new ArrayList<>(mainManagedDeps);
381+
}
382+
combined.addAll(profileManagedDeps);
332383
}
333384
}
385+
rawManagedDeps = combined == null ? mainManagedDeps : combined;
334386
}
335387
}
336388
return rawManagedDeps;

0 commit comments

Comments
 (0)