Java Code Examples for org.jboss.shrinkwrap.resolver.api.maven.Maven

The following examples show how to use org.jboss.shrinkwrap.resolver.api.maven.Maven. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: smallrye-metrics   Source File: ArchiveProcessor.java    License: Apache License 2.0 7 votes vote down vote up
@Override
public void process(TestDeployment testDeployment, Archive<?> protocolArchive) {
    WebArchive war = (WebArchive) protocolArchive;
    war.addAsWebInfResource("WEB-INF/jboss-web.xml", "jboss-web.xml");
    String[] deps = {
            "io.smallrye:smallrye-config",
            "io.smallrye:smallrye-metrics",
            "io.smallrye:smallrye-metrics-testsuite-common",
            "org.eclipse.microprofile.metrics:microprofile-metrics-api",
            "org.jboss.weld.servlet:weld-servlet-core"
    };

    File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity().asFile();

    war.addAsLibraries(dependencies);

    war.addClass(SmallRyeBeanArchiveHandler.class);
    war.addClass(MetricsHttpServlet.class);
    war.addClass(MetricsInitializer.class);
    war.addAsResource("io/smallrye/metrics/base-metrics.properties", "/io/smallrye/metrics/base-metrics.properties");
    war.addAsServiceProvider(BeanArchiveHandler.class, SmallRyeBeanArchiveHandler.class);
    war.addAsServiceProvider(Extension.class, ConfigExtension.class);
    war.addAsServiceProvider(ConfigProviderResolver.class, SmallRyeConfigProviderResolver.class);
}
 
Example 2
@Override
public void process(Archive<?> applicationArchive, TestClass testClass) {

    if (applicationArchive instanceof WebArchive) {
        WebArchive testDeployment = (WebArchive) applicationArchive;

        final File[] dependencies = Maven.resolver()
                .loadPomFromFile("pom.xml")
                .resolve("io.smallrye:smallrye-graphql-servlet")
                .withTransitivity()
                .asFile();
        // Make sure it's unique
        Set<File> dependenciesSet = new LinkedHashSet<>(Arrays.asList(dependencies));
        testDeployment.addAsLibraries(dependenciesSet.toArray(new File[] {}));
    }
}
 
Example 3
@Override
public void process(Archive<?> applicationArchive, TestClass testClass) {
    if (applicationArchive instanceof WebArchive) {
        WebArchive testDeployment = (WebArchive) applicationArchive;
        // Register SmallRyeBeanArchiveHandler using the ServiceLoader mechanism
        testDeployment.addClass(SmallRyeBeanArchiveHandler.class);
        testDeployment.addAsServiceProvider(BeanArchiveHandler.class, SmallRyeBeanArchiveHandler.class);

        String[] deps = {
                "io.smallrye:smallrye-health",
                "io.smallrye.config:smallrye-config",
                "io.smallrye:smallrye-health-tck",
                "org.eclipse.microprofile.health:microprofile-health-tck",
                "org.jboss.weld.servlet:weld-servlet-core" };

        File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity()
                .asFile();

        testDeployment.addAsLibraries(dependencies);
    }
}
 
Example 4
Source Project: tomee   Source File: MVCTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    File[] files = Maven.resolver()
                        .loadPomFromFile("pom.xml")
                        .importRuntimeDependencies()
                        .resolve()
                        .withTransitivity()
                        .asFile();

    return ShrinkWrap.create(WebArchive.class, "test.war")
                     .addPackages(true, "org.superbiz.mvc")
                     .addAsLibraries(files)
                     .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                     .addAsWebInfResource(new File("src/main/webapp/WEB-INF/web.xml"), "/web.xml")
                     .addAsWebInfResource(new File("src/main/webapp/WEB-INF/views/hello.jsp"), "/views/hello.jsp");
}
 
