Skip to content
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

Project root should not initialized to the current dir if the test class is from a JAR #8467

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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