• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JavaScopes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: resolveDependencies

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Resolves dependencies transitively from the given jar artifact, with the specified Maven scope
 * (compile, runtime, and so on.)
 */
public DependencyResult resolveDependencies(GAV a, String scope) throws DependencyResolutionException {
    DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(scope);

    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new Dependency(new DefaultArtifact(a.toString()), JavaScopes.COMPILE));
    collectRequest.setRepositories(remoteRepositories);

    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);

    return resolveDependencies(dependencyRequest);
}
 
开发者ID:cloudbees,项目名称:bees-maven-components,代码行数:16,代码来源:RepositoryService.java


示例17: children

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Get all dependencies of this root artifact.
 * @return The list of artifacts
 * @throws DependencyResolutionException If fails to resolve
 */
@Cacheable(forever = true)
public Collection<Artifact> children()
    throws DependencyResolutionException {
    return this.aether.resolve(
        this.art, JavaScopes.COMPILE, new NonOptionalFilter()
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:13,代码来源:RootArtifact.java


示例18: execute

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public final void execute() throws MojoFailureException {
    StaticLoggerBinder.getSingleton().setMavenLog(this.getLog());
    final Aether aether = new Aether(
        this.project,
        this.session.getLocalRepository().getBasedir()
    );
    for (final String coord : this.coordinates) {
        Logger.info(this, "%s:", coord);
        try {
            final Collection<Artifact> deps = aether.resolve(
                new DefaultArtifact(coord),
                JavaScopes.RUNTIME
            );
            for (final Artifact dep : deps) {
                Logger.info(this, "    %s", dep);
            }
        } catch (final DependencyResolutionException ex) {
            throw new MojoFailureException(
                String.format("failed to resolve '%s'", coord),
                ex
            );
        }
    }
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:30,代码来源:RunMojo.java


示例19: findsAndLoadsArtifacts

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Aether can find and load artifacts.
 * @throws Exception If there is some problem inside
 */
@Test
public void findsAndLoadsArtifacts() throws Exception {
    final File local = this.temp.newFolder();
    final Aether aether = new Aether(this.project(), local);
    final Collection<DefaultArtifact> artifacts =
        new LinkedList<DefaultArtifact>(
            Arrays.asList(
                new DefaultArtifact("com.jcabi:jcabi-log:pom:1.0-SNAPSHOT"),
                new DefaultArtifact("log4j:log4j:jar:1.2.16")
            )
        );
    if (AetherTest.AWS_KEY != null) {
        artifacts.add(
            new DefaultArtifact(
                "com.jcabi.aether-test:parent:pom:1.0"
            )
        );
    }
    final Matcher<?> matcher = new CustomMatcher<String>("file exists") {
        @Override
        public boolean matches(final Object file) {
            return File.class.cast(file).exists();
        }
    };
    for (final Artifact artifact : artifacts) {
        MatcherAssert.assertThat(
            aether.resolve(artifact, JavaScopes.RUNTIME),
            Matchers.<Artifact>everyItem(
                Matchers.<Artifact>hasProperty("file", matcher)
            )
        );
    }
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:38,代码来源:AetherTest.java


示例20: resolvesArtifactsInParallelThreads

import org.sonatype.aether.util.artifact.JavaScopes; //导入依赖的package包/类
/**
 * Aether can resolve in parallel threads.
 * @throws Exception If there is some problem inside
 */
@Test
public void resolvesArtifactsInParallelThreads() throws Exception {
    final File local = this.temp.newFolder();
    final Aether aether = new Aether(this.project(), local);
    final int threads = Runtime.getRuntime().availableProcessors() * 5;
    final Artifact artifact = new DefaultArtifact(
        "com.jcabi:jcabi-assembly:pom:0.1.10"
    );
    final CountDownLatch start = new CountDownLatch(1);
    final CountDownLatch latch = new CountDownLatch(threads);
    final Runnable task = new VerboseRunnable(
        new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                start.await();
                MatcherAssert.assertThat(
                    aether.resolve(artifact, JavaScopes.RUNTIME),
                    Matchers.not(Matchers.<Artifact>empty())
                );
                latch.countDown();
                return null;
            }
        },
        true
    );
    final ExecutorService svc =
        Executors.newFixedThreadPool(threads, new VerboseThreads());
    for (int thread = 0; thread < threads; ++thread) {
        svc.submit(task);
    }
    start.countDown();
    MatcherAssert.assertThat(
        latch.await(2, TimeUnit.MINUTES),
        Matchers.is(true)
    );
    svc.shutdown();
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:42,代码来源:AetherTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PersistentLongFile类代码示例发布时间:2022-05-22
下一篇:
Java WriteContents类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap