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


Java Artifact類代碼示例

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


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

示例1: isMarkerOlder

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
public boolean isMarkerOlder( Artifact artifact1 )
    throws MojoExecutionException
{
    File marker = getMarkerFile();
    if ( marker.exists() )
    {
    	long artifactLastModified = artifact1.getFile().lastModified();
    	long markerLastModified = marker.lastModified();
        return artifact1.getFile().lastModified() > marker.lastModified();
    }
    else
    {
        // if the marker doesn't exist, we want to copy so assume it is
        // infinately older
        return true;
    }
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:18,代碼來源:DefaultFileMarkerHandler.java

示例2: testBothMarkers

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
public void testBothMarkers()
    throws MojoExecutionException
{
    DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 1 ),
                                                                     this.outputFolder, true );
    DefaultFileMarkerHandler handler2 = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 1 ),
                                                                      this.outputFolder, false );

    handler.setMarker();
    assertTrue( handler.isMarkerSet() );
    assertTrue( handler2.isMarkerSet() );

    handler2.clearMarker();
    assertFalse( handler.isMarkerSet() );
    assertFalse( handler2.isMarkerSet() );
    outputFolder.delete();
    assertFalse( outputFolder.exists() );
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:19,代碼來源:TestSourcesMarkerFileHandler.java

示例3: testExcludeArtifactItemOverride

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
public void testExcludeArtifactItemOverride()
throws Exception
{
	Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
    ArtifactItem item = stubFactory.getArtifactItem( artifact );
    item.setExcludes("**/*");
    ArrayList list = new ArrayList( 1 );
    list.add( item );
    mojo.setArtifactItems( list ); 
    mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX );
	mojo.execute();
	assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
	assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
	assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
	assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:17,代碼來源:TestIncludeExcludeUnpackMojo.java

