use of org.guvnor.ala.build.maven.util.RepositoryVisitor 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.util.RepositoryVisitor 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);
}
use of org.guvnor.ala.build.maven.util.RepositoryVisitor in project kie-wb-common by kiegroup.
the class RepositoryVisitorTest method repositoryVisitorDiffDeletedTest.
@Test
public void repositoryVisitorDiffDeletedTest() throws IOException {
final IOServiceNio2WrapperImpl ioService = new IOServiceNio2WrapperImpl();
final Optional<Source> sourceOptional = new GitConfigExecutor(new InMemorySourceRegistry()).apply(new GitConfigImpl(tempPath.getAbsolutePath(), "master", gitUrl, "users-new", "true"));
assertTrue(sourceOptional.isPresent());
final Source source = sourceOptional.get();
final InputStream pomStream = org.uberfire.java.nio.file.Files.newInputStream(source.getPath().resolve("pom.xml"));
final MavenProject project = MavenProjectLoader.parseMavenPom(pomStream);
RepositoryVisitor repositoryVisitor = new RepositoryVisitor(source.getPath(), project.getName());
System.out.println("Root: " + repositoryVisitor.getRoot().getAbsolutePath());
Map<String, String> identityHash = repositoryVisitor.getIdentityHash();
final URI originRepo = URI.create("git://users-new");
final FileSystem fs = FileSystems.getFileSystem(originRepo);
ioService.startBatch(fs);
ioService.write(fs.getPath("/file.txt"), "temp");
ioService.write(fs.getPath("/pom.xml"), "hi there" + UUID.randomUUID().toString());
ioService.endBatch();
ioService.delete(source.getPath().resolve("demo.iml"));
RepositoryVisitor newRepositoryVisitor = new RepositoryVisitor(source.getPath(), repositoryVisitor.getRoot().getAbsolutePath().trim(), false);
System.out.println("Root: " + newRepositoryVisitor.getRoot().getAbsolutePath());
Map<String, String> newIdentityHash = newRepositoryVisitor.getIdentityHash();
MapDifference<String, String> difference = Maps.difference(identityHash, newIdentityHash);
Map<String, MapDifference.ValueDifference<String>> entriesDiffering = difference.entriesDiffering();
System.out.println(" Size of Differences: " + entriesDiffering.size());
for (String key : entriesDiffering.keySet()) {
System.out.println("Different Value: " + key);
}
assertEquals(1, entriesDiffering.size());
assertNotNull(entriesDiffering.get("/pom.xml"));
Map<String, String> deletedFiles = difference.entriesOnlyOnLeft();
System.out.println(" Size of Deleted Files: " + deletedFiles.size());
for (String key : deletedFiles.keySet()) {
System.out.println("Deleted File: " + key);
}
assertEquals(1, deletedFiles.size());
assertNotNull(deletedFiles.get("/demo.iml"));
Map<String, String> addedFiles = difference.entriesOnlyOnRight();
System.out.println(" Size of added Files: " + addedFiles.size());
for (String key : addedFiles.keySet()) {
System.out.println("Added File: " + key);
}
assertEquals(1, addedFiles.size());
assertNotNull(addedFiles.get("/file.txt"));
}
Aggregations