use of org.guvnor.ala.build.maven.model.MavenBinary in project kie-wb-common by kiegroup.
the class ContextAwareWildflyRuntimeExecConfig method setContext.
@Override
public void setContext(final Map<String, ?> context) {
this.context = context;
MavenBinary binary = (MavenBinary) context.get("binary");
if (binary != null) {
this.warPath = binary.getPath().toString();
}
WildflyProvider provider = (WildflyProvider) context.get("wildfly-provider");
this.providerId = provider;
}
use of org.guvnor.ala.build.maven.model.MavenBinary in project kie-wb-common by kiegroup.
the class ContextAwareWildflyRuntimeExecConfigTest method testContextUsingMavenBinary.
@Test
public void testContextUsingMavenBinary() {
final ContextAwareWildflyRuntimeExecConfig config = new ContextAwareWildflyRuntimeExecConfig();
final Map<String, Object> context = new HashMap<>();
final WildflyProvider provider = mock(WildflyProvider.class);
context.put("wildfly-provider", provider);
final MavenBinary binary = mock(MavenBinary.class);
final Path path = mock(Path.class);
when(binary.getPath()).thenReturn(path);
when(path.toString()).thenReturn(FILE_PATH);
context.put("binary", binary);
config.setContext(context);
assertEquals(provider, config.getProviderId());
assertEquals(FILE_PATH, config.getWarPath());
final WildflyRuntimeExecConfig configClone = config.asNewClone(config);
assertEquals(provider, configClone.getProviderId());
assertEquals(FILE_PATH, configClone.getWarPath());
}
use of org.guvnor.ala.build.maven.model.MavenBinary in project kie-wb-common by kiegroup.
the class MavenDependencyConfigExecutorTest method testMavenDependencyAPI.
@Test
public void testMavenDependencyAPI() throws Exception {
final String groupId = "org.guvnor.ala";
final String artifactId = "maven-ala-artifact-test";
final String version = "1";
final String artifactPath = "/org/guvnor/ala/maven-ala-artifact-test/1/maven-ala-artifact-test-1.pom";
final String oldSettingsXmlPath = System.getProperty(CUSTOM_SETTINGS_PROPERTY);
try {
final Path settingsXmlPath = generateSettingsXml();
System.setProperty(CUSTOM_SETTINGS_PROPERTY, settingsXmlPath.toString());
MavenSettings.reinitSettings();
installArtifactLocally(groupId, artifactId, version);
final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Maven Artifact", new MavenDependencyConfigImpl()).buildAs("my pipe");
final PipelineExecutor executor = new PipelineExecutor(singletonList(new MavenDependencyConfigExecutor(buildRegistry)));
executor.execute(new Input() {
{
put("artifact", groupId + ":" + artifactId + ":pom:" + version);
}
}, pipe, System.out::println);
final List<Binary> allBinaries = buildRegistry.getAllBinaries();
assertNotNull(allBinaries);
assertEquals(1, allBinaries.size());
assertTrue(allBinaries.get(0) instanceof MavenBinary);
final MavenBinary binary = (MavenBinary) allBinaries.get(0);
assertEquals("Maven", binary.getType());
assertEquals(artifactId, binary.getName());
assertEquals(groupId, binary.getGroupId());
assertEquals(artifactId, binary.getArtifactId());
assertEquals(version, binary.getVersion());
assertEquals(Paths.get(m2Folder.getPath(), artifactPath).toString(), binary.getPath().toString());
} finally {
if (oldSettingsXmlPath == null) {
System.clearProperty(CUSTOM_SETTINGS_PROPERTY);
} else {
System.setProperty(CUSTOM_SETTINGS_PROPERTY, oldSettingsXmlPath);
}
MavenSettings.reinitSettings();
}
}
use of org.guvnor.ala.build.maven.model.MavenBinary in project kie-wb-common by kiegroup.
the class MavenProjectConfigExecutorTest method assertMavenBinary.
private static void assertMavenBinary(final Binary binary, final Project project) {
assertTrue(binary instanceof MavenBinary);
final MavenBinary mavenBinary = (MavenBinary) binary;
assertEquals("Maven", mavenBinary.getType());
final File pom = new File(project.getTempDir(), "pom.xml");
final MavenProject mavenProject = MavenProjectLoader.parseMavenPom(pom);
assertEquals(mavenProject.getGroupId(), mavenBinary.getGroupId());
assertEquals(mavenProject.getArtifactId(), mavenBinary.getArtifactId());
assertEquals(mavenProject.getVersion(), mavenBinary.getVersion());
assertEquals(project.getTempDir() + "/target/" + project.getExpectedBinary(), mavenBinary.getPath().toString());
}
use of org.guvnor.ala.build.maven.model.MavenBinary in project kie-wb-common by kiegroup.
the class MavenDependencyConfigExecutor method apply.
@Override
public Optional<MavenBinary> apply(final MavenDependencyConfig config) {
final String artifactId = config.getArtifact();
checkNotEmpty("artifact parameter is mandatory", artifactId);
LOGGER.debug("Resolving Artifact: {}", artifactId);
final Artifact artifact = resolveArtifact(artifactId);
if (artifact == null) {
throw new RuntimeException("Cannot resolve Maven artifact. Look at the previous logs for more information.");
}
final String absolutePath = artifact.getFile().getAbsolutePath();
LOGGER.debug("Resolved Artifact path: {}", absolutePath);
final Path path = FileSystems.getFileSystem(URI.create("file://default")).getPath(absolutePath);
final MavenBinary binary = new MavenBinaryImpl(path, artifact.getArtifactId(), artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
buildRegistry.registerBinary(binary);
return Optional.of(binary);
}
Aggregations