Example 5
Source Project: keycloak   Source File: KeycloakDependenciesResolver.java    License: Apache License 2.0 6 votes vote down vote up
public static File[] resolveDependencies(String canonicalForm) {
    if (dependencies.containsKey(canonicalForm)) {
        return dependencies.get(canonicalForm);
    }

    log.info("Resolving " + canonicalForm + "'s dependencies");
    PomEquippedResolveStage resolver = Maven.configureResolverViaPlugin();

    File[] files = resolver.addDependency(MavenDependencies.createDependency(canonicalForm, ScopeType.COMPILE, false))
            .resolve().withTransitivity().asFile();

    dependencies.put(canonicalForm, files);

    log.info("Resolving dependencies is finished with " + files.length + " files");

    return dependencies.get(canonicalForm);
}
 
Example 6
Source Project: taskana   Source File: TaskanaWildflyTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment(testable = false)
public static Archive<?> createTestArchive() {

  File[] files =
      Maven.resolver()
          .loadPomFromFile("pom.xml")
          .importRuntimeDependencies()
          .resolve()
          .withTransitivity()
          .asFile();

  return ShrinkWrap.create(WebArchive.class, "taskana.war")
      .addPackages(true, "pro.taskana")
      .addAsResource("taskana.properties")
      .addAsResource("application.properties")
      .addAsResource("project-defaults.yml")
      .addAsLibraries(files);
}
 
Example 7
Source Project: metrics-cdi   Source File: TimerFieldWithElNameBeanTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(EnterpriseArchive.class)
        .addAsLibraries(
            Maven.configureResolver()
                .workOffline()
                .loadPomFromFile("pom.xml")
                .resolve("io.astefanutti.metrics.cdi:metrics-cdi")
                .withTransitivity()
                .as(JavaArchive.class))
        .addAsLibrary(
            ShrinkWrap.create(JavaArchive.class)
                .addClass(TimerFieldWithElNameBean.class)
                .addClass(TimerIdBean.class)
                // FIXME: Test class must be added until ARQ-659 is fixed
                .addClass(TimerFieldWithElNameBeanTest.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"));
}
 
Example 8
@Deployment
public static WebArchive createArchive() {
    File[] files = Maven.resolver()
                        .loadPomFromFile("pom.xml")
                        .importRuntimeDependencies()
                        .resolve()
                        .withTransitivity()
                        .asFile();
    return ShrinkWrap.create(WebArchive.class)
                     .addClasses(EntityManagerProducer.class,
                                 DomainRoleEntryEntity.class,
                                 DomainRoleEntryManager.class,
                                 MasterRegistrationControlEntryEntity.class,
                                 MasterRegistrationControlEntryManager.class,
                                 JoynrConfigurationProvider.class)
                     .addAsLibraries(files)
                     .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
                     .addAsWebInfResource(new File("src/main/webapp/WEB-INF/beans.xml"));
}
 
Example 9
Source Project: ee8-sandbox   Source File: JsonbTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment(name = "test")
public static Archive<?> createDeployment() {
    File[] extraJars = Maven.resolver().loadPomFromFile("pom.xml")
            .resolve(
                    "com.jayway.jsonpath:json-path:2.4.0",
                    "com.google.code.gson:gson:2.8.2"
            )
            .withTransitivity()
            .asFile();
    WebArchive archive = ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(extraJars)
            .addPackage(Person.class.getPackage())
            //.addAsManifestResource("META-INF/test-persistence.xml", "persistence.xml")
            .addAsResource("persons.json")
            .addAsResource("person.json")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    // System.out.println(archive.toString(true));
    return archive;
}
 
Example 10
Source Project: ee8-sandbox   Source File: JsonpTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment(name = "test")
public static Archive<?> createDeployment() {
    File[] extraJars = Maven.resolver().loadPomFromFile("pom.xml")
            .resolve(
                    "com.jayway.jsonpath:json-path:2.4.0",
                    "com.google.code.gson:gson:2.8.2"
            )
            .withTransitivity()
            .asFile();

    WebArchive archive = ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(extraJars)
            .addPackage(Person.class.getPackage())
            //.addAsManifestResource("META-INF/test-persistence.xml", "persistence.xml")
            .addAsResource("persons.json")
            .addAsResource("person.json")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    // System.out.println(archive.toString(true));
    return archive;
}
 
Example 11
Source Project: camunda-bpm-platform   Source File: DeploymentHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static JavaArchive getEngineCdi() {
  if(CACHED_ENGINE_CDI_ASSET != null) {
    return CACHED_ENGINE_CDI_ASSET;
  } else {

    JavaArchive[] resolvedArchives = Maven.configureResolver()
        .workOffline()
        .loadPomFromFile("pom.xml")
        .resolve(CAMUNDA_ENGINE_CDI)
        .withTransitivity()
        .as(JavaArchive.class);

    if(resolvedArchives.length != 1) {
      throw new RuntimeException("could not resolve "+CAMUNDA_ENGINE_CDI);
    } else {
      CACHED_ENGINE_CDI_ASSET = resolvedArchives[0];
      return CACHED_ENGINE_CDI_ASSET;
    }
  }
}
 
Example 12
Source Project: deltaspike   Source File: ScopeNotStartedTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deploy()
{
    String simpleName = ScopeNotStartedTest.class.getSimpleName();
    String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "scopeNotStartedTest.jar")
            .addPackage(CustomSchedulerWarFileTest.class.getPackage().getName())
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
            .addAsResource(new StringAsset(MockedScheduler.class.getName()),
                    "META-INF/services/" + Scheduler.class.getName())
            .addAsResource(new StringAsset(CustomDeactivatedConfigSource.class.getName()),
                    "META-INF/services/" + ConfigSource.class.getName());

    return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndSchedulerArchive())
            .addAsLibraries(ArchiveUtils.getContextControlForDeployment())
            .addAsLibraries(Maven.resolver().loadPomFromFile("pom.xml").resolve(
                    "org.quartz-scheduler:quartz")
                    .withTransitivity()
                    .asFile())
            .addAsLibraries(testJar)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example 13
