当前位置: 首页>>代码示例>>Java>>正文


Java JavaScopes类代码示例

本文整理汇总了Java中org.sonatype.aether.util.artifact.JavaScopes的典型用法代码示例。如果您正苦于以下问题:Java JavaScopes类的具体用法?Java JavaScopes怎么用?Java JavaScopes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaScopes类属于org.sonatype.aether.util.artifact包,在下文中一共展示了JavaScopes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getArtifactsWithDep

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 *
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
public List<ArtifactResult> getArtifactsWithDep(String dependency,
    Collection<String> excludes) throws Exception {
  Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
  DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );
  PatternExclusionsDependencyFilter exclusionFilter =
      new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:27,代码来源:DependencyResolver.java

示例2: fetchArtifactWithDep

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep)
    throws DependencyResolutionException, ArtifactResolutionException {
  Artifact artifact = new DefaultArtifact(dep.getGroupArtifactVersion());

  DependencyFilter classpathFilter = DependencyFilterUtils
      .classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(
      dep.getExclusions());

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact,
      JavaScopes.COMPILE));

  collectRequest.addRepository(mavenCentral);
  collectRequest.addRepository(mavenLocal);
  for (Repository repo : repositories) {
    RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
    rr.setPolicy(repo.isSnapshot(), null);
    collectRequest.addRepository(rr);
  }

  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));

  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:DependencyContext.java

