use of org.wildfly.swarm.fractions.FractionUsageAnalyzer in project wildfly-swarm by wildfly-swarm.
the class CDITest method testFractionMatchingMETAINF.
@Test
public void testFractionMatchingMETAINF() throws Exception {
JARArchive archive = ShrinkWrap.create(JARArchive.class);
archive.addAsResource("META-INF/beans.xml");
FractionUsageAnalyzer analyzer = new FractionUsageAnalyzer();
final File out = Files.createTempFile(archive.getName(), ".war").toFile();
out.deleteOnExit();
archive.as(ZipExporter.class).exportTo(out, true);
analyzer.source(out);
assertThat(analyzer.detectNeededFractions().stream().filter(fd -> fd.getArtifactId().equals("cdi")).count()).isEqualTo(1);
}
use of org.wildfly.swarm.fractions.FractionUsageAnalyzer in project wildfly-swarm by wildfly-swarm.
the class SecurityTest method testFractionMatchingAnnotation.
@Test
public void testFractionMatchingAnnotation() throws Exception {
JARArchive archive = ShrinkWrap.create(JARArchive.class);
archive.addClass(SecurityEndpoint.class);
FractionUsageAnalyzer analyzer = new FractionUsageAnalyzer();
final File out = Files.createTempFile(archive.getName(), ".war").toFile();
out.deleteOnExit();
archive.as(ZipExporter.class).exportTo(out, true);
analyzer.source(out);
assertThat(analyzer.detectNeededFractions().stream().filter(fd -> fd.getArtifactId().equals("security")).count()).isEqualTo(1);
}
use of org.wildfly.swarm.fractions.FractionUsageAnalyzer in project wildfly-swarm by wildfly-swarm.
the class SecurityTest method testFractionMatchingWebXML.
@Test
public void testFractionMatchingWebXML() throws Exception {
JARArchive archive = ShrinkWrap.create(JARArchive.class);
archive.addAsResource("WEB-INF/web.xml");
FractionUsageAnalyzer analyzer = new FractionUsageAnalyzer();
final File out = Files.createTempFile(archive.getName(), ".war").toFile();
out.deleteOnExit();
archive.as(ZipExporter.class).exportTo(out, true);
analyzer.source(out);
assertThat(analyzer.detectNeededFractions().stream().filter(fd -> fd.getArtifactId().equals("security")).count()).isEqualTo(1);
}
use of org.wildfly.swarm.fractions.FractionUsageAnalyzer in project wildfly-swarm by wildfly-swarm.
the class JPATest method testFractionMatching.
@Test
public void testFractionMatching() throws Exception {
JARArchive archive = ShrinkWrap.create(JARArchive.class);
archive.addAsResource("META-INF/persistence.xml");
FractionUsageAnalyzer analyzer = new FractionUsageAnalyzer();
File out = Files.createTempFile(archive.getName(), ".war").toFile();
archive.as(ZipExporter.class).exportTo(out, true);
analyzer.source(out);
assertThat(analyzer.detectNeededFractions().stream().filter(fd -> fd.getArtifactId().equals("jpa")).count()).isEqualTo(1);
out.delete();
}
use of org.wildfly.swarm.fractions.FractionUsageAnalyzer in project wildfly-swarm by wildfly-swarm.
the class BuildTool method detectFractions.
private void detectFractions() throws Exception {
final File tmpFile = File.createTempFile("buildtool", this.projectAsset.getName().replace("/", "_"));
tmpFile.deleteOnExit();
this.projectAsset.getArchive().as(ZipExporter.class).exportTo(tmpFile, true);
final FractionUsageAnalyzer analyzer = new FractionUsageAnalyzer().logger(log).source(tmpFile);
if (testClass != null && !"".equals(testClass)) {
analyzer.testClass(testClass);
}
final Collection<FractionDescriptor> detectedFractions = analyzer.detectNeededFractions();
// don't overwrite fractions added by the user
detectedFractions.removeAll(this.fractions.stream().map(ArtifactSpec::toFractionDescriptor).collect(Collectors.toSet()));
this.log.info(String.format("Detected %sfractions: %s", this.fractions.isEmpty() ? "" : "additional ", String.join(", ", detectedFractions.stream().map(FractionDescriptor::av).sorted().collect(Collectors.toList()))));
detectedFractions.stream().map(ArtifactSpec::fromFractionDescriptor).forEach(this::fraction);
}
Aggregations