@Deployment(order = 1, testable = false, name = "elasticsearch-server.war")
public static WebArchive createElasticSearchServerDeployment() {
    File[] files = Maven.configureResolverViaPlugin()
        .resolve("org.elasticsearch.plugin:transport-netty4-client")
        .withoutTransitivity()
        .asFile();

    return ShrinkWrap.create(WebArchive.class, "elasticsearch-server.war")
        .addClasses(FileUtils.class, AvailablePortFinder.class, ElasticsearchServerServlet.class)
        .addAsLibraries(files)
        .setManifest(() -> {
            ManifestBuilder builder = new ManifestBuilder();
            builder.addManifestHeader("Dependencies",
                "org.elasticsearch,io.netty,com.carrotsearch.hppc,org.apache.logging.log4j,org.apache.lucene:8.0");
            return builder.openStream();
        });
}
 
Example 14
Source Project: thorntail   Source File: RestClientArchiveProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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.ext");

    log.fine("Augmented war: \n" + war.toString(true));
}
 
Example 15
@Deployment(testable = false)
public static Archive<?> createDeployment1() {
    final File[] files = Maven.resolver().resolve("net.java.xadisk:xadisk:jar:1.2.2").withoutTransitivity().asFile();
    final RARArchive deploymentRar = ShrinkWrap.create(RARArchive.class, "xadisk.rar");
    deploymentRar.as(RARArchive.class).resourceAdapter("", (rar) -> {
        rar.archive("xadisk-1.2.2.rar");
        rar.transactionSupport(TransactionSupport.XATRANSACTION);
        rar.configProperties(new ConfigProperties("xaDiskHome").value("diskHome"));
        rar.configProperties(new ConfigProperties("instanceId").value("instance1"));
        rar.connectionDefinitions("XADiskConnectionFactoryPool", (connDef) -> {
            connDef.className("org.xadisk.connector.outbound.XADiskManagedConnectionFactory");
            connDef.jndiName("java:global/XADiskCF");
            connDef.configProperties(new ConfigProperties("instanceId").value("instance1"));
        });
    });

    deploymentRar.addAsLibraries(files[0]);
    deploymentRar.setResourceAdapterXML("ra.xml");
    return deploymentRar;
}
 
