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));
}
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]));
}
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);
}
Aggregations