mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
@@ -26,6 +26,7 @@ dependencies {
|
||||
implementation "io.quarkus:quarkus-platform-descriptor-resolver-json:${version}"
|
||||
implementation "io.quarkus:quarkus-development-mode:${version}"
|
||||
|
||||
testImplementation 'org.mockito:mockito-core:3.2.4'
|
||||
testImplementation 'org.assertj:assertj-core:3.14.0'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.5.2'
|
||||
|
||||
@@ -140,7 +140,7 @@ public class AppModelGradleResolver implements AppModelResolver {
|
||||
final List<AppDependency> fullDeploymentDeps = new ArrayList<>();
|
||||
if (!extensionDeps.isEmpty()) {
|
||||
final Configuration deploymentConfig = project.getConfigurations()
|
||||
.detachedConfiguration(extensionDeps.toArray(new Dependency[extensionDeps.size()]));
|
||||
.detachedConfiguration(extensionDeps.toArray(new Dependency[0]));
|
||||
final ResolvedConfiguration rc = deploymentConfig.getResolvedConfiguration();
|
||||
for (ResolvedArtifact a : rc.getResolvedArtifacts()) {
|
||||
final ModuleVersionIdentifier userVersion = userModules.get(getModuleId(a));
|
||||
@@ -232,14 +232,14 @@ public class AppModelGradleResolver implements AppModelResolver {
|
||||
return resolveModel(appArtifact);
|
||||
}
|
||||
|
||||
private ModuleIdentifier getModuleId(ResolvedArtifact a) {
|
||||
private static ModuleIdentifier getModuleId(ResolvedArtifact a) {
|
||||
final String[] split = a.getModuleVersion().toString().split(":");
|
||||
return DefaultModuleIdentifier.newId(split[0], split[1]);
|
||||
}
|
||||
|
||||
private AppDependency toAppDependency(ResolvedArtifact a) {
|
||||
static AppDependency toAppDependency(ResolvedArtifact a) {
|
||||
final String[] split = a.getModuleVersion().toString().split(":");
|
||||
final AppArtifact appArtifact = new AppArtifact(split[0], split[1], split[2]);
|
||||
final AppArtifact appArtifact = new AppArtifact(split[0], split[1], split.length > 2 ? split[2] : null);
|
||||
appArtifact.setPath(a.getFile().toPath());
|
||||
return new AppDependency(appArtifact, "runtime");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.quarkus.gradle;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.assertj.core.util.Files;
|
||||
import org.gradle.api.artifacts.ResolvedArtifact;
|
||||
import org.gradle.api.artifacts.ResolvedModuleVersion;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class AppModelGradleResolverTest {
|
||||
|
||||
@Test
|
||||
void testToAppDependency() {
|
||||
ResolvedArtifact artifact = mock(ResolvedArtifact.class);
|
||||
ResolvedModuleVersion version = mock(ResolvedModuleVersion.class);
|
||||
when(version.toString()).thenReturn(":commons-lang3-3.9:");
|
||||
when(artifact.getModuleVersion()).thenReturn(version);
|
||||
when(artifact.getFile()).thenReturn(Files.currentFolder());
|
||||
assertThatCode(() -> AppModelGradleResolver.toAppDependency(artifact)).doesNotThrowAnyException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user