Example 16
Source Project: windup   Source File: MavenizeRuleProviderTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Deployment
@AddonDependencies({
            @AddonDependency(name = "org.jboss.forge.furnace.container:cdi"),
            @AddonDependency(name = "org.jboss.windup.config:windup-config"),
            @AddonDependency(name = "org.jboss.windup.exec:windup-exec"),
            @AddonDependency(name = "org.jboss.windup.utils:windup-utils"),
            @AddonDependency(name = "org.jboss.windup.rules.apps:windup-rules-base"),
            @AddonDependency(name = "org.jboss.windup.rules.apps:windup-rules-java"),
            @AddonDependency(name = "org.jboss.windup.rules.apps:windup-rules-java-archives"),
            @AddonDependency(name = "org.jboss.windup.tests:test-util"),
})
public static AddonArchive getDeployment()
{
    // See https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc
    JavaArchive[] archives = Maven.resolver().resolve("org.jboss.windup.maven:nexus-indexer-data:zip:5").withoutTransitivity()
                .as(JavaArchive.class);
    Assert.assertEquals("maven-indexer-data found", 1, archives.length);
    AddonArchive deployment = ShrinkWrap.create(AddonArchive.class)
                .addBeansXML();
    for (JavaArchive archive : archives)
        deployment.merge(archive);
    return deployment;
}
 
Example 17
/**
 * @return a jar file containing all the required classes to test the {@link OpenShiftService}
 */
@Deployment(testable = true)
public static WebArchive createDeployment() {
    // Import Maven runtime dependencies
    final File[] dependencies = Maven.resolver().loadPomFromFile("pom.xml")
            .importRuntimeAndTestDependencies().resolve().withTransitivity().asFile();
    // Create deploy file
    final WebArchive war = ShrinkWrap.create(WebArchive.class)
            .addPackage(Fabric8OpenShiftServiceImpl.class.getPackage())
            .addPackage(OpenShiftServiceCdiIT.class.getPackage())
            .addPackage(OpenShiftService.class.getPackage())
            .addClass(DeleteOpenShiftProjectRule.class)
            .addClass(OpenShiftServiceSpi.class)
            .addClass(OpenShiftTestCredentials.class)
            .addClasses(OpenShiftCluster.class, OpenShiftClusterRegistry.class, OpenShiftClusterRegistryImpl.class, OpenShiftClusterConstructor.class)
            .addAsResource("openshift-project-template.json")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            .addAsWebInfResource("META-INF/jboss-deployment-structure.xml", "jboss-deployment-structure.xml")
            .addAsLibraries(dependencies);
    // Show the deployed structure
    log.info(war.toString(true));
    return war;
}
 
Example 18
Source Project: launchpad-missioncontrol   Source File: MissionControlIT.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @return a ear file containing all the required classes and dependencies
 * to test the {@link MissionControl}
 */
@Deployment(testable = true)
public static WebArchive createDeployment() {
    // Import Maven runtime dependencies
    final File[] dependencies = Maven.resolver().loadPomFromFile("pom.xml")
            .importRuntimeAndTestDependencies().resolve().withTransitivity().asFile();
    // Create deploy file
    final WebArchive war = ShrinkWrap.create(WebArchive.class)
            .addPackage(MissionControl.class.getPackage())
            .addPackage(MissionControlImpl.class.getPackage())
            .addPackage(GitHubTestCredentials.class.getPackage())
            .addAsWebInfResource("META-INF/jboss-deployment-structure.xml", "jboss-deployment-structure.xml")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            .addAsLibraries(dependencies);
    // Show the deployed structure
    log.info(war.toString(true));
    return war;
}
 
