Package org.jboss.shrinkwrap.resolver.api.maven

Examples of org.jboss.shrinkwrap.resolver.api.maven.MavenResolverSystem


    /**
     * Resolves Maven dependency and writes it to the cache, so it can be reused next run
     */
    private void resolveMavenDependency(String missingDependency, File dir) {

        MavenResolverSystem resolver = getMavenResolver();

        JavaArchive[] dependencies;

        if (missingDependency.matches("^[^:]+:[^:]+:[^:]+")) {
            // resolution of the artifact without a version specified
            dependencies = resolver.resolve(missingDependency).withClassPathResolution(false).withTransitivity()
                    .as(JavaArchive.class);
        } else {
            // resolution of the artifact without a version specified
            dependencies = resolver.loadPomFromFile("pom.xml").resolve(missingDependency)
                    .withClassPathResolution(false).withTransitivity().as(JavaArchive.class);
        }

        for (JavaArchive archive : dependencies) {
            dir.mkdirs();
View Full Code Here


    private FakeServerInventory serverInventory;

    @Deployment(name = "platform", order = 1)
    protected static RhqAgentPluginArchive getPlatformPlugin() throws Exception {
        MavenResolverSystem mavenDependencyResolver = Maven.resolver();
        //check for system property specifiers before going to classpath
        String rhqPlatformPluginVersion = System.getProperty("rhq-platform-plugin.version");
        //complete maven gav construction.
        String platformPluginArtifact = "org.rhq:rhq-platform-plugin:jar:";
        if ((rhqPlatformPluginVersion == null) || rhqPlatformPluginVersion.trim().isEmpty()) {
            platformPluginArtifact += getRhqVersion();//got to classpath and MavenArtifactProperties
        } else {
            platformPluginArtifact += rhqPlatformPluginVersion;
        }

        return mavenDependencyResolver.offline().loadPomFromFile("pom.xml").resolve(platformPluginArtifact)
            .withoutTransitivity().asSingle(RhqAgentPluginArchive.class);
    }
View Full Code Here

        // This is the jar that was just built during the Maven package phase, just prior to this test getting run
        // during the Maven integration-test phase. This is exactly what we want, because it's the real Maven-produced
        // jar, freshly assembled from the classes being tested.
        File pluginJarFile = getPluginJarFile();
        System.out.println("Using plugin jar [" + pluginJarFile + "]...");
        MavenResolverSystem mavenDependencyResolver = Maven.resolver();
        // Pull in any required plugins from our pom's dependencies.

        Collection<RhqAgentPluginArchive> requiredPlugins = Arrays.asList(mavenDependencyResolver
            .loadPomFromFile("pom.xml").importRuntimeAndTestDependencies(new AcceptScopesStrategy(ScopeType.PROVIDED))
            .as(RhqAgentPluginArchive.class));

        return ShrinkWrap.create(ZipImporter.class, pluginJarFile.getName()).importFrom(pluginJarFile)
            .as(RhqAgentPluginArchive.class).withRequiredPluginsFrom(requiredPlugins);
View Full Code Here

        }
        String rhqPlatformPluginVersion = System.getProperty("rhq-platform-plugin.version");
        if ((rhqPlatformPluginVersion == null) || rhqPlatformPluginVersion.trim().isEmpty()) {
            rhqPlatformPluginVersion = projectVersion;
        }
        MavenResolverSystem earResolver = Resolvers.use(MavenResolverSystem.class);
        // this must be named rhq.ear because the "rhq" portion is used in the jndi names
        earResolver.offline();
        EnterpriseArchive testEar = ShrinkWrap.create(EnterpriseArchive.class, "rhq.ear");
        EnterpriseArchive rhqEar = earResolver.resolve("org.rhq:rhq-enterprise-server-ear:ear:" + projectVersion)
            .withoutTransitivity().asSingle(EnterpriseArchive.class);
        // merge rhq.ear into testEar but include only the EJB jars and the supporting libraries. Note that we
        // don't include the services sar because tests are responsible for prepare/unprepare of all required services,
        // we don't want the production services performing any unexpected work.
        testEar = testEar.merge(rhqEar, Filters.include("/lib.*|/rhq.*ejb3\\.jar.*|/rhq-server.jar.*"));
        // remove startup beans and shutdown listeners, we don't want this to be a full server deployment. The tests
        // start/stop what they need, typically with test services or mocks.
        testEar.delete(ArchivePaths
            .create("/rhq-server.jar/org/rhq/enterprise/server/core/StartupBean.class"));
        testEar.delete(ArchivePaths
            .create("/rhq-server.jar/org/rhq/enterprise/server/core/StartupBean$1.class"));
        testEar.delete(ArchivePaths
            .create("/rhq-server.jar/org/rhq/enterprise/server/core/ShutdownListener.class"));
        testEar.delete(ArchivePaths
            .create("/rhq-server.jar/org/rhq/enterprise/server/storage/StorageClusterSettingsManagerBean.class"));

        //replace the above startup beans with stripped down versions
        testEar.add(new ClassAsset(StrippedDownStartupBean.class), ArchivePaths
            .create("/rhq-server.jar/org/rhq/enterprise/server/test/StrippedDownStartupBean.class"));
        testEar.add(new ClassAsset(StrippedDownStartupBeanPreparation.class), ArchivePaths
            .create("/rhq-server.jar/org/rhq/enterprise/server/test/"
                + "StrippedDownStartupBeanPreparation.class"));
        testEar.add(new ClassAsset(FakeStorageClusterSettingsManagerBean.class), ArchivePaths
            .create("/rhq-server.jar/org/rhq/enterprise/server/storage/FakeStorageClusterSettingsManagerBean.class"));
        testEar.addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));

        // add the test classes to the deployment
        testEar.addAsLibrary(testClassesJar);

        // add the necessary AS7 dependency modules
        testEar.addAsManifestResource("jboss-deployment-structure.xml");

        // add the application xml declaring the ejb jars
        testEar.setApplicationXML("application.xml");

        // add additional 3rd party dependent jars needed to support test classes
        Collection<String> thirdPartyDeps = new ArrayList<String>();
        thirdPartyDeps.add("joda-time:joda-time");
        thirdPartyDeps.add("org.jboss.shrinkwrap:shrinkwrap-impl-base");
        thirdPartyDeps.add("org.liquibase:liquibase-core");
        thirdPartyDeps.add("org.powermock:powermock-api-mockito");
        thirdPartyDeps.add("org.rhq.helpers:perftest-support:" + projectVersion);
        thirdPartyDeps.add("org.rhq:rhq-core-client-api:jar:tests:" + rhqCoreClientApiVersion);
        thirdPartyDeps.add("org.rhq:rhq-platform-plugin:jar:" + rhqPlatformPluginVersion);

        thirdPartyDeps.add("org.rhq:test-utils:" + projectVersion);

        MavenResolverSystem resolver = Maven.resolver();

        Collection<JavaArchive> dependencies = new HashSet<JavaArchive>();
        dependencies.addAll(Arrays.asList(resolver.loadPomFromFile("pom.xml").resolve(thirdPartyDeps)
            .withTransitivity().as(JavaArchive.class)));

        // If we're running oracle we need to include the OJDBC driver because dbunit needs it. Note that we need
        // add it explicitly even though it is a provided module used by the datasource.
        if (!Boolean.valueOf(System.getProperty("rhq.skip.oracle"))) {
            // in proxy situations (like Jenkins) shrinkwrap won't be able to find repositories defined in
            // settings.xml profiles.  We know at this point the driver is in the local repo, try going offline
            // at this point to force local repo resolution since the oracle driver is not in public repos.
            // see http://stackoverflow.com/questions/6291146/arquillian-shrinkwrap-mavendependencyresolver-behind-proxy
            // Last verified this problem using: Arquillian 1.0.3 bom
            resolver.offline();
            dependencies.addAll(Arrays.asList(resolver
                .resolve("com.oracle:ojdbc6:jar:" + System.getProperty("rhq.ojdbc.version")).withTransitivity()
                .as(JavaArchive.class)));
        }

        // Transitive test dep required by rhq-core-client-api above and for some reason not sucked in.
        // TODO: pass in version from pom property
        dependencies.addAll(Arrays.asList(resolver.resolve("commons-jxpath:commons-jxpath:1.3").withTransitivity()
            .as(JavaArchive.class)));

        // exclude any transitive deps we don't want
        String[] excludeFilters = { "testng.*jdk", "rhq-core-domain.*jar" };
        dependencies = exclude(dependencies, excludeFilters);
