Skip to content

Commit

Permalink
* If the test class is coming from a JAR, project root should not be …
Browse files Browse the repository at this point in the history
…initialized to the current dir

* Propagate project's managed dependencies to the deployment dependency trees
  • Loading branch information
aloubyansky committed Apr 8, 2020
1 parent 6e0ba9c commit 4a87f53
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,26 @@ public boolean visitLeave(DependencyNode node) {
child.accept(visitor);
}

final ArtifactDescriptorResult appArtifactDescr = mvn.resolveDescriptor(toAetherArtifact(appArtifact));
if (managedDeps == null) {
managedDeps = appArtifactDescr.getManagedDependencies();
} else {
final List<Dependency> mergedManagedDeps = new ArrayList<>(managedDeps.size());
final Set<AppArtifactKey> mergedKeys = new HashSet<>(managedDeps.size());
for (Dependency dep : managedDeps) {
mergedKeys.add(getKey(dep.getArtifact()));
mergedManagedDeps.add(dep);
}
for (Dependency dep : appArtifactDescr.getManagedDependencies()) {
final Artifact artifact = dep.getArtifact();
if (!mergedKeys.contains(getKey(artifact))) {
mergedManagedDeps.add(dep);
}
}
managedDeps = mergedManagedDeps;
}
final List<RemoteRepository> repos = mvn.aggregateRepositories(managedRepos,
mvn.newResolutionRepositories(mvn.resolveDescriptor(toAetherArtifact(appArtifact)).getRepositories()));
mvn.newResolutionRepositories(appArtifactDescr.getRepositories()));

final DeploymentInjectingDependencyVisitor deploymentInjector = new DeploymentInjectingDependencyVisitor(mvn,
managedDeps, repos, appBuilder);
Expand Down Expand Up @@ -292,6 +310,11 @@ public void install(AppArtifact appArtifact, Path localPath) throws AppModelReso
appArtifact.getType(), appArtifact.getVersion(), Collections.emptyMap(), localPath.toFile()));
}

private AppArtifactKey getKey(final Artifact artifact) {
return new AppArtifactKey(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getClassifier(), artifact.getExtension());
}

private String getEarliest(final VersionRangeResult rangeResult) {
final List<Version> versions = rangeResult.getVersions();
if (versions.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ private void processPlatformArtifact(DependencyNode node, Path descriptor) throw
node.setData(QUARKUS_DEPLOYMENT_ARTIFACT, deploymentArtifact);
runtimeNodes.add(node);
Dependency dependency = new Dependency(node.getArtifact(), JavaScopes.COMPILE);
managedDeps.add(dependency);
runtimeExtensionDeps.add(dependency);
managedDeps.add(new Dependency(deploymentArtifact, JavaScopes.COMPILE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -106,7 +107,7 @@ private ExtensionState doJavaStart(ExtensionContext context) throws Throwable {
}
CuratedApplication curatedApplication = runnerBuilder
.setTest(true)
.setProjectRoot(new File("").toPath())
.setProjectRoot(Files.isDirectory(appClassLocation) ? new File("").toPath() : null)
.build()
.bootstrap();

Expand Down

0 comments on commit 4a87f53

Please sign in to comment.