Example 19
Source Project: shiro-jwt   Source File: JWTOrFormAuthenticationFilterTest.java    License: MIT License 6 votes vote down vote up
@Deployment
public static Archive<?> deployment() {

    File[] filesCompile = Maven.resolver().loadPomFromFile("pom.xml").importDependencies(ScopeType.COMPILE).resolve().withTransitivity().asFile();
    File[] filestest = Maven.resolver().loadPomFromFile("pom.xml")
            .resolve("com.fasterxml.jackson.core:jackson-annotations", "com.fasterxml.jackson.core:jackson-databind", "com.fasterxml.jackson.core:jackson-core").withTransitivity().asFile();

    JavaArchive jar = ShrinkWrap.create(MavenImporter.class)
            .loadPomFromFile("pom.xml")
            .importBuildOutput()
            .as(JavaArchive.class);

    WebArchive war = ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(filestest)
            .addAsLibraries(jar)
            .addAsLibraries(filesCompile)
            .addClasses(UserDefaultExample.class, UserRepositoryExample.class)
            .addClasses(JAXRSConfigurationExample.class, ObjectMapperProviderExample.class, ResourceExample.class)
            .addAsWebInfResource("WEB-INF/test.shiro.ini", "shiro.ini")
            .addAsWebInfResource("WEB-INF/web.xml", "web.xml")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");

    System.out.println(war.toString(true));

    return war;
}
 
Example 20
Source Project: arquillian-container-chameleon   Source File: Resolver.java    License: Apache License 2.0 6 votes vote down vote up
public static File[] resolve(File cacheFolder, MavenDependency[] dependencies) {
    String hash = hash(dependencies);
    File[] files;

    File cacheFile = getCacheFile(cacheFolder, hash);
    if (cacheFile.exists()) {
        files = readCache(cacheFile);
    } else {
        files = Maven.configureResolver()
            .addDependencies(dependencies)
            .resolve()
            .withTransitivity()
            .asFile();

        writeCache(getCacheFile(cacheFolder, hash), files);
    }
    return files;
}
 
Example 21
public static WebArchive createSpecialtiesDeployment() {
    File[] deps = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withTransitivity().asFile();
    WebArchive war = null;
    try {
        war = ShrinkWrap.create(WebArchive.class, "specialties.war")
            .addClasses(SpecialtyController.class, LanguageBean.class,
                    SpecialtyDao.class, SpecialtyDaoImpl.class,
                    Owner.class, Pet.class, PetType.class,
                    Specialty.class, Vet.class, Visit.class)
            .merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                    .importDirectory(WEBAPP_SRC).as(GenericArchive.class),
                    "/", Filters.include(".*\\.xhtml$|.*\\.html$"))
            .addAsResource("META-INF/persistence.xml")
            .addAsResource("messages_de.properties")
            .addAsResource("messages_en.properties")
            .addAsLibraries(deps)
            .addAsWebInfResource(
                    new StringAsset("<faces-config version=\"2.2\"/>"),
                    "faces-config.xml");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return war;
}
 
Example 22
public static WebArchive createPetTypeDeployment() {
    File[] deps = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withTransitivity().asFile();
    return ShrinkWrap.create(WebArchive.class, "pettypes.war")
            .addClasses(PetTypeController.class, LanguageBean.class,
                    PetTypeDao.class, PetTypeDaoImpl.class,
                    Owner.class, Pet.class, PetType.class,
                    Specialty.class, Vet.class, Visit.class)
            .merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                    .importDirectory(WEBAPP_SRC).as(GenericArchive.class),
                    "/", Filters.include(".*\\.xhtml$|.*\\.html$"))
            .addAsResource("META-INF/persistence.xml")
            .addAsResource("messages_de.properties")
            .addAsResource("messages_en.properties")
            .addAsLibraries(deps)
            .addAsWebInfResource(
                    new StringAsset("<faces-config version=\"2.2\"/>"),
                    "faces-config.xml");
}
 
