Search in sources :

Example 1 with MavenProjectImpl

use of org.guvnor.ala.build.maven.model.impl.MavenProjectImpl in project kie-wb-common by kiegroup.

the class WildflyRuntimeTest method waitForAppBuildTest.

@Test
public void waitForAppBuildTest() {
    final Optional<Source> _source = new GitConfigExecutor(new InMemorySourceRegistry()).apply(new GitConfigImpl(tempPath.getAbsolutePath(), "master", gitUrl, "drools-workshop-build", "true"));
    assertTrue(_source.isPresent());
    final Source source = _source.get();
    assertNotNull(source);
    List<String> goals = new ArrayList<>();
    goals.add("package");
    Properties properties = new Properties();
    properties.setProperty("failIfNoTests", "false");
    final Path projectRoot = source.getPath();
    final InputStream pomStream = org.uberfire.java.nio.file.Files.newInputStream(projectRoot.resolve("pom.xml"));
    final MavenProject project = MavenProjectLoader.parseMavenPom(pomStream);
    RepositoryVisitor repositoryVisitor = new RepositoryVisitor(projectRoot, project.getName());
    final String expectedBinary = project.getArtifact().getArtifactId() + "-" + project.getArtifact().getVersion() + "." + project.getArtifact().getType();
    final org.guvnor.ala.build.maven.model.MavenProject mavenProject = new MavenProjectImpl(project.getId(), project.getArtifact().getType(), project.getName(), expectedBinary, source.getPath(), source.getPath(), source.getPath().resolve("target").resolve(expectedBinary).toAbsolutePath(), repositoryVisitor.getRoot().getAbsolutePath(), null);
    final File pom = new File(mavenProject.getTempDir(), "pom.xml");
    MavenBuildExecutor.executeMaven(pom, properties, goals.toArray(new String[0]));
    final File file = new File(repositoryVisitor.getRoot().getAbsolutePath() + "/target/" + mavenProject.getExpectedBinary());
    WildflyClient wildflyClient = new WildflyClient("", "admin", "Admin#70365", ip, 8080, 9990);
    wildflyClient.deploy(file);
    final String id = file.getName();
    WildflyAppState appState = wildflyClient.getAppState(id);
    assertNotNull(appState);
    assertTrue(appState.getState().equals(RUNNING));
    wildflyClient.undeploy(id);
    appState = wildflyClient.getAppState(id);
    assertNotNull(appState);
    assertTrue(appState.getState().equals(UNKNOWN));
    wildflyClient.deploy(file);
    appState = wildflyClient.getAppState(id);
    assertNotNull(appState);
    assertTrue(appState.getState().equals(RUNNING));
}
Also used : Path(org.uberfire.java.nio.file.Path) GitConfigImpl(org.guvnor.ala.source.git.config.impl.GitConfigImpl) InputStream(java.io.InputStream) RepositoryVisitor(org.guvnor.ala.build.maven.util.RepositoryVisitor) ArrayList(java.util.ArrayList) WildflyClient(org.guvnor.ala.wildfly.access.WildflyClient) MavenProjectImpl(org.guvnor.ala.build.maven.model.impl.MavenProjectImpl) Properties(java.util.Properties) WildflyAppState(org.guvnor.ala.wildfly.access.WildflyAppState) Source(org.guvnor.ala.source.Source) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) MavenProject(org.apache.maven.project.MavenProject) File(java.io.File) Test(org.junit.Test)

Example 2 with MavenProjectImpl

use of org.guvnor.ala.build.maven.model.impl.MavenProjectImpl in project kie-wb-common by kiegroup.

the class MavenCliOutputTest method buildMavenProject.

/*
     * Build Maven Project from Source using Out and Err PrintStreams for getting the output
     */