View Full Code Here

        thirdPartyDeps.add("commons-codec:commons-codec");
        thirdPartyDeps.add("commons-io:commons-io");
        thirdPartyDeps.add("org.unitils:unitils-testng:3.1");
        thirdPartyDeps.add("org.rhq:rhq-core-dbutils:" + System.getProperty("project.version")); // needed by SetupBean

        MavenResolverSystem resolver = Maven.resolver();

        Collection<JavaArchive> dependencies = new HashSet<JavaArchive>();
        dependencies.addAll(Arrays.asList(resolver.loadPomFromFile("pom.xml").resolve(thirdPartyDeps)
            .withTransitivity().as(JavaArchive.class)));

        String[] excludeFilters = { "testng.*jdk" };

        dependencies = exclude(dependencies, excludeFilters);
View Full Code Here

      return artifacts;
   }

   private File[] resolveArtifact(final String artifact)
   {
      MavenResolverSystem resolver;

      final String alternateMavenSettings = System.getProperty(MVN_ALTERNATE_SETTINGS);
      if (alternateMavenSettings == null)
      {
         resolver = Maven.resolver();
      }
      else
      {
         resolver = Maven.configureResolver().fromFile(alternateMavenSettings);
      }

      if (mavenIsUsed())
      {
         resolver.loadPomFromFile(POM_XML);
      }

      return resolver.resolve(artifact).withTransitivity().asFile();
   }
View Full Code Here

        new ValidationUtil("test-deps-a-1.0.0.jar", "test-deps-c-1.0.0.jar", "test-deps-b-1.0.0.jar").validate(files);
    }

    @Test
    public void testMavenSystemResolverAsSessionContainer() {
        MavenResolverSystem resolver = Maven.resolver();
        resolver.resolve("org.jboss.shrinkwrap.test:test-deps-a:1.0.0");

        List<MavenDependency> dependencies = ((MavenWorkingSessionContainer) resolver).getMavenWorkingSession()
                .getDependenciesForResolution();
        Assert.assertEquals("There is one dependency to be resolved", 1, dependencies.size());
        Assert.assertEquals("Dependency artifactId to be resolved matches", "test-deps-a", dependencies.iterator().next()
View Full Code Here

TOP

Related Classes of org.jboss.shrinkwrap.resolver.api.maven.MavenResolverSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.