Example 23
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(EnterpriseArchive.class)
        .addAsLibraries(
            Maven.configureResolver()
                .workOffline()
                .loadPomFromFile("pom.xml")
                .resolve("io.astefanutti.metrics.cdi:metrics-cdi")
                .withTransitivity()
                .as(JavaArchive.class))
        .addAsModule(
            ShrinkWrap.create(JavaArchive.class)
                .addClass(CountedMethodScheduledBean.class)
                .addClass(CallCounter.class)
                // FIXME: Test class must be added until ARQ-659 is fixed
                .addClass(CountedMethodScheduledBeanTest.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"));
}
 
Example 24
Source Project: tomee   Source File: Enrichers.java    License: Apache License 2.0 6 votes vote down vote up
public static File[] resolve(final String pom) {
    if (!CACHE.containsKey(pom)) {
        try {

            // try offline first since it is generally faster
            CACHE.put(pom, Maven.resolver()
                    .offline(true)
                    .loadPomFromFile(pom)
                    .importCompileAndRuntimeDependencies().resolve().withTransitivity()
                    .asFile());
        } catch (ResolutionException re) { // try on central
            CACHE.put(pom, Maven.resolver()
                    .loadPomFromFile(pom)
                    .importCompileAndRuntimeDependencies().resolve().withTransitivity()
                    .asFile());
        }
    }
    return CACHE.get(pom);
}
 
Example 25
Source Project: metrics-cdi   Source File: TimedMethodWithElNameBeanTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(EnterpriseArchive.class)
        .addAsLibraries(
            Maven.configureResolver()
                .workOffline()
                .loadPomFromFile("pom.xml")
                .resolve("io.astefanutti.metrics.cdi:metrics-cdi")
                .withTransitivity()
                .as(JavaArchive.class))
        .addAsLibrary(
            ShrinkWrap.create(JavaArchive.class)
                .addClass(TimedMethodWithElNameBean.class)
                .addClass(TimerIdBean.class)
                // FIXME: Test class must be added until ARQ-659 is fixed
                .addClass(TimedMethodWithElNameBeanTest.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"));
}
 
Example 26
Source Project: jbang   Source File: shrinkwrap.java    License: MIT License 5 votes vote down vote up
@Override
public Integer call() throws Exception { // your business logic goes here...
    System.out.println("Hello " + greeting);

    ConfigurableMavenResolverSystem resolver = Maven.configureResolver()
            .withRemoteRepo("jcenter", "https://jcenter.bintray.com/", "default")
            .withMavenCentralRepo(false);
    
    //System.setProperty("maven.repo.local", Settings.getLocalMavenRepo().toPath().toAbsolutePath().toString());

    List<File> artifacts = resolver.resolve("log4j:log4j:1.2.17")
            .using(new MavenResolutionStrategy() {

                @Override
                public TransitiveExclusionPolicy getTransitiveExclusionPolicy() {
                    return new TransitiveExclusionPolicy() {
                        @Override
                        public boolean allowOptional() {
                            return true;
                        }

                        @Override
                        public ScopeType[] getFilteredScopes() {
                            return new ScopeType[]{ScopeType.PROVIDED, ScopeType.TEST};
                        }
                    };
                }

                @Override
                public MavenResolutionFilter[] getResolutionFilters() {
                    return new MavenResolutionFilter[0];
                }
            })
            .asList(File.class);

    artifacts.forEach(System.out::println);

    return CommandLine.ExitCode.OK;
}
 
Example 27
Source Project: jbang   Source File: DependencyUtil.java    License: MIT License 5 votes vote down vote up
public List<File> resolveDependenciesViaAether(List<String> depIds, List<MavenRepo> customRepos,
		boolean offline, boolean loggingEnabled) {

	ConfigurableMavenResolverSystem resolver = Maven.configureResolver()
													.withMavenCentralRepo(false)
													.workOffline(offline);

	customRepos.stream().forEach(mavenRepo -> {
		mavenRepo.apply(resolver);
	});

	System.setProperty("maven.repo.local", Settings.getLocalMavenRepo().toPath().toAbsolutePath().toString());

	return depIds.stream().flatMap(it -> {

		if (loggingEnabled)
			System.err.print(String.format("[jbang]     Resolving %s...", it));

		List<File> artifacts;
		try {
			artifacts = resolver.resolve(depIdToArtifact(it).toCanonicalForm())
								.withTransitivity()
								.asList(File.class); // , RUNTIME);
		} catch (RuntimeException e) {
			throw new ExitException(1, "Could not resolve dependency", e);
		}

		if (loggingEnabled)
			System.err.println("Done");

		return artifacts.stream();
	}).collect(Collectors.toList());
}
 
Example 28
Source Project: jbang   Source File: Jbang.java    License: MIT License 5 votes vote down vote up
static List<MavenCoordinate> findDeps(File pom) {
	// todo use to dump out pom dependencies
	return Maven.resolver()
				.loadPomFromFile(pom)
				.importCompileAndRuntimeDependencies()
				.resolve()
				.withoutTransitivity()
				.asList(MavenCoordinate.class);
}
 
Example 29
Source Project: camunda-bpm-platform   Source File: DeploymentHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static JavaArchive[] getEngineSpring() {
  if(CACHED_SPRING_ASSETS != null) {
    return CACHED_SPRING_ASSETS;
  } else {

    JavaArchive[] resolvedArchives = Maven.configureResolver()
        .workOffline()
        .loadPomFromFile("pom.xml")
        .addDependencies(
            MavenDependencies.createDependency("org.camunda.bpm:camunda-engine-spring", ScopeType.COMPILE, false,
                MavenDependencies.createExclusion("org.camunda.bpm:camunda-engine")),
                MavenDependencies.createDependency("org.springframework:spring-context", ScopeType.COMPILE, false),
                MavenDependencies.createDependency("org.springframework:spring-jdbc", ScopeType.COMPILE, false),
                MavenDependencies.createDependency("org.springframework:spring-tx", ScopeType.COMPILE, false),
                MavenDependencies.createDependency("org.springframework:spring-orm", ScopeType.COMPILE, false),
                MavenDependencies.createDependency("org.springframework:spring-web", ScopeType.COMPILE, false))
        .resolve()
        .withTransitivity()
        .as(JavaArchive.class);

    if(resolvedArchives.length == 0) {
      throw new RuntimeException("could not resolve org.camunda.bpm:camunda-engine-spring");
    } else {
      CACHED_SPRING_ASSETS = resolvedArchives;
      return CACHED_SPRING_ASSETS;
    }
  }

}
 
Example 30
Source Project: smallrye-jwt   Source File: SmallRyeJWTArchiveProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void process(Archive<?> applicationArchive, TestClass testClass) {
    if (applicationArchive instanceof WebArchive) {
        WebArchive war = (WebArchive) applicationArchive;
        war.addClass(OptionalAwareSmallRyeJWTAuthCDIExtension.class);
        war.addClass(SmallRyeJWTAuthJaxRsFeature.class);
        war.addAsServiceProvider(Extension.class, OptionalAwareSmallRyeJWTAuthCDIExtension.class);

        if (!war.contains("META-INF/microprofile-config.properties")) {
            war.addAsManifestResource("microprofile-config-local.properties", "microprofile-config.properties");
        }

        // A few tests require the apps to be deployed in the root. Check PublicKeyAsJWKLocationURLTest and PublicKeyAsPEMLocationURLTest
        // Both tests set the public key location url to be in root.
        war.addAsWebInfResource("jboss-web.xml");

        String[] deps = {
                "io.smallrye:smallrye-jwt",
                "io.smallrye.config:smallrye-config",
                "org.jboss.resteasy:resteasy-servlet-initializer",
                "org.jboss.resteasy:resteasy-jaxrs",
                "org.jboss.resteasy:resteasy-client",
                "org.jboss.resteasy:resteasy-cdi",
                "org.jboss.resteasy:resteasy-json-binding-provider",
                "org.jboss.weld.servlet:weld-servlet-core"
        };
        File[] dependencies = Maven.resolver()
                .loadPomFromFile(new File("pom.xml"))
                .resolve(deps)
                .withTransitivity()
                .asFile();

        war.addAsLibraries(dependencies);
    }
}