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


Java DefaultArtifactHandler类代码示例

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


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

示例1: testMissingParent

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
public void testMissingParent() throws Exception {
    TestFileUtils.writeFile(new File(getWorkDir(), "pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" +
        "<parent><groupId>g</groupId><artifactId>par</artifactId><version>0</version></parent>" +
        "<artifactId>m</artifactId>" +
        "</project>");
    Project p = ProjectManager.getDefault().findProject(FileUtil.toFileObject(getWorkDir()));
    assertEquals("g:m:jar:0", p.getLookup().lookup(NbMavenProject.class).getMavenProject().getId());
    ProblemReporterImpl pr = getReporter(p);
    MavenModelProblemsProvider mpp = new MavenModelProblemsProvider(p);
    Collection<? extends ProjectProblemsProvider.ProjectProblem> problems = mpp.getProblems();
    
    waitForReports();
    assertFalse(problems.isEmpty());
    
    assertEquals(Collections.singleton(a2f(new DefaultArtifact("g", "par", "0", null, "pom", null, new DefaultArtifactHandler("pom")))), pr.getMissingArtifactFiles());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ProblemReporterImplTest.java

示例2: isArtifactAvailableLocally

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
/**
 * Checks if an artifact is available in the local repository. The artifact <code>version</code>
 * must be a specific value, cannot be "LATEST".
 */
public static boolean isArtifactAvailableLocally(String groupId, String artifactId,
                                                 String version, String type,
                                                 String classifier) {
  try {
    Preconditions.checkArgument(!MAVEN_LATEST_VERSION.equals(version));
    String artifactPath =
        MavenPlugin.getMaven().getLocalRepository()
            .pathOf(new DefaultArtifact(groupId, artifactId, version, null /* scope */, type,
                                        classifier, new DefaultArtifactHandler(type)));
    return new File(artifactPath).exists();
  } catch (CoreException ex) {
    logger.log(Level.SEVERE, "Could not lookup local repository", ex);
    return false;
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:20,代码来源:MavenUtils.java

示例3: retrieveAvailableVersions

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
@NotNull
@Override
public List<String> retrieveAvailableVersions(@NotNull String groupId,
                                              @NotNull String artifactId,
                                              @NotNull List<MavenRemoteRepository> remoteRepositories)
  throws RemoteException {
  try {
    Artifact artifact =
      new DefaultArtifact(groupId, artifactId, "", Artifact.SCOPE_COMPILE, "pom", null, new DefaultArtifactHandler("pom"));
    List<ArtifactVersion> versions = getComponent(ArtifactMetadataSource.class)
      .retrieveAvailableVersions(
        artifact,
        getLocalRepository(),
        convertRepositories(remoteRepositories));
    return ContainerUtil.map(versions, new Function<ArtifactVersion, String>() {
      @Override
      public String fun(ArtifactVersion version) {
        return version.toString();
      }
    });
  }
  catch (Exception e) {
    Maven3ServerGlobals.getLogger().info(e);
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:Maven3ServerEmbedder.java

示例4: extractArtifact

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
/**
    * This returns a {@link DefaultArtifact} object with the same groupId,
    * artifactId, version and scope as the main artifact of the project
    * (for instance 'bw-ear' or 'projlib').
    * 
    * This {@link DefaultArtifact} will have its own {@link type} and
    * {@link classifier}.
    * 
    * @param a
    * @param type
    * @param classifier
    * @return
    */
private Artifact extractArtifact(Artifact a, String type, String classifier) {
	if (a == null) {
		return a;
	}

	Artifact result = new DefaultArtifact(a.getGroupId(),
			                              a.getArtifactId(),
			                              a.getVersionRange(),
			                              a.getScope(),
			                              type,
			                              classifier,
			                              new DefaultArtifactHandler(type));
	
	return result;
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:29,代码来源:AbstractBWArtifactMojo.java

示例5: testMojoLookup

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
public void testMojoLookup()
    throws Exception
{
    File pluginXml = new File( getBasedir(), "src/test/resources/linker/plugin-config-ranlib.xml" );
    NativeRanlibMojo mojo = (NativeRanlibMojo) lookupMojo( "ranlib", pluginXml );
    assertNotNull( mojo );

    // simulate artifact
    ArtifactHandler artifactHandler = new DefaultArtifactHandler();

    Artifact artifact =
        new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe",
                             null, artifactHandler );
    mojo.getProject().setArtifact( artifact );

    mojo.execute();
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:18,代码来源:NativeRanlibMojoTest.java

示例6: testMojoLookup

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
public void testMojoLookup()
    throws Exception
{
    File pluginXml = new File( getBasedir(), "src/test/resources/initialize/plugin-config.xml" );
    NativeInitializeMojo mojo = (NativeInitializeMojo) lookupMojo( "initialize", pluginXml );
    assertNotNull( mojo );

    // simulate artifact
    ArtifactHandler artifactHandler = new DefaultArtifactHandler();
    Artifact artifact =
        new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe",
                             null, artifactHandler );
    mojo.project.setArtifact( artifact );
    mojo.setPluginContext( new HashMap() );

    mojo.execute();

    assertEquals( "someArtifactId", mojo.project.getBuild().getFinalName() );
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:20,代码来源:NativeInitializeMojoTest.java

示例7: generateJSON

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
private void generateJSON(Set<FractionMetadata> fractions) {
    ObjectMapper mapper = new ObjectMapper();

    mapper.enable(SerializationFeature.INDENT_OUTPUT);

    File outFile = new File(this.project.getBuild().getOutputDirectory(), "fraction-list.json");

    try {
        mapper.writeValue(outFile, fractions);
    } catch (IOException e) {
        e.printStackTrace();
    }

    org.apache.maven.artifact.DefaultArtifact artifact = new org.apache.maven.artifact.DefaultArtifact(
            this.project.getGroupId(),
            this.project.getArtifactId(),
            this.project.getVersion(),
            "compile",
            "json",
            "",
            new DefaultArtifactHandler("json")
    );

    artifact.setFile(outFile);
    this.project.addAttachedArtifact(artifact);
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:27,代码来源:FractionListMojo.java

示例8: filterVersionsWithIncludes

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
private ArtifactVersion[] filterVersionsWithIncludes( ArtifactVersion[] newer, Artifact artifact )
{
    List<ArtifactVersion> filteredNewer = new ArrayList<>( newer.length );
    for ( int j = 0; j < newer.length; j++ )
    {
        ArtifactVersion artifactVersion = newer[j];
        Artifact artefactWithNewVersion =
            new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                                 VersionRange.createFromVersion( artifactVersion.toString() ), artifact.getScope(),
                                 artifact.getType(), null, new DefaultArtifactHandler(), false );
        if ( isIncluded( artefactWithNewVersion ) )
        {
            filteredNewer.add( artifactVersion );
        }
    }
    return filteredNewer.toArray( new ArtifactVersion[filteredNewer.size()] );
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:18,代码来源:UseLatestReleasesMojo.java

示例9: testFindArtifactInRepository

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
@Test
public void testFindArtifactInRepository() throws MojoExecutionException {
    GenerateMojo mojo = new GenerateMojo();
    mojo.setLog(new SystemStreamLog());

    Dependency dependency = mojo.findArtifactInRepository(
            new DefaultArtifact("org.spigotmc", "spigot-api", "1.8-R0.1-SNAPSHOT",
                                "compile", "jar", "jar", new DefaultArtifactHandler()),
            new MavenArtifactRepository("yawkat",
                                        "http://mvn.yawk.at",
                                        new DefaultRepositoryLayout(),
                                        new ArtifactRepositoryPolicy(),
                                        new ArtifactRepositoryPolicy())
    );
    Assert.assertNotNull(dependency);
}
 
开发者ID:yawkat,项目名称:mdep,代码行数:17,代码来源:GenerateMojoTest.java

示例10: filterVersionsWithIncludes

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
private ArtifactVersion[] filterVersionsWithIncludes( ArtifactVersion[] newer, Artifact artifact )
{
    List filteredNewer = new ArrayList( newer.length );
    for ( int j = 0; j < newer.length; j++ )
    {
        ArtifactVersion artifactVersion = newer[j];
        Artifact artefactWithNewVersion = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                                                               VersionRange.createFromVersion(
                                                                   artifactVersion.toString() ),
                                                               artifact.getScope(), artifact.getType(), null,
                                                               new DefaultArtifactHandler(), false );
        if ( isIncluded( artefactWithNewVersion ) )
        {
            filteredNewer.add( artifactVersion );
        }
    }
    return (ArtifactVersion[]) filteredNewer.toArray( new ArtifactVersion[filteredNewer.size()] );
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:19,代码来源:UseLatestReleasesMojo.java

示例11: getModelArtifact

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
/**
 * Generate an model Artifact
 *
 * @param groupId String
 * @param artifactId String
 * @param version String
 * @return Artifact
 */
private Artifact getModelArtifact(final String groupId, final String artifactId, final String version ){
    final DefaultArtifactHandler handler = new DefaultArtifactHandler();
    handler.setExtension("pom");

    final Artifact model = new DefaultArtifact(
            groupId,
            artifactId,
            version,
            null,
            "pom",
            null ,
            handler);

    return model;

}
 
开发者ID:Axway,项目名称:grapes-maven-plugin,代码行数:25,代码来源:LicenseResolver.java

示例12: findGwt

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
@Override
protected Pair<String, Boolean> findGwt(String cp, String cpSep) {
  VersionRange versions;
  try {
    versions = VersionRange.createFromVersionSpec("[2.5.0,)");
  } catch (InvalidVersionSpecificationException e) {
    throw X_Debug.rethrow(e);
  }

  ArtifactHandler artifactHandler = new DefaultArtifactHandler("default");
  Artifact gwtUser = new DefaultArtifact("com.google.gwt", "gwt-user", versions, "compile", "default", "jar",
      artifactHandler);
  // Check maven first
  Artifact local = getSession().getLocalRepository().find(gwtUser);
  if (local != null) {
    return PairBuilder.pairOf(local.getFile().getParentFile().getParent(), true);
  }
  return super.findGwt(cp, cpSep);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:20,代码来源:CodeServerMojo.java

示例13: getPluginDescriptor

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
public PluginDescriptor getPluginDescriptor(Plugin plugin) throws IOException, PlexusConfigurationException, Exception {
    synchronized (cache) {
        PluginDescriptor descriptor = (PluginDescriptor) cache.get(plugin.getKey());
        if (descriptor == null) {
            String version = plugin.getVersion();
            VersionRange range = null;
            if (version == null) {
                version = "LATEST";
                range = VersionRange.createFromVersionSpec(version);
            } else {
                range = VersionRange.createFromVersion(version);
            }
            DefaultArtifact pluginArtifact = new DefaultArtifact(plugin.getGroupId(), plugin.getArtifactId(), range, null, "jar", null, new DefaultArtifactHandler("jar"));
            descriptor = MavenArtifactResolver.getInstance().getPluginDescriptor(pluginArtifact);
            cache.put(plugin.getKey(), descriptor);
        }

        return descriptor;
    }
}
 
开发者ID:mulesoft,项目名称:mule-tooling-incubator,代码行数:21,代码来源:ProjectModelCache.java

示例14: root

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
/**
 * Convert dependency to root artifact.
 * @param dep Dependency
 * @return Root artifact
 */
private MavenRootArtifact root(final Dependency dep) {
    final DefaultArtifact artifact = new DefaultArtifact(
        dep.getGroupId(),
        dep.getArtifactId(),
        dep.getVersion(),
        dep.getScope(),
        dep.getType(),
        dep.getClassifier(),
        new DefaultArtifactHandler()
    );
    try {
        final Collection<Artifact> children = new LinkedList<Artifact>();
        for (final DependencyNode child : this.graph().getChildren()) {
            children.add(child.getArtifact());
        }
        return new MavenRootArtifact(
            artifact,
            dep.getExclusions(),
            children
        );
    } catch (final DependencyGraphBuilderException ex) {
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:30,代码来源:MavenClasspath.java

示例15: resolvesMavenRootArtifact

import org.apache.maven.artifact.handler.DefaultArtifactHandler; //导入依赖的package包/类
/**
 * MavenRootArtifact can resolve a root artifact.
 * @throws Exception If there is some problem inside
 */
@Test
@SuppressWarnings("unchecked")
public void resolvesMavenRootArtifact() throws Exception {
    final DefaultArtifact artifact = new DefaultArtifact(
        // @checkstyle MultipleStringLiteralsCheck (1 line)
        "junit", "junit", "4.10", "", "jar", "",
        new DefaultArtifactHandler()
    );
    final MavenRootArtifact root = new MavenRootArtifact(
        artifact,
        new ArrayList<Exclusion>(0),
        Collections.<Artifact>singleton(artifact)
    );
    MatcherAssert.assertThat(
        root,
        Matchers.hasToString(Matchers.containsString("junit:junit:4.10"))
    );
    MatcherAssert.assertThat(
        root.children(),
        Matchers.<Artifact>hasItems(
            Matchers.hasToString("junit:junit:jar:4.10:")
        )
    );
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:29,代码来源:MavenRootArtifactTest.java


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