use of org.wildfly.swarm.bootstrap.env.ApplicationEnvironment in project wildfly-swarm by wildfly-swarm.
the class ArtifactManager method determineVersionViaApplicationEnvironment.
String determineVersionViaApplicationEnvironment(String groupId, String artifactId, String packaging, String classifier) throws IOException {
ApplicationEnvironment env = ApplicationEnvironment.get();
if (classifier.isEmpty()) {
classifier = null;
}
for (String dep : env.getDependencies()) {
String[] parts = dep.split(COLON);
String depGroupId = parts[0];
String depArtifactId = parts[1];
String depPackaging = parts[2];
String depVersion = null;
String depClassifier = null;
if (parts.length == 4) {
depVersion = parts[3];
} else {
depClassifier = parts[3];
depVersion = parts[4];
}
if (groupId.equals(depGroupId)) {
if (artifactId.equals(depArtifactId)) {
if (packaging.equals(depPackaging)) {
if (classifier == null) {
if (depClassifier == null) {
return depVersion;
}
} else {
if (depClassifier != null && classifier.equals(depClassifier)) {
return depVersion;
}
}
}
}
}
}
return null;
}
use of org.wildfly.swarm.bootstrap.env.ApplicationEnvironment in project wildfly-swarm by wildfly-swarm.
the class BootstrapModuleFinder method buildModule.
@Override
public void buildModule(ModuleSpec.Builder builder, ModuleLoader delegateLoader) throws ModuleLoadException {
try (AutoCloseable handle = Performance.accumulate("module: Bootstrap")) {
if (LOG.isTraceEnabled()) {
LOG.trace("Loading module");
}
ApplicationEnvironment env = ApplicationEnvironment.get();
PathFilter filter = new PathFilter() {
@Override
public boolean accept(String path) {
return path.endsWith("/module.xml");
}
};
env.bootstrapArtifactsAsCoordinates().forEach((coords) -> {
try {
File artifact = MavenResolvers.get().resolveJarArtifact(coords);
if (artifact == null) {
throw new RuntimeException("Unable to resolve artifact from coordinates: " + coords);
}
JarFile jar = JarFileManager.INSTANCE.addJarFile(artifact);
ResourceLoader originaloader = ResourceLoaders.createJarResourceLoader(artifact.getName(), jar);
builder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(ResourceLoaders.createFilteredResourceLoader(filter, originaloader)));
} catch (IOException e) {
throw new RuntimeException(e);
}
});
builder.addDependency(DependencySpec.createLocalDependencySpec());
builder.addDependency(DependencySpec.createModuleDependencySpec("org.jboss.modules"));
builder.addDependency(DependencySpec.createModuleDependencySpec("org.jboss.shrinkwrap"));
builder.addDependency(DependencySpec.createModuleDependencySpec("org.yaml.snakeyaml"));
HashSet<String> paths = new HashSet<>();
paths.add("org/wildfly/swarm/bootstrap/env");
paths.add("org/wildfly/swarm/bootstrap/logging");
paths.add("org/wildfly/swarm/bootstrap/modules");
paths.add("org/wildfly/swarm/bootstrap/performance");
paths.add("org/wildfly/swarm/bootstrap/util");
builder.addDependency(DependencySpec.createSystemDependencySpec(paths, true));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.wildfly.swarm.bootstrap.env.ApplicationEnvironment in project wildfly-swarm by wildfly-swarm.
the class ApplicationModuleFinderTest method testDependencyHasClassifier.
@Test
public void testDependencyHasClassifier() {
// Mocks
ApplicationEnvironment env = mock(ApplicationEnvironment.class);
when(env.getDependencies()).thenReturn(Collections.singleton("org.jboss.forge.addon:ui-spi:jar:forge-addon:3.4.0.Final"));
ModuleSpec.Builder builder = mock(ModuleSpec.Builder.class);
ApplicationModuleFinder sut = new ApplicationModuleFinder();
sut.addDependencies(builder, env);
verify(builder, times(1)).addResourceRoot(any());
}
Aggregations