use of org.sonatype.aether.RepositoryException in project sonatype-aether by sonatype.
the class DefaultDeployerTest method testStaleLocalMetadataCopyGetsDeletedBeforeMergeWhenMetadataIsNotCurrentlyPresentInRemoteRepo.
@Test
public void testStaleLocalMetadataCopyGetsDeletedBeforeMergeWhenMetadataIsNotCurrentlyPresentInRemoteRepo() throws Exception {
MergeableMetadata metadata = new MergeableMetadata() {
public Metadata setFile(File file) {
return this;
}
public String getVersion() {
return "";
}
public String getType() {
return "test.properties";
}
public Nature getNature() {
return Nature.RELEASE;
}
public String getGroupId() {
return "org";
}
public File getFile() {
return null;
}
public String getArtifactId() {
return "aether";
}
public void merge(File current, File result) throws RepositoryException {
Properties props = new Properties();
try {
if (current.isFile()) {
TestFileUtils.read(props, current);
}
props.setProperty("new", "value");
TestFileUtils.write(props, result);
} catch (IOException e) {
throw new RepositoryException(e.getMessage(), e);
}
}
public boolean isMerged() {
return false;
}
};
manager.setConnector(new RepositoryConnector() {
public void put(Collection<? extends ArtifactUpload> artifactUploads, Collection<? extends MetadataUpload> metadataUploads) {
}
public void get(Collection<? extends ArtifactDownload> artifactDownloads, Collection<? extends MetadataDownload> metadataDownloads) {
if (metadataDownloads != null) {
for (MetadataDownload download : metadataDownloads) {
download.setException(new MetadataNotFoundException(download.getMetadata(), null, null));
}
}
}
public void close() {
}
});
request.addMetadata(metadata);
File metadataFile = new File(session.getLocalRepository().getBasedir(), session.getLocalRepositoryManager().getPathForRemoteMetadata(metadata, request.getRepository(), ""));
Properties props = new Properties();
props.setProperty("old", "value");
TestFileUtils.write(props, metadataFile);
deployer.deploy(session, request);
props = new Properties();
TestFileUtils.read(props, metadataFile);
assertNull(props.toString(), props.get("old"));
}
use of org.sonatype.aether.RepositoryException in project sonatype-aether by sonatype.
the class JavaEffectiveScopeCalculator method transformGraph.
public DependencyNode transformGraph(DependencyNode node, DependencyGraphTransformationContext context) throws RepositoryException {
List<?> sortedConflictIds = (List<?>) context.get(TransformationContextKeys.SORTED_CONFLICT_IDS);
if (sortedConflictIds == null) {
ConflictIdSorter sorter = new ConflictIdSorter();
sorter.transformGraph(node, context);
sortedConflictIds = (List<?>) context.get(TransformationContextKeys.SORTED_CONFLICT_IDS);
}
Map<?, ?> conflictIds = (Map<?, ?>) context.get(TransformationContextKeys.CONFLICT_IDS);
if (conflictIds == null) {
throw new RepositoryException("conflict groups have not been identified");
}
Boolean cyclicConflictIds = (Boolean) context.get(TransformationContextKeys.CYCLIC_CONFLICT_IDS);
Map<Object, ConflictGroup> groups = new HashMap<Object, ConflictGroup>(256);
buildConflictGroups(groups, node, null, conflictIds);
String rootScope = "";
if (node.getDependency() != null) {
Object key = conflictIds.get(node);
groups.get(key).scope = rootScope = node.getDependency().getScope();
}
for (DependencyNode child : node.getChildren()) {
Object key = conflictIds.get(child);
groups.get(key).scope = getInheritedScope(rootScope, child.getDependency().getScope());
}
Set<Object> prequisites = null;
if (Boolean.TRUE.equals(cyclicConflictIds)) {
prequisites = new HashSet<Object>(sortedConflictIds.size() * 2);
}
for (Object key : sortedConflictIds) {
if (prequisites != null) {
prequisites.add(key);
}
ConflictGroup group = groups.get(key);
resolve(group, conflictIds, prequisites);
}
return node;
}
use of org.sonatype.aether.RepositoryException in project SSM by Intel-bigdata.
the class DependencyResolver method getArtifactsWithDep.
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency, Collection<String> excludes) throws RepositoryException {
Artifact artifact = new DefaultArtifact(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(excludes);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
try {
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
} catch (NullPointerException ex) {
throw new RepositoryException(String.format("Cannot fetch dependencies for %s", dependency));
}
}
use of org.sonatype.aether.RepositoryException in project gradle by gradle.
the class AbstractMavenPublishAction method publish.
public void publish() {
List<Artifact> artifacts = new ArrayList<Artifact>();
if (mainArtifact.getFile() != null) {
artifacts.add(mainArtifact);
}
artifacts.add(pomArtifact);
if (metadataArtifact != null) {
artifacts.add(metadataArtifact);
}
for (Artifact artifact : attached) {
File file = artifact.getFile();
if (file != null && file.isFile()) {
artifacts.add(artifact);
}
}
try {
publishArtifacts(artifacts, newRepositorySystem(), session);
} catch (RepositoryException e) {
throw new GradleException(e.getMessage(), e);
}
}
use of org.sonatype.aether.RepositoryException in project motech by motech.
the class ModuleAdminServiceImpl method installWithDependenciesFromFile.
private BundleInformation installWithDependenciesFromFile(File bundleFile, boolean startBundle) throws IOException {
JarInformation jarInformation = getJarInformations(bundleFile);
List<Bundle> bundlesInstalled = new ArrayList<>();
BundleInformation bundleInformation = null;
if (jarInformation == null) {
throw new IOException("Unable to read bundleFile " + bundleFile.getAbsolutePath());
}
try {
List<ArtifactResult> artifactResults = new LinkedList<>();
bundleWatcherSuspensionService.suspendBundleProcessing();
for (Dependency dependency : jarInformation.getPomInformation().getDependencies()) {
artifactResults.addAll(resolveDependencies(dependency, jarInformation.getPomInformation()));
}
artifactResults = removeDuplicatedArtifacts(artifactResults);
bundlesInstalled = installBundlesFromArtifacts(artifactResults);
final Bundle requestedModule = installBundleFromFile(bundleFile, true, false);
if (requestedModule != null) {
if (!isFragmentBundle(requestedModule) && startBundle) {
requestedModule.start();
}
bundlesInstalled.add(requestedModule);
bundleInformation = null;
} else {
bundleInformation = new BundleInformation(null);
}
} catch (BundleException | RepositoryException e) {
throw new MotechException("Error while installing bundle and dependencies.", e);
} finally {
bundleWatcherSuspensionService.restoreBundleProcessing();
}
// start bundles after all bundles installed to avoid any dependency resolution problems.
startBundles(bundlesInstalled, startBundle);
return bundleInformation;
}
Aggregations