Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Jan 30, 2024
1 parent 8f66719 commit dcd3a0b
Show file tree
Hide file tree
Showing 16 changed files with 1,270 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.HashSet;
import java.util.Set;

import org.eclipse.aether.util.artifact.JavaScopes;

import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
Expand Down Expand Up @@ -70,22 +72,22 @@ protected TsArtifact composeApplication() {
protected void assertAppModel(ApplicationModel model) throws Exception {
final Set<Dependency> expected = new HashSet<>();
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-d-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-d-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-e-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-e-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-f-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-f-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
assertEquals(expected, getDeploymentOnlyDeps(model));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

import org.eclipse.aether.util.artifact.JavaScopes;

import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.resolver.TsArtifact;
Expand Down Expand Up @@ -114,54 +115,53 @@ protected TsArtifact composeApplication() {

@Override
protected void assertAppModel(ApplicationModel appModel) throws Exception {
final Set<Dependency> deploymentDeps = appModel.getDependencies().stream()
.filter(d -> d.isDeploymentCp() && !d.isRuntimeCp()).map(d -> new ArtifactDependency(d))
.collect(Collectors.toSet());
var deploymentDeps = getDeploymentOnlyDeps(appModel);
;
final Set<Dependency> expected = new HashSet<>();
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-f-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-f-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-g-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-g-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-h-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-h-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-k-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-k-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-l-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-l-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-j-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-j-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-m-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-m-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-n-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-n-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-i-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-i-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-o-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-o-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-p-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-p-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-r-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-r-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-s-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-s-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-t-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-t-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-u-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-u-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
assertEquals(expected, new HashSet<>(deploymentDeps));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

import org.eclipse.aether.util.artifact.JavaScopes;

import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
import io.quarkus.deployment.runnerjar.BootstrapFromOriginalJarTestBase;
import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.maven.dependency.ArtifactDependency;
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.maven.dependency.DependencyFlags;
import io.quarkus.maven.dependency.GACTV;

public class ConditionalDependencyWithSingleConditionTest extends BootstrapFromOriginalJarTestBase {

Expand Down Expand Up @@ -42,19 +41,19 @@ protected TsArtifact composeApplication() {

@Override
protected void assertAppModel(ApplicationModel appModel) throws Exception {
final Set<Dependency> deploymentDeps = appModel.getDependencies().stream()
.filter(d -> d.isDeploymentCp() && !d.isRuntimeCp()).map(d -> new ArtifactDependency(d))
.collect(Collectors.toSet());
final Set<Dependency> expected = new HashSet<>();
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION), "compile",
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION), "compile",
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
DependencyFlags.DEPLOYMENT_CP));
assertEquals(expected, deploymentDeps);
var expected = Set.of(
new ArtifactDependency(
ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION),
JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP),
new ArtifactDependency(
ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION),
JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP),
new ArtifactDependency(
ArtifactCoords.jar(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION),
JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
assertEquals(expected, getDeploymentOnlyDeps(appModel));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.HashSet;
import java.util.Set;

import org.eclipse.aether.util.artifact.JavaScopes;

import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
Expand Down Expand Up @@ -46,16 +48,16 @@ protected TsArtifact composeApplication() {
protected void assertAppModel(ApplicationModel model) throws Exception {
final Set<Dependency> expected = new HashSet<>();
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION), "runtime",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-d-deployment", TsArtifact.DEFAULT_VERSION), "compile",
new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-d-deployment", TsArtifact.DEFAULT_VERSION), JavaScopes.COMPILE,
DependencyFlags.DEPLOYMENT_CP));
assertEquals(expected, getDeploymentOnlyDeps(model));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,27 @@ protected QuarkusBootstrap.Builder initBootstrapBuilder() throws Exception {
.setAppModelResolver(resolver)
.setTest(isBootstrapForTestMode());

if (createWorkspace()) {
if (createWorkspace() || !wsModules.isEmpty()) {
System.setProperty("basedir", ws.toAbsolutePath().toString());
final Model appPom = appJar.getPomModel();

final List<Dependency> bomModules = (appPom.getDependencyManagement() == null ? List.<Dependency> of()
: appPom.getDependencyManagement().getDependencies()).stream()
.filter(d -> "import".equals(d.getScope())
&& d.getGroupId().equals(appPom.getGroupId()))
.collect(Collectors.toList());

final List<Dependency> depModules = appPom.getDependencies().stream()
.filter(d -> d.getGroupId().equals(appPom.getGroupId()) &&
(d.getType().isEmpty() || ArtifactCoords.TYPE_JAR.equals(d.getType())))
.collect(Collectors.toList());
List<Dependency> bomModules = List.of();
List<Dependency> depModules = List.of();
if (createWorkspace()) {
bomModules = (appPom.getDependencyManagement() == null ? List.<Dependency> of()
: appPom.getDependencyManagement().getDependencies()).stream()
.filter(d -> "import".equals(d.getScope())
&& d.getGroupId().equals(appPom.getGroupId()))
.collect(Collectors.toList());
depModules = appPom.getDependencies().stream()
.filter(d -> d.getGroupId().equals(appPom.getGroupId()) &&
(d.getType().isEmpty() || ArtifactCoords.TYPE_JAR.equals(d.getType())))
.collect(Collectors.toList());
}

final Path appModule;
final Path appPomXml;
if (depModules.isEmpty() && bomModules.isEmpty() || appPom.getParent() != null) {
if (depModules.isEmpty() && bomModules.isEmpty() && wsModules.isEmpty() || appPom.getParent() != null) {
appModule = ws;
appPomXml = ws.resolve("pom.xml");
ModelUtils.persistModel(appPomXml, appPom);
Expand Down Expand Up @@ -130,31 +133,32 @@ protected QuarkusBootstrap.Builder initBootstrapBuilder() throws Exception {
ModelUtils.persistModel(appPomXml, appPom);

// dependency modules
final Map<ArtifactKey, String> managedVersions = new HashMap<>();
collectManagedDeps(appPom, managedVersions);
for (Dependency moduleDep : depModules) {
parentPom.getModules().add(moduleDep.getArtifactId());
final String moduleVersion = moduleDep.getVersion() == null
? managedVersions.get(ArtifactKey.of(moduleDep.getGroupId(), moduleDep.getArtifactId(),
moduleDep.getClassifier(), moduleDep.getType()))
: moduleDep.getVersion();
Model modulePom = ModelUtils.readModel(resolver
.resolve(ArtifactCoords.pom(moduleDep.getGroupId(), moduleDep.getArtifactId(), moduleVersion))
.getResolvedPaths().getSinglePath());
modulePom.setParent(parent);
final Path moduleDir = IoUtils.mkdirs(ws.resolve(modulePom.getArtifactId()));
ModelUtils.persistModel(moduleDir.resolve("pom.xml"), modulePom);
final Path resolvedJar = resolver
.resolve(ArtifactCoords.of(modulePom.getGroupId(), modulePom.getArtifactId(),
moduleDep.getClassifier(), moduleDep.getType(), modulePom.getVersion()))
.getResolvedPaths()
.getSinglePath();
final Path moduleTargetDir = moduleDir.resolve("target");
ZipUtils.unzip(resolvedJar, moduleTargetDir.resolve("classes"));
IoUtils.copy(resolvedJar,
moduleTargetDir.resolve(modulePom.getArtifactId() + "-" + modulePom.getVersion() + ".jar"));
if (!depModules.isEmpty()) {
final Map<ArtifactKey, String> managedVersions = new HashMap<>();
collectManagedDeps(appPom, managedVersions);
for (Dependency moduleDep : depModules) {
parentPom.getModules().add(moduleDep.getArtifactId());
final String moduleVersion = moduleDep.getVersion() == null
? managedVersions.get(ArtifactKey.of(moduleDep.getGroupId(), moduleDep.getArtifactId(),
moduleDep.getClassifier(), moduleDep.getType()))
: moduleDep.getVersion();
Model modulePom = ModelUtils.readModel(resolver
.resolve(ArtifactCoords.pom(moduleDep.getGroupId(), moduleDep.getArtifactId(), moduleVersion))
.getResolvedPaths().getSinglePath());
modulePom.setParent(parent);
final Path moduleDir = IoUtils.mkdirs(ws.resolve(modulePom.getArtifactId()));
ModelUtils.persistModel(moduleDir.resolve("pom.xml"), modulePom);
final Path resolvedJar = resolver
.resolve(ArtifactCoords.of(modulePom.getGroupId(), modulePom.getArtifactId(),
moduleDep.getClassifier(), moduleDep.getType(), modulePom.getVersion()))
.getResolvedPaths()
.getSinglePath();
final Path moduleTargetDir = moduleDir.resolve("target");
ZipUtils.unzip(resolvedJar, moduleTargetDir.resolve("classes"));
IoUtils.copy(resolvedJar,
moduleTargetDir.resolve(modulePom.getArtifactId() + "-" + modulePom.getVersion() + ".jar"));
}
}

for (TsArtifact module : wsModules) {
parentPom.getModules().add(module.getArtifactId());
Model modulePom = module.getPomModel();
Expand Down
Loading

0 comments on commit dcd3a0b

Please sign in to comment.