use of org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage in project wildfly-swarm by wildfly-swarm.
the class RestClientArchiveProcessor method process.
@Override
public void process(Archive<?> appArchive, TestClass testClass) {
if (!(appArchive instanceof WebArchive)) {
return;
}
log.info("Preparing archive: " + appArchive);
WARArchive war = appArchive.as(WARArchive.class);
PomEquippedResolveStage pom = Maven.resolver().loadPomFromFile("pom.xml");
// Wiremock classes that need to be present
File[] wiremockDeps = pom.resolve("com.github.tomakehurst:wiremock").withTransitivity().asFile();
war.addAsLibraries(wiremockDeps);
// TCK Classes that need to present
war.addPackages(true, "org.eclipse.microprofile.rest.client.tck.interfaces");
log.fine("Augmented war: \n" + war.toString(true));
}
use of org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage in project jbpm by kiegroup.
the class EJBService method buildArchive.
public WebArchive buildArchive() throws Exception {
System.out.println("### Building archive '" + ARCHIVE_NAME + ".war'");
PomEquippedResolveStage resolver = IntegrationMavenResolver.get("jbpm", "jbpm-ejb-services", "jbpm-persistence");
File[] dependencies = resolver.importCompileAndRuntimeDependencies().resolve().withTransitivity().asFile();
LOGGER.debug("Archive dependencies:");
for (File d : dependencies) {
LOGGER.debug(d.getName());
}
war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME + ".war").addAsLibraries(dependencies).addClass(EJBService.class).addClass(WebSphereFixedJtaPlatform.class).addClass(DefaultCountDownProcessEventListener.class).addClass(JbpmContainerTest.class).addClass(AbstractEJBServicesTest.class).addClass(AbstractRuntimeEJBServicesTest.class).addClass(TrackingAgendaEventListener.class).addPackages(true, "org.jbpm.test.container.groups", EJB_SERVICES_PACKAGE, TEST_EJB_SERVICES_PACKAGE).addAsWebResource(getClass().getResource("/logback.xml"), ArchivePaths.create("logback.xml")).addAsResource(getClass().getResource("ejbservices/persistence.xml"), ArchivePaths.create("META-INF/persistence.xml")).addAsResource(getClass().getResource("ejbservices/usergroups.properties"), ArchivePaths.create("usergroups.properties")).addAsResource(getClass().getResource("ejbservices/UserGroupsAssignmentsOne.mvel"), ArchivePaths.create("org/jbpm/services/task/identity/UserGroupsAssignmentsOne.mvel"));
// CDI beans.xml
war.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("classes/META-INF/beans.xml"));
try {
String pkg = EJB_SERVICES_ASSETS_PATH;
File f = new File(getClass().getResource(pkg).toURI());
for (File res : f.listFiles()) {
if (!res.isDirectory()) {
war.addAsResource(res, ArchivePaths.create(pkg, res.getName()));
}
}
} catch (Exception ex) {
LOGGER.error("Failed to build archive.", ex);
throw ex;
}
return war;
}
use of org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage in project component-runtime by Talend.
the class Dependencies method findRepositories.
private static List<MavenRemoteRepository> findRepositories() {
final List<MavenRemoteRepository> repositories = new ArrayList<>();
final String repos = System.getProperty("talend.component.junit.maven.repositories");
if (repos != null && !repos.isEmpty()) {
for (final String repo : repos.split(",")) {
final String[] parts = repo.split("::");
final MavenRemoteRepository repository = MavenRemoteRepositories.createRemoteRepository(parts.length == 1 ? "repo_" + parts[0].replace(':', '_').replace('/', '_') : parts[0], parts.length == 1 ? parts[0] : parts[1], parts.length < 3 ? "default" : parts[2]);
repository.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_DAILY);
repository.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
repositories.add(repository);
}
} else if (!Boolean.getBoolean("talend.component.junit.maven.skipPomReading")) {
// try to grab from the root pom the repos - simplifying maven parsing for speed reasons and enough
// generally
File current = new File(".").getAbsoluteFile();
while (new File(current, "pom.xml").exists()) {
final File parent = current.getParentFile();
if (parent != null && new File(parent, "pom.xml").exists()) {
current = parent;
continue;
}
break;
}
final File pom = new File(current, "pom.xml");
if (pom.exists()) {
final PomEquippedResolveStage localPom = Maven.configureResolver().loadPomFromFile(pom);
final MavenWorkingSession mavenWorkingSession = PomEquippedResolveStageBaseImpl.class.cast(localPom).getMavenWorkingSession();
try {
final Field remoteRepositories = mavenWorkingSession.getClass().getDeclaredField("remoteRepositories");
if (!remoteRepositories.isAccessible()) {
remoteRepositories.setAccessible(true);
}
final List<RemoteRepository> pomRepos = List.class.cast(remoteRepositories.get(mavenWorkingSession));
if (pomRepos != null && !pomRepos.isEmpty()) {
pomRepos.forEach(r -> {
final MavenRemoteRepository repository = MavenRemoteRepositories.createRemoteRepository(r.getId(), r.getUrl(), "default");
repository.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_DAILY);
repository.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_IGNORE);
repositories.add(repository);
});
}
} catch (final Exception e) {
throw new IllegalStateException("Check your shrinkwrap maven version", e);
}
}
}
if (!Boolean.getBoolean("talend.component.junit.maven.central.skip")) {
final MavenRemoteRepository central = MavenRemoteRepositories.createRemoteRepository("central_test_default", "http://repo.maven.apache.org/maven2/", "default");
central.setChecksumPolicy(MavenChecksumPolicy.CHECKSUM_POLICY_WARN);
central.setUpdatePolicy(MavenUpdatePolicy.UPDATE_POLICY_NEVER);
repositories.add(central);
}
return repositories;
}
use of org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage in project camunda-bpm-platform by camunda.
the class TomcatServerBootstrap method start.
public void start() {
Properties serverProperties = readProperties();
int port = Integer.parseInt(serverProperties.getProperty(PORT_PROPERTY));
tomcat = new Tomcat();
tomcat.setPort(port);
tomcat.setBaseDir(getWorkingDir());
tomcat.getHost().setAppBase(getWorkingDir());
tomcat.getHost().setAutoDeploy(true);
tomcat.getHost().setDeployOnStartup(true);
String contextPath = "/" + getContextPath();
PomEquippedResolveStage resolver = Maven.configureResolver().useLegacyLocalRepo(true).workOffline().loadPomFromFile("pom.xml");
WebArchive wa = ShrinkWrap.create(WebArchive.class, "rest-test.war").setWebXML(webXmlPath).addAsLibraries(resolver.resolve("org.codehaus.jackson:jackson-jaxrs:1.6.5").withTransitivity().asFile()).addAsLibraries(resolver.addDependencies(MavenDependencies.createDependency("org.mockito:mockito-core", ScopeType.TEST, false, MavenDependencies.createExclusion("org.hamcrest:hamcrest-core"))).resolve().withTransitivity().asFile()).addAsServiceProvider(ProcessEngineProvider.class, MockedProcessEngineProvider.class).add(new ClassLoaderAsset("runtime/tomcat/context.xml"), "META-INF/context.xml").addPackages(true, "org.camunda.bpm.engine.rest");
addRuntimeSpecificLibraries(wa, resolver);
wa.setWebXML(webXmlPath);
String webAppPath = getWorkingDir() + "/" + getContextPath() + ".war";
wa.as(ZipExporter.class).exportTo(new File(webAppPath), true);
tomcat.addWebapp(tomcat.getHost(), contextPath, webAppPath);
try {
tomcat.start();
} catch (LifecycleException e) {
throw new RuntimeException(e);
}
}
use of org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage in project wildfly-swarm by wildfly-swarm.
the class MavenDependencyDeclarationFactory method create.
@Override
public DeclaredDependencies create(FileSystemLayout ignored, ShrinkwrapArtifactResolvingHelper resolvingHelper) {
final DeclaredDependencies declaredDependencies = new DeclaredDependencies();
final PomEquippedResolveStage pom = MavenProfileLoader.loadPom(resolvingHelper.getResolver());
// NonTransitiveStrategy
final MavenResolvedArtifact[] explicitDeps = resolvingHelper.withResolver(r -> pom.importRuntimeAndTestDependencies().resolve().withoutTransitivity().asResolvedArtifact());
// TransitiveStrategy
for (MavenResolvedArtifact directDep : explicitDeps) {
ArtifactSpec parent = new ArtifactSpec(directDep.getScope().toString(), directDep.getCoordinate().getGroupId(), directDep.getCoordinate().getArtifactId(), directDep.getCoordinate().getVersion(), directDep.getCoordinate().getPackaging().toString(), directDep.getCoordinate().getClassifier(), directDep.asFile());
MavenResolvedArtifact[] bucket = resolvingHelper.withResolver(r -> {
r.addDependency(resolvingHelper.createMavenDependency(parent));
return pom.resolve().withTransitivity().asResolvedArtifact();
});
for (MavenResolvedArtifact dep : bucket) {
ArtifactSpec child = new ArtifactSpec(dep.getScope().toString(), dep.getCoordinate().getGroupId(), dep.getCoordinate().getArtifactId(), dep.getCoordinate().getVersion(), dep.getCoordinate().getPackaging().toString(), dep.getCoordinate().getClassifier(), dep.asFile());
declaredDependencies.add(parent, child);
}
}
return declaredDependencies;
}
Aggregations