Search in sources :

Example 1 with PomEquippedResolveStage

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));
}
Also used : WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) WARArchive(org.wildfly.swarm.undertow.WARArchive) PomEquippedResolveStage(org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage) File(java.io.File)

Example 2 with PomEquippedResolveStage

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;
}
Also used : WebSphereFixedJtaPlatform(org.jbpm.test.container.webspherefix.WebSphereFixedJtaPlatform) JbpmContainerTest(org.jbpm.test.container.JbpmContainerTest) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest) PomEquippedResolveStage(org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage) File(java.io.File)

Example 3 with PomEquippedResolveStage

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;
}
Also used : AcceptScopesStrategy(org.jboss.shrinkwrap.resolver.api.maven.strategy.AcceptScopesStrategy) URL(java.net.URL) MavenResolutionStrategy(org.jboss.shrinkwrap.resolver.api.maven.strategy.MavenResolutionStrategy) MavenChecksumPolicy(org.jboss.shrinkwrap.resolver.api.maven.repository.MavenChecksumPolicy) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) Maven(org.jboss.shrinkwrap.resolver.api.maven.Maven) MavenRemoteRepository(org.jboss.shrinkwrap.resolver.api.maven.repository.MavenRemoteRepository) PomEquippedResolveStageBaseImpl(org.jboss.shrinkwrap.resolver.impl.maven.PomEquippedResolveStageBaseImpl) MavenDependency(org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency) MavenWorkingSession(org.jboss.shrinkwrap.resolver.api.maven.MavenWorkingSession) ScopeType(org.jboss.shrinkwrap.resolver.api.maven.ScopeType) MavenRemoteRepositories(org.jboss.shrinkwrap.resolver.api.maven.repository.MavenRemoteRepositories) MalformedURLException(java.net.MalformedURLException) PomEquippedResolveStage(org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Field(java.lang.reflect.Field) File(java.io.File) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) List(java.util.List) Stream(java.util.stream.Stream) ConfigurableMavenResolverSystem(org.jboss.shrinkwrap.resolver.api.maven.ConfigurableMavenResolverSystem) MavenUpdatePolicy(org.jboss.shrinkwrap.resolver.api.maven.repository.MavenUpdatePolicy) PRIVATE(lombok.AccessLevel.PRIVATE) NoArgsConstructor(lombok.NoArgsConstructor) MavenWorkingSession(org.jboss.shrinkwrap.resolver.api.maven.MavenWorkingSession) ArrayList(java.util.ArrayList) PomEquippedResolveStage(org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage) MalformedURLException(java.net.MalformedURLException) Field(java.lang.reflect.Field) MavenRemoteRepository(org.jboss.shrinkwrap.resolver.api.maven.repository.MavenRemoteRepository) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 4 with PomEquippedResolveStage

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);
    }
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) LifecycleException(org.apache.catalina.LifecycleException) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) Properties(java.util.Properties) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) PomEquippedResolveStage(org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage) File(java.io.File)

Example 5 with PomEquippedResolveStage

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;
}
Also used : MavenResolvedArtifact(org.jboss.shrinkwrap.resolver.api.maven.MavenResolvedArtifact) ArtifactSpec(org.wildfly.swarm.tools.ArtifactSpec) DeclaredDependencies(org.wildfly.swarm.tools.DeclaredDependencies) PomEquippedResolveStage(org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage)

Aggregations

PomEquippedResolveStage (org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage)9 File (java.io.File)8 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)4 WebSphereFixedJtaPlatform (org.jbpm.test.container.webspherefix.WebSphereFixedJtaPlatform)3 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)2 Field (java.lang.reflect.Field)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Stream (java.util.stream.Stream)1 PRIVATE (lombok.AccessLevel.PRIVATE)1 NoArgsConstructor (lombok.NoArgsConstructor)1 LifecycleException (org.apache.catalina.LifecycleException)1 Tomcat (org.apache.catalina.startup.Tomcat)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 ClassLoaderAsset (org.jboss.shrinkwrap.api.asset.ClassLoaderAsset)1