use of org.jboss.shrinkwrap.api.spec.JavaArchive in project wildfly by wildfly.
the class JMXPropertyEditorsTestCase method deploymentObjectDouble.
@Deployment(name = "ObjectDouble", managed = false)
public static Archive<?> deploymentObjectDouble() {
// jar
final JavaArchive jmxSAR = createArchive("ObjectDouble");
Asset asset = createServiceAsset("ObjectDouble", "10");
jmxSAR.addAsManifestResource(asset, "jboss-service.xml");
return jmxSAR;
}
use of org.jboss.shrinkwrap.api.spec.JavaArchive in project wildfly by wildfly.
the class JMXPropertyEditorsTestCase method createArchive.
private static JavaArchive createArchive(String prefix) {
// jar
final JavaArchive jmxSAR = ShrinkWrap.create(JavaArchive.class, prefix + "-" + SAR_DEPLOMENT_FILE);
jmxSAR.addClass(WithPropertiesMBean.class);
jmxSAR.addClass(WithProperties.class);
return jmxSAR;
}
use of org.jboss.shrinkwrap.api.spec.JavaArchive in project camel by apache.
the class ArquillianPackager method springBootPackage.
public static Archive<?> springBootPackage(ITestConfig config) throws Exception {
if (!new File(".").getCanonicalFile().getName().equals("camel-itest-spring-boot")) {
throw new IllegalStateException("In order to run the integration tests, 'camel-itest-spring-boot' must be the working directory. Check your configuration.");
}
ExtensionLoader extensionLoader = new ServiceExtensionLoader(Collections.singleton(getExtensionClassloader()));
extensionLoader.addOverride(ZipExporter.class, SpringBootZipExporterImpl.class);
ConfigurationBuilder builder = new ConfigurationBuilder().extensionLoader(extensionLoader);
Configuration conf = builder.build();
Domain domain = ShrinkWrap.createDomain(conf);
JavaArchive ark = domain.getArchiveFactory().create(JavaArchive.class, "test.jar");
ark = ark.addAsManifestResource("BOOT-MANIFEST.MF", "MANIFEST.MF");
ark = ark.addAsDirectories(LIB_FOLDER);
if (!CLASSES_FOLDER.equals("")) {
ark = ark.addAsDirectories(CLASSES_FOLDER);
}
if (config.getUseCustomLog()) {
ark = ark.addAsResource("spring-logback.xml", CLASSES_FOLDER + "/spring-logback.xml");
}
for (Map.Entry<String, String> res : config.getResources().entrySet()) {
ark = ark.addAsResource(res.getKey(), CLASSES_FOLDER + "/" + res.getValue());
}
String version = System.getProperty("version_org.apache.camel:camel-core");
if (version == null) {
config.getMavenVersion();
}
if (version == null) {
// It is missing when launching from IDE
List<MavenResolvedArtifact> resolved = Arrays.asList(resolver(config).loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withoutTransitivity().asResolvedArtifact());
for (MavenResolvedArtifact dep : resolved) {
if (dep.getCoordinate().getGroupId().equals("org.apache.camel")) {
version = dep.getCoordinate().getVersion();
break;
}
}
}
debug("Resolved version: " + version);
if (version == null) {
throw new IllegalStateException("Cannot determine the current version of the camel component");
}
List<MavenDependencyExclusion> commonExclusions = new LinkedList<>();
commonExclusions.add(MavenDependencies.createExclusion("commons-logging", "commons-logging"));
commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-log4j12"));
commonExclusions.add(MavenDependencies.createExclusion("log4j", "log4j"));
commonExclusions.add(MavenDependencies.createExclusion("log4j", "log4j-slf4j-impl"));
commonExclusions.add(MavenDependencies.createExclusion("org.apache.logging.log4j", "log4j"));
commonExclusions.add(MavenDependencies.createExclusion("org.apache.logging.log4j", "log4j-core"));
commonExclusions.add(MavenDependencies.createExclusion("org.apache.logging.log4j", "log4j-slf4j-impl"));
commonExclusions.add(MavenDependencies.createExclusion("log4j", "apache-log4j-extras"));
commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-simple"));
commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-jdk14"));
commonExclusions.add(MavenDependencies.createExclusion("ch.qos.logback", "logback-classic"));
commonExclusions.add(MavenDependencies.createExclusion("ch.qos.logback", "logback-core"));
for (String ex : config.getMavenExclusions()) {
commonExclusions.add(MavenDependencies.createExclusion(ex));
}
// Module dependencies
List<MavenDependency> additionalDependencies = new LinkedList<>();
for (String canonicalForm : config.getAdditionalDependencies()) {
MavenCoordinate coord = MavenCoordinates.createCoordinate(canonicalForm);
MavenDependency dep = MavenDependencies.createDependency(coord, ScopeType.RUNTIME, false);
additionalDependencies.add(dep);
}
// String mainArtifactId = config.getModuleName() + "-starter";
// MavenCoordinate mainJar = MavenCoordinates.createCoordinate(config.getMavenGroup(), mainArtifactId, version, PackagingType.JAR, null);
// // Add exclusions only when not using the starters
// MavenDependency mainDep = MavenDependencies.createDependency(mainJar, ScopeType.COMPILE, false);
// moduleDependencies.add(mainDep);
List<String> testProvidedDependenciesXml = new LinkedList<>();
List<ScopeType> scopes = new LinkedList<>();
if (config.getIncludeProvidedDependencies() || config.getIncludeTestDependencies() || config.getUnitTestEnabled()) {
if (config.getIncludeTestDependencies() || config.getUnitTestEnabled()) {
testProvidedDependenciesXml.addAll(DependencyResolver.getDependencies(config.getModuleBasePath() + "/pom.xml", ScopeType.TEST.toString()));
scopes.add(ScopeType.TEST);
}
if (config.getIncludeProvidedDependencies()) {
testProvidedDependenciesXml.addAll(DependencyResolver.getDependencies(config.getModuleBasePath() + "/pom.xml", ScopeType.PROVIDED.toString()));
scopes.add(ScopeType.PROVIDED);
}
}
List<String> cleanTestProvidedDependenciesXml = new LinkedList<>();
for (String depXml : testProvidedDependenciesXml) {
if (validTestDependency(config, depXml, commonExclusions)) {
depXml = useBOMVersionIfPresent(config, depXml);
depXml = enforceExclusions(config, depXml, commonExclusions);
depXml = switchToStarterIfPresent(config, depXml);
cleanTestProvidedDependenciesXml.add(depXml);
}
}
// List<MavenResolvedArtifact> testDependencies = new LinkedList<>();
// if (!cleanTestProvidedDependenciesXml.isEmpty()) {
//
// File testProvidedResolverPom = createResolverPom(config, cleanTestProvidedDependenciesXml);
//
// testDependencies.addAll(Arrays.asList(resolver(config)
// .loadPomFromFile(testProvidedResolverPom)
// .importDependencies(scopes.toArray(new ScopeType[0]))
// .resolve()
// .withTransitivity()
// .asResolvedArtifact()));
// }
File moduleSpringBootPom = createUserPom(config, cleanTestProvidedDependenciesXml);
List<ScopeType> resolvedScopes = new LinkedList<>();
resolvedScopes.add(ScopeType.COMPILE);
resolvedScopes.add(ScopeType.RUNTIME);
resolvedScopes.addAll(scopes);
List<MavenResolvedArtifact> runtimeDependencies = new LinkedList<>();
runtimeDependencies.addAll(Arrays.asList(resolver(config).loadPomFromFile(moduleSpringBootPom).importDependencies(resolvedScopes.toArray(new ScopeType[0])).addDependencies(additionalDependencies).resolve().withTransitivity().asResolvedArtifact()));
//merge(config, runtimeDependencies, testDependencies);
List<MavenResolvedArtifact> dependencyArtifacts = runtimeDependencies;
lookForVersionMismatch(config, dependencyArtifacts);
List<File> dependencies = new LinkedList<>();
for (MavenResolvedArtifact a : dependencyArtifacts) {
dependencies.add(a.asFile());
}
// The spring boot-loader dependency will be added to the main jar, so it should be excluded from the embedded ones
excludeDependencyRegex(dependencies, "^spring-boot-loader-[0-9].*");
// Add all dependencies as spring-boot nested jars
ark = addDependencies(ark, dependencies);
// Add common packages to main jar
ark = ark.addPackages(true, "org.jboss.shrinkwrap");
// Add current classes to both location to be used by different classloaders
ark = ark.addPackages(true, "org.apache.camel.itest.springboot");
ark = addSpringbootPackage(ark, "org.apache.camel.itest.springboot");
// CAMEL-10060 is resolved since 2.18 but some unit tests use custom (non spring-boot enabled) camel contexts
ark = ark.addPackages(true, "org.apache.camel.converter.myconverter");
ark = ark.addPackages(true, "org.springframework.boot.loader");
ClassPath.Builder external = ClassPath.builder().add(ark);
// overcome limitations of some JDKs
external.addSystemProperty("javax.xml.accessExternalDTD", "all");
external.addSystemProperty("javax.xml.accessExternalSchema", "all");
if (config.getUnitTestEnabled()) {
external.addSystemProperty("container.user.dir", new File(config.getModuleBasePath()).getCanonicalPath());
external.addSystemProperty("container.test.resources.dir", new File(config.getModuleBasePath()).getCanonicalPath() + "/target/test-classes");
}
// Adding configuration properties
for (Map.Entry<Object, Object> e : System.getProperties().entrySet()) {
if (e.getKey() instanceof String && e.getValue() instanceof String) {
String key = (String) e.getKey();
if (key.startsWith(ITestConfigBuilder.CONFIG_PREFIX)) {
external.addSystemProperty(key, (String) e.getValue());
}
}
}
for (Map.Entry<String, String> e : config.getSystemProperties().entrySet()) {
external.addSystemProperty(e.getKey(), e.getValue());
}
return external.build();
}
use of org.jboss.shrinkwrap.api.spec.JavaArchive in project hibernate-orm by hibernate.
the class PackagingTestCase method buildNestedEarDir.
protected File buildNestedEarDir(File includeFile) {
String fileName = "nesteddir.ear";
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, fileName);
archive.addAsResource(includeFile);
File testPackage = new File(packageTargetDir, fileName);
archive.as(ExplodedExporter.class).exportExploded(packageTargetDir);
return testPackage;
}
use of org.jboss.shrinkwrap.api.spec.JavaArchive in project hibernate-orm by hibernate.
the class PackagingTestCase method buildDefaultPar_1_0.
protected File buildDefaultPar_1_0() {
String fileName = "defaultpar_1_0.par";
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, fileName);
archive.addClasses(ApplicationServer1.class, Lighter1.class, Money1.class, Mouse1.class, IncrementListener1.class, Version1.class);
ArchivePath path = ArchivePaths.create("META-INF/orm.xml");
archive.addAsResource("defaultpar_1_0/META-INF/orm.xml", path);
path = ArchivePaths.create("META-INF/persistence.xml");
archive.addAsResource("defaultpar_1_0/META-INF/persistence.xml", path);
path = ArchivePaths.create("org/hibernate/jpa/test/pack/defaultpar_1_0/Mouse.hbm.xml");
archive.addAsResource("defaultpar_1_0/org/hibernate/jpa/test/pack/defaultpar_1_0/Mouse1.hbm.xml", path);
path = ArchivePaths.create("org/hibernate/jpa/test/pack/defaultpar_1_0/package-info.class");
archive.addAsResource("org/hibernate/jpa/test/pack/defaultpar_1_0/package-info.class", path);
File testPackage = new File(packageTargetDir, fileName);
archive.as(ZipExporter.class).exportTo(testPackage, true);
return testPackage;
}
Aggregations