use of org.eclipse.aether.resolution.ArtifactResult in project acceptance-test-harness by jenkinsci.
the class FallbackConfig method getJenkinsWar.
/**
* Get the file with Jenkins to run.
*
* The file will exist on machine where tests run.
*/
@Provides
@Named("jenkins.war")
public File getJenkinsWar(RepositorySystem repositorySystem, RepositorySystemSession repositorySystemSession) {
try {
return IOUtil.firstExisting(false, System.getenv("JENKINS_WAR"));
} catch (IOException ex) {
}
String version = System.getenv("JENKINS_VERSION");
if (version != null && !version.isEmpty()) {
ArtifactResolverUtil resolverUtil = new ArtifactResolverUtil(repositorySystem, repositorySystemSession);
ArtifactResult resolvedArtifact = resolverUtil.resolve(new DefaultArtifact("org.jenkins-ci.main", "jenkins-war", "war", version));
return resolvedArtifact.getArtifact().getFile();
}
try {
// Lowest priority of all
return IOUtil.firstExisting(false, System.getenv("JENKINS_WAR"), getWorkspace() + "/jenkins.war", "./jenkins.war");
} catch (IOException ex) {
throw new Error("Could not find jenkins.war, use JENKINS_WAR or JENKINS_VERSION to specify it.", ex);
}
}
use of org.eclipse.aether.resolution.ArtifactResult in project acceptance-test-harness by jenkinsci.
the class FallbackConfig method getFormElementsPathFile.
/**
* Provides the path to the form elements plug-in. Uses the Maven repository to obtain the plugin.
*
* @return the path to the form elements plug-in
*/
@Named("form-element-path.hpi")
@Provides
public File getFormElementsPathFile(RepositorySystem repositorySystem, RepositorySystemSession repositorySystemSession) {
ArtifactResolverUtil resolverUtil = new ArtifactResolverUtil(repositorySystem, repositorySystemSession);
String version = System.getenv("FORM_ELEMENT_PATH_VERSION");
version = version == null ? "1.12" : version;
ArtifactResult resolvedArtifact = resolverUtil.resolve(new DefaultArtifact("org.jenkins-ci.plugins", "form-element-path", "hpi", version));
return resolvedArtifact.getArtifact().getFile();
}
use of org.eclipse.aether.resolution.ArtifactResult in project acceptance-test-harness by jenkinsci.
the class ArtifactResolverUtil method resolve.
/**
* @param artifact The artifact to be resolved
*
* @return artifact resolution result
*/
public ArtifactResult resolve(DefaultArtifact artifact) {
Builder repoBuilder = new RemoteRepository.Builder("repo.jenkins-ci.org", "default", "https://repo.jenkins-ci.org/public/");
DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
File userHome = new File(System.getProperty("user.home"));
File userSettingsFile = new File(new File(userHome, ".m2"), "settings.xml");
request.setUserSettingsFile(userSettingsFile);
if (userSettingsFile.exists()) {
LOGGER.config("Found maven settings file - " + userSettingsFile.getAbsolutePath());
SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance();
try {
Settings settings = settingsBuilder.build(request).getEffectiveSettings();
org.apache.maven.settings.Proxy mavenActiveproxy = settings.getActiveProxy();
if (mavenActiveproxy != null) {
LOGGER.config("Found maven proxy settings. Will use for artifact resolution");
repoBuilder.setProxy(asProxy(mavenActiveproxy));
} else {
LOGGER.config("Did not find an active proxy in maven settings xml file");
}
} catch (SettingsBuildingException e) {
LOGGER.log(Level.WARNING, "Could not find or load settings.xml to attempt to user proxy settings.", e);
}
}
RemoteRepository repo = repoBuilder.build();
ArtifactResult r;
try {
r = repoSystem.resolveArtifact(repoSystemSession, new ArtifactRequest(artifact, Arrays.asList(repo), null));
} catch (ArtifactResolutionException e) {
throw new RuntimeException("Could not resolve " + artifact + " from Maven repository", e);
}
LOGGER.config("Found " + r);
return r;
}
use of org.eclipse.aether.resolution.ArtifactResult in project acceptance-test-harness by jenkinsci.
the class PluginMetadata method resolve.
public File resolve(Injector i, String version) {
DefaultArtifact artifact = getDefaultArtifact();
if (version != null) {
artifact.setVersion(version);
}
ArtifactResolverUtil resolverUtil = i.getInstance(ArtifactResolverUtil.class);
ArtifactResult r = resolverUtil.resolve(artifact);
return r.getArtifact().getFile();
}
use of org.eclipse.aether.resolution.ArtifactResult in project BIMserver by opensourceBIM.
the class MavenPluginLocation method getLatestVersionString.
public String getLatestVersionString() {
Artifact lastArt = new DefaultArtifact(groupId, artifactId, "jar", "LATEST");
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(lastArt);
request.setRepositories(mavenPluginRepository.getRepositoriesAsList());
try {
ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request);
return resolveArtifact.getArtifact().getVersion();
} catch (ArtifactResolutionException e1) {
e1.printStackTrace();
}
return null;
}
Aggregations