本文整理汇总了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;
}
}
示例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() );
}
示例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 );
}
示例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();
}
示例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 );
}
示例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]);
}
示例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;
}
示例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;
}
示例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;
}
示例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() );
}
示例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;
}
示例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;
}
示例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() );
}
示例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;
}
示例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;
}