private void buildMavenProject(Source source, PrintStream out, PrintStream err) throws org.uberfire.java.nio.IOException, SecurityException, UnsupportedOperationException, IllegalArgumentException {
    List<String> goals = new ArrayList<>();
    goals.add("package");
    Properties p = new Properties();
    p.setProperty("failIfNoTests", "false");
    final InputStream pomStream = org.uberfire.java.nio.file.Files.newInputStream(source.getPath().resolve("pom.xml"));
    MavenProject project = MavenProjectLoader.parseMavenPom(pomStream);
    final String expectedBinary = project.getArtifact().getArtifactId() + "-" + project.getArtifact().getVersion() + "." + project.getArtifact().getType();
    final org.guvnor.ala.build.maven.model.MavenProject mavenProject = new MavenProjectImpl(project.getId(), project.getArtifact().getType(), project.getName(), expectedBinary, source.getPath(), source.getPath(), source.getPath().resolve("target").resolve(expectedBinary).toAbsolutePath(), null, null);
    final File pom = new File(getRepositoryVisitor(mavenProject).getRoot(), "pom.xml");
    MavenBuildExecutor.executeMaven(pom, out, err, p, goals.toArray(new String[0]));
}
Also used : MavenProject(org.apache.maven.project.MavenProject) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) MavenProjectImpl(org.guvnor.ala.build.maven.model.impl.MavenProjectImpl) Properties(java.util.Properties) File(java.io.File)

Example 3 with MavenProjectImpl

use of org.guvnor.ala.build.maven.model.impl.MavenProjectImpl in project kie-wb-common by kiegroup.

the class MavenProjectConfigExecutor method apply.

@Override
public Optional<ProjectConfig> apply(final Source source, final MavenProjectConfig mavenProjectConfig) {
    final Path projectRoot = source.getPath().resolve(mavenProjectConfig.getProjectDir());
    final InputStream pomStream = Files.newInputStream(projectRoot.resolve("pom.xml"));
    final MavenProject project = MavenProjectLoader.parseMavenPom(pomStream);
    final Collection<PlugIn> buildPlugins = extractPlugins(project);
    final String expectedBinary = project.getArtifact().getArtifactId() + "-" + project.getArtifact().getVersion() + "." + calculateExtension(project.getArtifact().getType());
    final String _tempDir = mavenProjectConfig.getProjectTempDir().trim();
    final RepositoryVisitor repositoryVisitor;
    if (_tempDir.isEmpty()) {
        repositoryVisitor = new RepositoryVisitor(projectRoot, project.getName());
    } else {
        repositoryVisitor = new RepositoryVisitor(projectRoot, _tempDir, mavenProjectConfig.recreateTempDir());
    }
    final org.guvnor.ala.build.maven.model.MavenProject mavenProject = new MavenProjectImpl(project.getId(), project.getArtifact().getType(), project.getName(), expectedBinary, source.getPath(), source.getPath().resolve(mavenProjectConfig.getProjectDir()), source.getPath().resolve("target").resolve(expectedBinary).toAbsolutePath(), repositoryVisitor.getRoot().getAbsolutePath(), buildPlugins);
    sourceRegistry.registerProject(source, mavenProject);
    return Optional.of(mavenProject);
}
Also used : Path(org.uberfire.java.nio.file.Path) MavenProject(org.apache.maven.project.MavenProject) InputStream(java.io.InputStream) RepositoryVisitor(org.guvnor.ala.build.maven.util.RepositoryVisitor) MavenProjectImpl(org.guvnor.ala.build.maven.model.impl.MavenProjectImpl) PlugIn(org.guvnor.ala.build.maven.model.PlugIn)

Aggregations

InputStream (java.io.InputStream)3 MavenProject (org.apache.maven.project.MavenProject)3 MavenProjectImpl (org.guvnor.ala.build.maven.model.impl.MavenProjectImpl)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 RepositoryVisitor (org.guvnor.ala.build.maven.util.RepositoryVisitor)2 Path (org.uberfire.java.nio.file.Path)2 PipedInputStream (java.io.PipedInputStream)1 PlugIn (org.guvnor.ala.build.maven.model.PlugIn)1 InMemorySourceRegistry (org.guvnor.ala.registry.inmemory.InMemorySourceRegistry)1 Source (org.guvnor.ala.source.Source)1 GitConfigImpl (org.guvnor.ala.source.git.config.impl.GitConfigImpl)1 GitConfigExecutor (org.guvnor.ala.source.git.executor.GitConfigExecutor)1 WildflyAppState (org.guvnor.ala.wildfly.access.WildflyAppState)1 WildflyClient (org.guvnor.ala.wildfly.access.WildflyClient)1 Test (org.junit.Test)1