use of org.apache.maven.artifact.repository.DefaultArtifactRepository in project intellij-community by JetBrains.
the class Maven2ServerEmbedderImpl 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, VersionRange.createFromVersion(""), Artifact.SCOPE_COMPILE, "pom", null, new DefaultArtifactHandler("pom"));
ArtifactRepositoryLayout repositoryLayout = getComponent(ArtifactRepositoryLayout.class);
List versions = getComponent(ArtifactMetadataSource.class).retrieveAvailableVersions(artifact, new DefaultArtifactRepository("local", getLocalRepositoryFile().getPath(), repositoryLayout), convertRepositories(remoteRepositories));
List<String> result = new ArrayList<String>();
for (Object version : versions) {
result.add(version.toString());
}
return result;
} catch (Exception e) {
Maven2ServerGlobals.getLogger().info(e);
}
return Collections.emptyList();
}
use of org.apache.maven.artifact.repository.DefaultArtifactRepository in project intellij-community by JetBrains.
the class MavenEmbedder method createLocalRepository.
private ArtifactRepository createLocalRepository(MavenEmbedderSettings generalSettings) {
ArtifactRepositoryLayout layout = getComponent(ArtifactRepositoryLayout.class, "default");
ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
String url = mySettings.getLocalRepository();
if (!url.startsWith("file:"))
url = "file://" + url;
ArtifactRepository localRepository = new DefaultArtifactRepository("local", url, layout);
boolean snapshotPolicySet = mySettings.isOffline();
if (!snapshotPolicySet && generalSettings.getSnapshotUpdatePolicy() == MavenEmbedderSettings.UpdatePolicy.ALWAYS_UPDATE) {
factory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
}
factory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
return localRepository;
}
use of org.apache.maven.artifact.repository.DefaultArtifactRepository in project maven-plugins by apache.
the class BundlePackMojoTest method testPack_RemoveOne.
public void testPack_RemoveOne() throws Exception {
File testPom = new File(getBasedir(), "src/test/resources/unit/bundle-pack/pom.xml");
BundlePackMojo mojo = (BundlePackMojo) lookupMojo("bundle-pack", testPom);
URL repoURL = new File(getBasedir(), "src/test/resources/repo").toURL();
mojo.localRepository = new DefaultArtifactRepository("test", repoURL.toString(), new DefaultRepositoryLayout());
// NOTE: This is sensitive to the lookupMojo method timing...
TestInputHandler ih = (TestInputHandler) lookup(InputHandler.ROLE, "default");
Stack<String> responses = new Stack<String>();
responses.push("3");
ih.setLineResponses(responses);
File generatedFilesDir = new File(getBasedir(), "target/bundle-pack-tests");
mojo.basedir = generatedFilesDir.getAbsolutePath();
mojo.execute();
File bundleSource = new File(generatedFilesDir, "testartifact-1.0-bundle.jar");
Set<String> entryNames = new HashSet<String>();
entryNames.add("testartifact-1.0-javadoc.jar");
entryNames.add("testartifact-1.0.jar");
entryNames.add("pom.xml");
entryNames.add("META-INF/MANIFEST.MF");
entryNames.add("META-INF/");
Set<String> bannedNames = new HashSet<String>();
// determined experimentally, so this could change!
bannedNames.add("testartifact-1.0-sources.jar");
assertZipContents(entryNames, bannedNames, bundleSource);
}
use of org.apache.maven.artifact.repository.DefaultArtifactRepository in project maven-plugins by apache.
the class BundlePackMojoTest method testPack_PomPackaging.
public void testPack_PomPackaging() throws Exception {
File testPom = new File(getBasedir(), "src/test/resources/unit/bundle-pack-parent/pom.xml");
BundlePackMojo mojo = (BundlePackMojo) lookupMojo("bundle-pack", testPom);
URL repoURL = new File(getBasedir(), "src/test/resources/repo").toURL();
mojo.localRepository = new DefaultArtifactRepository("test", repoURL.toString(), new DefaultRepositoryLayout());
File generatedFilesDir = new File(getBasedir(), "target/bundle-pack-parent-tests");
mojo.basedir = generatedFilesDir.getAbsolutePath();
// NOTE: This is sensitive to the lookupMojo method timing...
TestInputHandler ih = (TestInputHandler) lookup(InputHandler.ROLE, "default");
Stack<String> responses = new Stack<String>();
responses.push("http://foo/");
responses.push("scm:svn:http://foo/");
responses.push("2,3");
responses.push("0");
ih.setLineResponses(responses);
mojo.execute();
File bundleSource = new File(generatedFilesDir, "testparent-1.0-bundle.jar");
Set<String> entryNames = new HashSet<String>();
entryNames.add("pom.xml");
entryNames.add("META-INF/MANIFEST.MF");
entryNames.add("META-INF/");
assertZipContents(entryNames, Assertions.EMPTY_ENTRY_NAMES, bundleSource);
}
use of org.apache.maven.artifact.repository.DefaultArtifactRepository in project maven-plugins by apache.
the class BundlePackMojoTest method testPack_RemoveTwoWithSpace.
public void testPack_RemoveTwoWithSpace() throws Exception {
File testPom = new File(getBasedir(), "src/test/resources/unit/bundle-pack/pom.xml");
BundlePackMojo mojo = (BundlePackMojo) lookupMojo("bundle-pack", testPom);
URL repoURL = new File(getBasedir(), "src/test/resources/repo").toURL();
mojo.localRepository = new DefaultArtifactRepository("test", repoURL.toString(), new DefaultRepositoryLayout());
// NOTE: This is sensitive to the lookupMojo method timing...
TestInputHandler ih = (TestInputHandler) lookup(InputHandler.ROLE, "default");
Stack<String> responses = new Stack<String>();
responses.push("2, 3");
ih.setLineResponses(responses);
File generatedFilesDir = new File(getBasedir(), "target/bundle-pack-tests");
mojo.basedir = generatedFilesDir.getAbsolutePath();
mojo.execute();
File bundleSource = new File(generatedFilesDir, "testartifact-1.0-bundle.jar");
Set<String> entryNames = new HashSet<String>();
entryNames.add("testartifact-1.0.jar");
entryNames.add("pom.xml");
entryNames.add("META-INF/MANIFEST.MF");
entryNames.add("META-INF/");
Set<String> bannedNames = new HashSet<String>();
// determined experimentally, so this could change!
bannedNames.add("testartifact-1.0-sources.jar");
bannedNames.add("testartifact-1.0-javadoc.jar");
assertZipContents(entryNames, bannedNames, bundleSource);
}
Aggregations