use of org.jboss.modules.ModuleLoadException 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.jboss.modules.ModuleLoadException in project wildfly-swarm by wildfly-swarm.
the class BootstrapClasspathModuleFinderTest method testSlot.
@Test
public void testSlot() {
BootstrapClasspathModuleFinder finder = new BootstrapClasspathModuleFinder();
try {
ModuleSpec spec = finder.findModule("classpath.module.load.test:1.0.0.Final", null);
assertNotNull(spec);
} catch (ModuleLoadException e) {
fail();
}
}
use of org.jboss.modules.ModuleLoadException in project wildfly-swarm by wildfly-swarm.
the class BootstrapClasspathModuleFinderTest method testMain.
@Test
public void testMain() {
BootstrapClasspathModuleFinder finder = new BootstrapClasspathModuleFinder();
try {
ModuleSpec spec = finder.findModule("classpath.module.load.test", null);
assertNotNull(spec);
} catch (ModuleLoadException e) {
fail();
}
}
use of org.jboss.modules.ModuleLoadException in project wildfly-swarm by wildfly-swarm.
the class BootstrapClasspathModuleFinderTest method testMissingMain.
@Test
public void testMissingMain() {
BootstrapClasspathModuleFinder finder = new BootstrapClasspathModuleFinder();
try {
ModuleSpec spec = finder.findModule("classpath.module.load.test.missing", null);
assertNull(spec);
} catch (ModuleLoadException e) {
fail();
}
}
use of org.jboss.modules.ModuleLoadException in project wildfly-swarm by wildfly-swarm.
the class ClasspathModuleFinderTest method testMissingSlot.
@Test
public void testMissingSlot() {
ClasspathModuleFinder finder = new ClasspathModuleFinder();
try {
ModuleSpec spec = finder.findModule("classpath.module.load.test:missing", null);
assertNull(spec);
} catch (ModuleLoadException e) {
fail();
}
}
Aggregations