org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependencies Java Examples

The following examples show how to use org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependencies. 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 File: KeycloakDependenciesResolver.java    From keycloak with 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 #2
Source File: ShrinkwrapArtifactResolvingHelper.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public MavenDependency createMavenDependency(final ArtifactSpec spec) {
    final MavenCoordinate newCoordinate = MavenCoordinates.createCoordinate(
            spec.groupId(),
            spec.artifactId(),
            spec.version(),
            PackagingType.of(spec.type()),
            spec.classifier());
    return MavenDependencies.createDependency(newCoordinate, ScopeType.fromScopeType(spec.scope), false);
}
 
Example #3
Source File: Utils.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
public static MavenDependency[] toMavenDependencies(String[] dependencies, String[] exclusions) {
    MavenDependencyExclusion[] mavenExclusions = toMavenExclusions(exclusions);
    MavenDependency[] mavenDependencies = new MavenDependency[dependencies.length];
    for (int i = 0; i < dependencies.length; i++) {
        mavenDependencies[i] = MavenDependencies.createDependency(
            dependencies[i],
            ScopeType.COMPILE,
            false,
            mavenExclusions);
    }
    return mavenDependencies;
}
 
Example #4
Source File: Utils.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
private static MavenDependencyExclusion[] toMavenExclusions(String[] exclusions) {
    MavenDependencyExclusion[] mavenExclusions = new MavenDependencyExclusion[exclusions.length];
    for (int i = 0; i < exclusions.length; i++) {
        mavenExclusions[i] = MavenDependencies.createExclusion(exclusions[i]);
    }
    return mavenExclusions;
}
 
Example #5
Source File: ResteasyTomcatServerBootstrap.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
protected void addRuntimeSpecificLibraries(WebArchive wa, PomEquippedResolveStage resolver) {
  // inject rest easy version to differentiate between resteasy and wildfly-compatibility profile
  String restEasyVersion = System.getProperty("restEasyVersion");

  wa.addAsLibraries(resolver.addDependencies(
    MavenDependencies.createDependency("org.jboss.resteasy:resteasy-jaxrs:" + restEasyVersion, ScopeType.TEST, false,
      MavenDependencies.createExclusion("org.apache.httpcomponents:httpclient"))).resolve()
    .withTransitivity().asFile());
}
 
Example #6
Source File: DeploymentHelper.java    From camunda-bpm-platform with 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 #7
Source File: WebArchiveBuilder.java    From krazo with Apache License 2.0 4 votes vote down vote up
public WebArchiveBuilder addDependency(String coordinates) {
    addDependencies(MavenDependencies.createDependency(coordinates, ScopeType.RUNTIME,false));
    return this;
}
 
Example #8
Source File: WebArchiveBuilder.java    From ozark with Apache License 2.0 4 votes vote down vote up
public WebArchiveBuilder addDependency(String coordinates) {
    addDependencies(MavenDependencies.createDependency(coordinates, ScopeType.RUNTIME,false));
    return this;
}
 
Example #9
Source File: TomcatServerBootstrap.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
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();

  // 1) Must not use shrinkwrap offline mode (see longer explanation at the end of the file)
  // 2) Must use configuration via Shrinkwrap Maven plugin (see pom.xml for plugin definition);
  //    This forwards things like the location of the settings.xml file to Shrinkwrap. We need
  //    that for our CI where settings.xml is not in the default location.
  PomEquippedResolveStage resolver = Maven.configureResolver()
    .useLegacyLocalRepo(true).configureViaPlugin();

  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);
  }
}