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