當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultArtifact類代碼示例

本文整理匯總了Java中org.apache.maven.artifact.DefaultArtifact的典型用法代碼示例。如果您正苦於以下問題:Java DefaultArtifact類的具體用法?Java DefaultArtifact怎麽用?Java DefaultArtifact使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultArtifact類屬於org.apache.maven.artifact包,在下文中一共展示了DefaultArtifact類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMissingParent

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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: setUp

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的package包/類
protected void setUp()
    throws Exception
{
    super.setUp();

    ArtifactHandler ah = new DefaultArtifactHandlerStub( "jar", null );
    VersionRange vr = VersionRange.createFromVersion( "1.1" );
    release = new DefaultArtifact( "test", "one", vr, Artifact.SCOPE_COMPILE, "jar", "sources", ah, false );
    artifacts.add( release );

    ah = new DefaultArtifactHandlerStub( "war", null );
    vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
    snap = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", null, ah, false );
    artifacts.add( snap );

    ah = new DefaultArtifactHandlerStub( "war", null );
    vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
    sources = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "sources", "sources", ah, false );

    // pick random output location
    Random a = new Random();
    outputFolder = new File( "target/copy" + a.nextLong() + "/" );
    outputFolder.delete();
    assertFalse( outputFolder.exists() );
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:26,代碼來源:TestDependencyUtil.java

示例3: includeDependencies

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的package包/類
protected void includeDependencies() {
    Stream<Artifact> artifacts;

    if (Boolean.TRUE.equals(listAllArtifacts)) {
        artifacts = project.getArtifacts().stream()
            .filter(artifact -> StringUtils.equals(artifact.getScope(), DefaultArtifact.SCOPE_PROVIDED));
    } else {
        artifacts = this.project.getDependencies().stream()
            .filter(dependency -> StringUtils.equals(dependency.getScope(), DefaultArtifact.SCOPE_PROVIDED))
            .map(this::toArtifact);
    }

    artifacts.map(Artifact::getId)
        .sorted()
        .map(io.syndesis.model.Dependency::maven)
        .forEachOrdered(extensionBuilder::addDependency);
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:18,代碼來源:GenerateMetadataMojo.java

示例4: isArtifactAvailableLocally

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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

示例5: setupArtifact

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的package包/類
@SuppressWarnings( "unchecked" )
void setupArtifact( String groupId, String artifactId, String goal, String type )
      throws DuplicateMojoDescriptorException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException {

   DefaultArtifact artifact = new DefaultArtifact( groupId, artifactId, "DUMMY", "compile", type, "", null );
   MojoDescriptor mojoDescriptor = new MojoDescriptor();
   mojoDescriptor.setGoal( goal );
   PluginDescriptor pluginDescriptor = new PluginDescriptor();
   pluginDescriptor.addMojo( mojoDescriptor );

   Plugin plugin = new Plugin();
   plugin.setGroupId( groupId );
   plugin.setArtifactId( artifactId );

   when( this.mojo.pluginManager.loadPlugin( eq( plugin ), anyList(), any( RepositorySystemSession.class ) ) ).thenReturn( pluginDescriptor );

   this.mojo.pluginDescriptor.getArtifactMap().put( String.format( "%s:%s", groupId, artifactId ), artifact );
}
 
開發者ID:ZsZs,項目名稱:FitNesseLauncher,代碼行數:19,代碼來源:SetupsMojoTestHelper.java

示例6: retrieveAvailableVersions

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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

示例7: extractArtifact

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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

示例8: testMojoLookup

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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

示例9: testMojoLookup

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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

示例10: filterVersionsWithIncludes

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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

示例11: testFindArtifactInRepository

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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

示例12: getDependencies

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的package包/類
/**
 * Collects dependencies, including transitives.
 * Project dependencies retain their scope, while test only dependencies (including transitives) will have test scope.
 * @param projectDependencies
 * @return
 */
private Set<Artifact> getDependencies(final Set<Artifact> projectDependencies) {
    Set<Artifact> result = new LinkedHashSet<Artifact>(projectDependencies);
    Set<Artifact> testDependencies = dependenciesWithScope(projectDependencies, Artifact.SCOPE_TEST);
    Set<Artifact> nonTestDependencies = allBut(projectDependencies, testDependencies);

    Set<Artifact> testTransitives = resolve(testDependencies);
    Set<Artifact> nonTestTransitives = resolve(nonTestDependencies);

    Set<Artifact> testOnlyDependencies = allBut(testTransitives, nonTestTransitives);

    for (Artifact testOnly : testOnlyDependencies) {
        result.add(new DefaultArtifact(testOnly.getGroupId(), testOnly.getArtifactId(), testOnly.getVersion(), Artifact.SCOPE_TEST, testOnly.getType(), testOnly.getClassifier(), testOnly
                .getArtifactHandler()));
    }

    result.addAll(resolve(projectDependencies));
    return result;
}
 
開發者ID:sundrio,項目名稱:sundrio,代碼行數:25,代碼來源:GenerateBomMojo.java

示例13: resolveDependencies

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的package包/類
private Map<Artifact, Dependency> resolveDependencies(BomImport bom) throws Exception {
    org.eclipse.aether.artifact.Artifact artifact = new org.eclipse.aether.artifact.DefaultArtifact(bom.getGroupId(), bom.getArtifactId(), "pom", bom.getVersion());

    List<RemoteRepository> repositories = remoteRepositories;
    if (bom.getRepository() != null) {
        // Include the additional repository into the copy
        repositories = new LinkedList<RemoteRepository>(repositories);
        RemoteRepository repo = new RemoteRepository.Builder(bom.getArtifactId() + "-repository", "default", bom.getRepository()).build();
        repositories.add(0, repo);
    }

    ArtifactRequest artifactRequest = new ArtifactRequest(artifact, repositories, null);
    system.resolveArtifact(session, artifactRequest); // To get an error when the artifact does not exist

    ArtifactDescriptorRequest req = new ArtifactDescriptorRequest(artifact, repositories, null);
    ArtifactDescriptorResult res = system.readArtifactDescriptor(session, req);

    Map<Artifact, Dependency> mavenDependencies = new LinkedHashMap<Artifact, Dependency>();
    if (res.getManagedDependencies() != null) {
        for (org.eclipse.aether.graph.Dependency dep : res.getManagedDependencies()) {
            mavenDependencies.put(toMavenArtifact(dep), toMavenDependency(dep));
        }
    }

    return mavenDependencies;
}
 
開發者ID:sundrio,項目名稱:sundrio,代碼行數:27,代碼來源:ExternalBomResolver.java

示例14: testExcludeArtifacts

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的package包/類
@Test
public void testExcludeArtifacts() throws Exception {

  final CheckMojo mojo = getMojo("exclude-dependencies");

  // inject some dependencies to exclude later
  mojo.project.setArtifacts(ImmutableSet.of(
      new DefaultArtifact("com.foobar", "bizbat", "1.2.3", "compile", "jar", "", null)
  ));

  mojo.execute();

  ArgumentCaptor<ImmutableList> toCheck = ArgumentCaptor.forClass(ImmutableList.class);

  verify(conflictChecker).check(
      any(Artifact.class),
      toCheck.capture(),
      anyListOf(Artifact.class)
  );

  assertThat(toCheck.getValue()).isEmpty();
}
 
開發者ID:spotify,項目名稱:missinglink,代碼行數:23,代碼來源:CheckMojoTest.java

示例15: filterVersionsWithIncludes

import org.apache.maven.artifact.DefaultArtifact; //導入依賴的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


注:本文中的org.apache.maven.artifact.DefaultArtifact類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。