use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project intellij-community by JetBrains.
the class Maven3ServerEmbedder method retrieveAvailableVersions.
@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();
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project maven-plugins by apache.
the class RemoteResourcesMojoTest method testSimpleBundles.
public void testSimpleBundles() throws Exception {
final MavenProjectResourcesStub project = createTestProject("default-simplebundles");
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.0" });
setupDefaultProject(project);
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.0"), null, "jar", "", new DefaultArtifactHandler()));
File file = new File(repo.getBasedir() + "/" + path + ".jar");
file.getParentFile().mkdirs();
buildResourceBundle("default-simplebundles-create", null, new String[] { "SIMPLE.txt" }, file);
mojo.execute();
file = (File) getVariableValueFromObject(mojo, "outputDirectory");
file = new File(file, "SIMPLE.txt");
assertTrue(file.exists());
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project maven-plugins by apache.
the class RemoteResourcesMojoTest method testFilteredBundles.
public void testFilteredBundles() throws Exception {
final MavenProjectResourcesStub project = createTestProject("default-filterbundles");
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.1" });
setupDefaultProject(project);
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.1"), null, "jar", "", new DefaultArtifactHandler()));
File file = new File(repo.getBasedir() + "/" + path + ".jar");
file.getParentFile().mkdirs();
buildResourceBundle("default-filterbundles-create", null, new String[] { "FILTER.txt.vm" }, file);
mojo.execute();
// executing a second time (example: forked lifecycle) should still work
mojo.execute();
file = (File) getVariableValueFromObject(mojo, "outputDirectory");
file = new File(file, "FILTER.txt");
assertTrue(file.exists());
String data = FileUtils.fileRead(file);
assertTrue(data.contains("2007"));
assertTrue(data.contains("default-filterbundles"));
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project maven-plugins by apache.
the class RemoteResourcesMojoTest method testSimpleBundlesWithClassifier.
public void testSimpleBundlesWithClassifier() throws Exception {
final MavenProjectResourcesStub project = createTestProject("default-simplebundles");
final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.0:jar:test" });
setupDefaultProject(project);
ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.0"), null, "jar", "test", new DefaultArtifactHandler()));
File file = new File(repo.getBasedir() + "/" + path + ".jar");
file.getParentFile().mkdirs();
buildResourceBundle("default-simplebundles-create", null, new String[] { "SIMPLE.txt" }, file);
mojo.execute();
file = (File) getVariableValueFromObject(mojo, "outputDirectory");
file = new File(file, "SIMPLE.txt");
assertTrue(file.exists());
}
use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project maven-plugins by apache.
the class TestSourcesMarkerFileHandler method setUp.
protected void setUp() throws Exception {
super.setUp();
ArtifactHandler ah = new DefaultArtifactHandler();
VersionRange vr = VersionRange.createFromVersion("1.1");
Artifact artifact = new DefaultArtifact("test", "1", vr, Artifact.SCOPE_COMPILE, "jar", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "2", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "3", vr, Artifact.SCOPE_TEST, "sources", "", ah, false);
artifacts.add(artifact);
artifact = new DefaultArtifact("test", "4", vr, Artifact.SCOPE_RUNTIME, "zip", "", ah, false);
artifacts.add(artifact);
// pick random output location
Random a = new Random();
outputFolder = new File("target/markers" + a.nextLong() + "/");
outputFolder.delete();
assertFalse(outputFolder.exists());
}
Aggregations