示例4: readMavenProject

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
private static MavenProject readMavenProject(MavenEmbedder embedder, Artifact artifact, List<ArtifactRepository> remoteRepos) throws  ProjectBuildingException {
    ProjectBuilder bldr = embedder.lookupComponent(ProjectBuilder.class);
    assert bldr !=null : "ProjectBuilder component not found in maven";
    DefaultMaven maven = (DefaultMaven) embedder.lookupComponent(Maven.class);
    assert bldr !=null : "DefaultMaven component not found in maven";
    
    MavenExecutionRequest req = embedder.createMavenExecutionRequest();
    req.setLocalRepository(embedder.getLocalRepository());
    req.setRemoteRepositories(remoteRepos);

    ProjectBuildingRequest configuration = req.getProjectBuildingRequest();
    configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
    configuration.setResolveDependencies(true);
    configuration.setRepositorySession(maven.newRepositorySession(req));
    ProjectBuildingResult projectBuildingResult = bldr.build(artifact, configuration);
    return projectBuildingResult.getProject();    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:ArtifactMultiViewFactory.java

示例5: testIncludeArtifactItemOverride

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
public void testIncludeArtifactItemOverride()
	throws Exception
{
	Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
    ArtifactItem item = stubFactory.getArtifactItem( artifact );
    item.setIncludes("**/*");
    ArrayList list = new ArrayList( 1 );
    list.add( item );
    mojo.setArtifactItems( list ); 
    mojo.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX );
	mojo.execute();
	assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
	assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
	assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
	assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:17,代碼來源:TestIncludeExcludeUnpackMojo.java

示例6: NBMWrapper

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
public NBMWrapper(Artifact art, Set<String> allPackages, String[] publicPackages, String[] friends, String[] mavenCP) {
    super(art, allPackages);
    this.friends = friends != null ? Arrays.asList(friends) : Collections.<String>emptyList();
    this.mavenCP = mavenCP != null ? Arrays.asList(mavenCP) : Collections.<String>emptyList();
    Set<String> packs = new HashSet<String>();
    if (publicPackages == null) {
        //no public packages.
    } else {
        for (String pub : publicPackages) {
            pub = pub.trim();
            packs.add(pub);
            if (pub.endsWith(".**")) {
                String sub = pub.substring(0, pub.length() - ".**".length());
                subPublic.add(sub);
            } else if (pub.endsWith(".*")) {
                String eq = pub.substring(0, pub.length() - ".*".length());
                eqPublic.add(eq);
            }
        }
    }
    this.publicPackages = packs.toArray(new String[0]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:MavenWhiteListQueryImpl.java

示例7: filter

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
public Set filter( Set artifacts )
    throws ArtifactFilterException
{
    Set result = new HashSet();

    Iterator iter = artifacts.iterator();
    
    while ( iter.hasNext() )
    {
        Artifact artifact = (Artifact) iter.next();
        if ( isArtifactIncluded( new ArtifactItem( artifact ) ) )
        {
            result.add( artifact );
        }
    }
    return result;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:18,代碼來源:DestFileFilter.java

示例8: getJsonDependencies

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
public static ArrayNode getJsonDependencies(List<Artifact> artifacts, List<Dependency> directDependencies) {
    HashMap<String, String> requirements = new HashMap<String, String>(directDependencies.size());
    for (Dependency dep : directDependencies) {
        requirements.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion());
    }

    ObjectMapper mapper = new ObjectMapper();
    ArrayNode arrayNode = mapper.createArrayNode();
    for (Artifact art : artifacts) {
        ObjectNode artNode = depToJsonNode(mapper, art);
        String requirement;
        requirement = requirements.get(art.getGroupId() + ":" + art.getArtifactId());
        // Temporary workaround for transitive dependencies
        if (requirement == null){
            requirement = art.getVersion();
        }
        artNode.put("requirement", requirement);
        arrayNode.add(artNode);
    }
    return arrayNode;
}
 
開發者ID:gemnasium,項目名稱:gemnasium-maven-plugin,代碼行數:22,代碼來源:ProjectsUtils.java

示例9: getResult

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
FixDescription getResult() {
    FixDescription res = new FixDescription();
    res.isSet = addSetCheck.isSelected();
    res.version2Set = res.isSet ? (ArtifactVersion) versionList.getSelectedValue() : null;
    res.isExclude = excludeCheck.isSelected();
    if (res.isExclude) {
        res.exclusionTargets = new HashSet<Artifact>();
        res.conflictParents = new HashSet<MavenDependencyNode>();
        ListModel lm = excludesList.getModel();
        for (int i = 0; i < lm.getSize(); i++) {
            ExclTargetEntry entry = (ExclTargetEntry) lm.getElementAt(i);
            if (entry.isSelected) {
                res.exclusionTargets.add(entry.artif);
                res.conflictParents.addAll(eTargets.getConflictParents(entry.artif));
            }
        }
    }
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:FixVersionConflictPanel.java

示例10: testMarkerTimeStamp

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
public void testMarkerTimeStamp()
    throws MojoExecutionException, IOException, InterruptedException
{
    File theFile = new File( outputFolder, "theFile.jar" );
    outputFolder.mkdirs();
    theFile.createNewFile();
    Artifact theArtifact = (Artifact) artifacts.get( 0 );
    theArtifact.setFile( theFile );
    DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( theArtifact, this.outputFolder );
    assertFalse( handler.isMarkerSet() );
    // if the marker is not set, assume it is infinately older than the
    // artifact.
    assertTrue( handler.isMarkerOlder( theArtifact ) );
    handler.setMarker();
    assertFalse( handler.isMarkerOlder( theArtifact ) );

    theFile.setLastModified( theFile.lastModified() + 60000 );
    assertTrue( handler.isMarkerOlder( theArtifact ) );

    theFile.delete();
    handler.clearMarker();
    assertFalse( handler.isMarkerSet() );
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:24,代碼來源:TestDefaultMarkerFileHandler.java

示例11: showDependencyExcludeDialog

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
@Messages("TIT_Exclude=Add Dependency Excludes")
public static Map<Artifact, List<Artifact>> showDependencyExcludeDialog(Project prj) {
    NbMavenProject nbproj = prj.getLookup().lookup(NbMavenProject.class);
    final ExcludeDependencyPanel pnl = new ExcludeDependencyPanel(nbproj.getMavenProject());
    DialogDescriptor dd = new DialogDescriptor(pnl, TIT_Exclude());
    pnl.setStatusDisplayer(dd.createNotificationLineSupport());
    Object ret = DialogDisplayer.getDefault().notify(dd);
    if (ret == DialogDescriptor.OK_OPTION) {
        Map<Artifact, List<DependencyNode>> dependencyExcludes = pnl.getDependencyExcludes();
        Map<Artifact, List<Artifact>> toRet = new HashMap<Artifact, List<Artifact>>();
        for (Artifact exclude : dependencyExcludes.keySet()) {
            List<DependencyNode> directs = dependencyExcludes.get(exclude);
            List<Artifact> dirArts = new ArrayList<Artifact>();
            for (DependencyNode nd : directs) {
                dirArts.add(nd.getArtifact());
            }
            if (dirArts.size() > 0) {
                toRet.put(exclude, dirArts);
            }
        }
        return toRet;
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:DialogFactory.java

示例12: depToJsonNode

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
private static ObjectNode depToJsonNode(ObjectMapper mapper, Artifact art) {
    List<String> parents = getDependencyParents(new ArrayList<String>(art.getDependencyTrail()));

    ObjectNode jsonNode = mapper.createObjectNode();
    jsonNode.put("groupId", art.getGroupId());
    jsonNode.put("artifactId", art.getArtifactId());
    jsonNode.put("type", art.getType());
    jsonNode.put("classifier", art.getClassifier());
    jsonNode.put("version", art.getVersion());
    jsonNode.put("scope", art.getScope());
    jsonNode.put("transitive", !parents.isEmpty());
    jsonNode.set("parents", mapper.valueToTree(parents));
    jsonNode.put("optional", art.isOptional());

    return jsonNode;
}
 
開發者ID:gemnasium,項目名稱:gemnasium-maven-plugin,代碼行數:17,代碼來源:ProjectsUtils.java

示例13: setUp

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

示例14: list

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
Collection<DependencyWrapper> list(boolean longLiving) {  
    HashSet<DependencyWrapper> lst;
    MavenProject mp = project.getOriginalMavenProject();
    Set<Artifact> arts = mp.getArtifacts();
    switch (type) {
        case COMPILE:
        case TEST:
        case RUNTIME:
            lst = create(arts, longLiving, type.artifactScopes());
            break;
        default:
            lst = create(arts, longLiving, (a) -> !a.getArtifactHandler().isAddedToClasspath());
    }
    //#200927 do not use comparator in treeset, comparator not equivalent to equals/hashcode
    ArrayList<DependencyWrapper> l = new ArrayList<>(lst);
    Collections.sort(l, new DependenciesComparator());
    return l;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:DependenciesNode.java

示例15: create

import org.apache.maven.artifact.Artifact; //導入依賴的package包/類
private HashSet<DependencyWrapper> create(Set<Artifact> arts, boolean longLiving, Function<Artifact, Boolean> accept) {
    HashSet<DependencyWrapper> lst = new HashSet<>();
    for (Artifact a : arts) {
        if (accept.apply(a)) {
            URL url = FileUtil.urlForArchiveOrDir(a.getFile());
            String name = url != null ? SourceUtils.getModuleName(url) : null;
            if(name != null) {
                LOG.log(Level.FINE, "Artifact {0} has module name ''{1}''", new Object[]{url, name}); // NOI18N
                lst.add(new DependencyWrapper(a, longLiving, () -> moduleInfoSupport != null ? moduleInfoSupport.canAddToModuleInfo(name) : false));
            } else {
                LOG.log(Level.WARNING, "Could not determine module name for artifact {0}", new Object[]{url}); // NOI18N
            }
        }
    }
    return lst;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:DependenciesNode.java


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