示例3: getArtifactsWithDep

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
  Collection<String> excludes) throws RepositoryException {
  Artifact artifact = new DefaultArtifact(dependency);
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
          new PatternExclusionsDependencyFilter(excludes);

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
          DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  try {
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
  } catch (NullPointerException | DependencyResolutionException ex) {
    throw new RepositoryException(
            String.format("Cannot fetch dependencies for %s", dependency), ex);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:32,代码来源:DependencyResolver.java

示例4: getArtifactsWithDep

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
    Collection<String> excludes) throws Exception {
  Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
      new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:SparkDependencyResolver.java

示例5: scope

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Default scopes.
 * @return List of scopes.
 */
private Collection<String> scope() {
    final List<String> scps;
    if (this.eclipseAether()) {
        scps = Arrays.asList(
            org.eclipse.aether.util.artifact.JavaScopes.COMPILE,
            org.eclipse.aether.util.artifact.JavaScopes.PROVIDED,
            org.eclipse.aether.util.artifact.JavaScopes.RUNTIME,
            org.eclipse.aether.util.artifact.JavaScopes.SYSTEM
        );
    } else {
        scps = Arrays.asList(
            JavaScopes.COMPILE,
            JavaScopes.RUNTIME,
            JavaScopes.PROVIDED,
            JavaScopes.SYSTEM
        );
    }
    return scps;
}
 
开发者ID:jcabi,项目名称:jcabi-maven-plugin,代码行数:24,代码来源:AjcMojo.java

示例6: buildsClasspath

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Classpath can build a classpath.
 * @throws Exception If there is some problem inside
 */
@Test
public void buildsClasspath() throws Exception {
    MatcherAssert.assertThat(
        new Classpath(
            this.project(
                this.dependency(
                    ClasspathTest.GROUP, ClasspathTest.GROUP, "4.10"
                )
            ), this.temp.newFolder(), JavaScopes.TEST
        ),
        Matchers.<File>hasItems(
            Matchers.hasToString(
                Matchers.endsWith(
                    String.format(
                        ClasspathTest.SDIR,
                        System.getProperty(ClasspathTest.FILE_SEP)
                    )
                )
            ),
            Matchers.hasToString(Matchers.endsWith("junit-4.10.jar")),
            Matchers.hasToString(Matchers.endsWith("hamcrest-core-1.1.jar"))
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:29,代码来源:ClasspathTest.java

示例7: buildsClasspathWithMoreScopes

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Classpath can build a classpath with more scopes.
 * @throws Exception If there is some problem inside
 */
@Test
public void buildsClasspathWithMoreScopes() throws Exception {
    final String artf = "jcabi-ssh";
    final String vrs = "1.5.2";
    MatcherAssert.assertThat(
        new Classpath(
            this.project(this.dependency("com.jcabi", artf, vrs)),
            this.temp.newFolder(), JavaScopes.TEST, JavaScopes.COMPILE
        ),
        Matchers.<File>hasItems(
            Matchers.hasToString(
                Matchers.endsWith(
                    String.format(
                        ClasspathTest.SDIR,
                        System.getProperty(ClasspathTest.FILE_SEP)
                    )
                )
            ),
            Matchers.hasToString(
                Matchers.endsWith(String.format("%s-%s.jar", artf, vrs))
            )
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:29,代码来源:ClasspathTest.java

示例8: buildsClasspathWithoutOptionalArtifacts

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Classpath can build a classpath without optional dependencies.
 * @throws Exception If there is some problem inside
 */
@Test
public void buildsClasspathWithoutOptionalArtifacts() throws Exception {
    final Dependency dep = new Dependency();
    // @checkstyle MultipleStringLiterals (2 lines)
    dep.setGroupId("commons-validator");
    dep.setArtifactId("commons-validator");
    dep.setVersion("1.3.1");
    dep.setScope(JavaScopes.COMPILE);
    MatcherAssert.assertThat(
        new Classpath(
            this.project(dep), this.temp.newFolder(), JavaScopes.COMPILE
        ),
        Matchers.not(
            Matchers.<File>hasItems(
                Matchers.hasToString(
                    Matchers.endsWith("oro-2.0.8.jar")
                )
            )
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:26,代码来源:ClasspathTest.java

示例9: hasToStringWithBrokenDependency

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Classpath can return a string when a dependency is broken.
 * @throws Exception If there is some problem inside
 */
@Test
public void hasToStringWithBrokenDependency() throws Exception {
    final Dependency dep = new Dependency();
    dep.setGroupId("junit-broken");
    dep.setArtifactId("junit-absent");
    dep.setVersion("1.0");
    dep.setScope(JavaScopes.TEST);
    final Classpath classpath = new Classpath(
        this.project(dep), this.temp.newFolder(), JavaScopes.TEST
    );
    MatcherAssert.assertThat(
        classpath.toString(),
        Matchers.containsString(
            "failed to load 'junit-broken:junit-absent:jar:1.0 (compile)'"
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:22,代码来源:ClasspathTest.java

示例10: comparesToAnotherClasspath

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Classpath can be compared to another classpath.
 * @throws Exception If there is some problem inside
 */
@Test
public void comparesToAnotherClasspath() throws Exception {
    final Dependency dep = new Dependency();
    dep.setGroupId("org.apache.commons");
    dep.setArtifactId("commons-lang3-absent");
    dep.setVersion("3.0");
    dep.setScope(JavaScopes.COMPILE);
    final Classpath classpath = new Classpath(
        this.project(dep), this.temp.newFolder(), JavaScopes.TEST
    );
    MatcherAssert.assertThat(classpath, Matchers.equalTo(classpath));
    MatcherAssert.assertThat(
        classpath.canEqual(classpath),
        Matchers.is(true)
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:21,代码来源:ClasspathTest.java

示例11: parsePom

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
public void parsePom(InputStream inputStream) {
    try {
        MavenXpp3Reader reader = new MavenXpp3Reader();

        Model model = reader.read(inputStream);

        if (dependencies == null) {
            dependencies = new LinkedList<>();
        }
        if (repositories == null) {
            repositories = new LinkedList<>();
        }

        parent = model.getParent();
        setPropertiesFromModel(this, model);

        for (org.apache.maven.model.Dependency dependency : model.getDependencies()) {
            if (!"test".equalsIgnoreCase(dependency.getScope())) {
                dependencies.add(new Dependency(new DefaultArtifact(
                        dependency.getGroupId(),
                        dependency.getArtifactId(),
                        dependency.getClassifier(),
                        "jar",
                        dependency.getVersion()
                ), JavaScopes.RUNTIME));
            }
        }

        for (Repository remoteRepository : model.getRepositories()) {
            repositories.add(new RemoteRepository(remoteRepository.getId(), "default", remoteRepository.getUrl()));
        }
    } catch (Exception ex) {
        LOGGER.error("Error while reading POM file", ex);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:36,代码来源:PomInformation.java

示例12: installBundleFromRepository

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
@Override
public BundleInformation installBundleFromRepository(String moduleId, boolean startBundle) {
    try {
        return installFromRepository(new Dependency(new DefaultArtifact(moduleId), JavaScopes.RUNTIME), startBundle);
    } catch (RepositoryException | IOException | BundleException e) {
        throw new MotechException("Unable to install module from repository " + moduleId, e);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:9,代码来源:ModuleAdminServiceImpl.java

示例13: shouldParsePomFile

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
@Test
public void shouldParsePomFile() throws IOException {
    Properties properties = new Properties();
    properties.put("test.properties", "test");
    properties.put("modules.root.dir", "${basedir}/../..");
    // Because we use <version> and <groupId> tags in our tested pom, the parsing method should add this as properties
    properties.put("project.version", "0-27-SNAPSHOT");
    properties.put("project.groupId", "testGroupId");

    Dependency dependency = new Dependency(new DefaultArtifact(
            "${project.groupId}",
            "motech-osgi-platform",
            "",
            "jar",
            "${project.version}"
    ), JavaScopes.RUNTIME);

    try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("pom/pom.xml")) {
        pomInformation = new PomInformation();
        pomInformation.parsePom(inputStream);
    }

    assertEquals(properties, pomInformation.getProperties());

    Parent parentFromParsing = pomInformation.getParent();
    assertEquals("0.27-SNAPSHOT", parentFromParsing.getVersion());
    assertEquals("motech", parentFromParsing.getArtifactId());
    assertEquals("org.motechproject", parentFromParsing.getGroupId());

    assertTrue(pomInformation.getDependencies().contains(dependency));
}
 
开发者ID:motech,项目名称:motech,代码行数:32,代码来源:PomInformationTest.java

示例14: resolveArtifacts

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
public List<Artifact> resolveArtifacts(Iterable<? extends Artifact> sourceArtifacts)
{
    CollectRequest collectRequest = new CollectRequest();
    for (Artifact sourceArtifact : sourceArtifacts) {
        collectRequest.addDependency(new Dependency(sourceArtifact, JavaScopes.RUNTIME));
    }
    for (RemoteRepository repository : repositories) {
        collectRequest.addRepository(repository);
    }

    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME));

    return resolveArtifacts(dependencyRequest);
}
 
开发者ID:airlift,项目名称:resolver,代码行数:15,代码来源:ArtifactResolver.java

示例15: transformGraph

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context )
    throws RepositoryException
{
    if ( findPlexusUtils( node ) == null )
    {
        Artifact pu = new DefaultArtifact( GID, AID, null, EXT, VER );
        DefaultDependencyNode child = new DefaultDependencyNode( new Dependency( pu, JavaScopes.RUNTIME ) );
        child.setRepositories( node.getRepositories() );
        child.setRequestContext( node.getRequestContext() );
        node.getChildren().add( child );
    }

    return node;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:15,代码来源:PlexusUtilsInjector.java


注:本文中的org.sonatype.aether.util.artifact.JavaScopes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。