Search in sources :

Example 1 with MavenDependencyConfigImpl

use of org.guvnor.ala.build.maven.config.impl.MavenDependencyConfigImpl 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();
    }
}
Also used : Path(java.nio.file.Path) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenDependencyConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenDependencyConfigImpl) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) Pipeline(org.guvnor.ala.pipeline.Pipeline) Input(org.guvnor.ala.pipeline.Input) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) Binary(org.guvnor.ala.build.Binary) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) Test(org.junit.Test)

Aggregations

Path (java.nio.file.Path)1 Binary (org.guvnor.ala.build.Binary)1 MavenDependencyConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenDependencyConfigImpl)1 MavenBinary (org.guvnor.ala.build.maven.model.MavenBinary)1 Input (org.guvnor.ala.pipeline.Input)1 Pipeline (org.guvnor.ala.pipeline.Pipeline)1 PipelineExecutor (org.guvnor.ala.pipeline.execution.PipelineExecutor)1 BuildRegistry (org.guvnor.ala.registry.BuildRegistry)1 InMemoryBuildRegistry (org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry)1 Test (org.junit.Test)1