Search in sources :

Example 1 with DeploymentException

use of org.eclipse.aether.deployment.DeploymentException in project buck by facebook.

the class PublishCommand method publishTargets.

private boolean publishTargets(ImmutableList<BuildTarget> buildTargets, CommandRunnerParams params) {
    ImmutableSet.Builder<MavenPublishable> publishables = ImmutableSet.builder();
    boolean success = true;
    for (BuildTarget buildTarget : buildTargets) {
        BuildRule buildRule = null;
        try {
            buildRule = getBuild().getRuleResolver().requireRule(buildTarget);
        } catch (NoSuchBuildTargetException e) {
            // This doesn't seem physically possible!
            throw new RuntimeException(e);
        }
        Preconditions.checkNotNull(buildRule);
        if (!(buildRule instanceof MavenPublishable)) {
            params.getBuckEventBus().post(ConsoleEvent.severe("Cannot publish rule of type %s", buildRule.getClass().getName()));
            success &= false;
            continue;
        }
        MavenPublishable publishable = (MavenPublishable) buildRule;
        if (!publishable.getMavenCoords().isPresent()) {
            params.getBuckEventBus().post(ConsoleEvent.severe("No maven coordinates specified for %s", buildTarget.getUnflavoredBuildTarget().getFullyQualifiedName()));
            success &= false;
            continue;
        }
        publishables.add(publishable);
    }
    Publisher publisher = new Publisher(params.getCell().getFilesystem(), Optional.ofNullable(remoteRepo), Optional.ofNullable(username), Optional.ofNullable(password), dryRun);
    try {
        ImmutableSet<DeployResult> deployResults = publisher.publish(new SourcePathResolver(new SourcePathRuleFinder(getBuild().getRuleResolver())), publishables.build());
        for (DeployResult deployResult : deployResults) {
            printArtifactsInformation(params, deployResult);
        }
    } catch (DeploymentException e) {
        params.getConsole().printBuildFailureWithoutStacktraceDontUnwrap(e);
        return false;
    }
    return success;
}
Also used : Publisher(com.facebook.buck.maven.Publisher) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) MavenPublishable(com.facebook.buck.jvm.java.MavenPublishable) ImmutableSet(com.google.common.collect.ImmutableSet) DeployResult(org.eclipse.aether.deployment.DeployResult) BuildTarget(com.facebook.buck.model.BuildTarget) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) BuildRule(com.facebook.buck.rules.BuildRule) DeploymentException(org.eclipse.aether.deployment.DeploymentException)

Example 2 with DeploymentException

use of org.eclipse.aether.deployment.DeploymentException in project buck by facebook.

the class Publisher method publish.

public ImmutableSet<DeployResult> publish(SourcePathResolver pathResolver, ImmutableSet<MavenPublishable> publishables) throws DeploymentException {
    ImmutableListMultimap<UnflavoredBuildTarget, UnflavoredBuildTarget> duplicateBuiltinBuileRules = checkForDuplicatePackagedDeps(publishables);
    if (duplicateBuiltinBuileRules.size() > 0) {
        StringBuilder sb = new StringBuilder();
        sb.append("Duplicate transitive dependencies for publishable libraries found!  This means");
        sb.append(StandardSystemProperty.LINE_SEPARATOR);
        sb.append("that the following libraries would have multiple copies if these libraries were");
        sb.append(StandardSystemProperty.LINE_SEPARATOR);
        sb.append("used together.  The can be resolved by adding a maven URL to each target listed");
        sb.append(StandardSystemProperty.LINE_SEPARATOR);
        sb.append("below:");
        for (UnflavoredBuildTarget unflavoredBuildTarget : duplicateBuiltinBuileRules.keySet()) {
            sb.append(StandardSystemProperty.LINE_SEPARATOR);
            sb.append(unflavoredBuildTarget.getFullyQualifiedName());
            sb.append(" (referenced by these build targets: ");
            Joiner.on(", ").appendTo(sb, duplicateBuiltinBuileRules.get(unflavoredBuildTarget));
            sb.append(")");
        }
        throw new DeploymentException(sb.toString());
    }
    ImmutableSet.Builder<DeployResult> deployResultBuilder = ImmutableSet.builder();
    for (MavenPublishable publishable : publishables) {
        DefaultArtifact coords = new DefaultArtifact(Preconditions.checkNotNull(publishable.getMavenCoords().get(), "No maven coordinates specified for published rule ", publishable));
        Path relativePathToOutput = pathResolver.getRelativePath(Preconditions.checkNotNull(publishable.getSourcePathToOutput(), "No path to output present in ", publishable));
        File mainItem = publishable.getProjectFilesystem().resolve(relativePathToOutput).toFile();
        if (!coords.getClassifier().isEmpty()) {
            deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem)));
        }
        try {
            // If this is the "main" artifact (denoted by lack of classifier) generate and publish
            // pom alongside
            File pom = Pom.generatePomFile(pathResolver, publishable).toFile();
            deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem, pom)));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return deployResultBuilder.build();
}
Also used : Path(java.nio.file.Path) UnflavoredBuildTarget(com.facebook.buck.model.UnflavoredBuildTarget) IOException(java.io.IOException) MavenPublishable(com.facebook.buck.jvm.java.MavenPublishable) ImmutableSet(com.google.common.collect.ImmutableSet) DeployResult(org.eclipse.aether.deployment.DeployResult) DeploymentException(org.eclipse.aether.deployment.DeploymentException) File(java.io.File) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 3 with DeploymentException

use of org.eclipse.aether.deployment.DeploymentException in project drools by kiegroup.

the class MavenRepository method deployArtifact.

/**
 * Deploys a jar on a remote repository.
 *
 * @param repository The remote repository where the kjar will be deployed
 * @param releaseId The releaseId with which the deployment will be made
 * @param jar The jar to be deployed
 * @param pomfile The pom file to be deployed together with the kjar
 */
public void deployArtifact(RemoteRepository repository, ReleaseId releaseId, File jar, File pomfile) {
    Artifact jarArtifact = new DefaultArtifact(releaseId.getGroupId(), releaseId.getArtifactId(), "jar", releaseId.getVersion());
    jarArtifact = jarArtifact.setFile(jar);
    Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom");
    pomArtifact = pomArtifact.setFile(pomfile);
    DeployRequest deployRequest = new DeployRequest();
    deployRequest.addArtifact(jarArtifact).addArtifact(pomArtifact).setRepository(repository);
    try {
        aether.getSystem().deploy(aether.getSession(), deployRequest);
    } catch (DeploymentException e) {
        throw new RuntimeException(e);
    }
}
Also used : SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) DeployRequest(org.eclipse.aether.deployment.DeployRequest) DeploymentException(org.eclipse.aether.deployment.DeploymentException) SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 4 with DeploymentException

use of org.eclipse.aether.deployment.DeploymentException in project drools by kiegroup.

the class MavenRepository method deployPomArtifact.

public void deployPomArtifact(String groupId, String artifactId, String version, File pomfile) {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "pom", version);
    pomArtifact = pomArtifact.setFile(pomfile);
    DeployRequest deployRequest = new DeployRequest();
    deployRequest.addArtifact(pomArtifact).setRepository(aether.getLocalRepository());
    try {
        aether.getSystem().deploy(aether.getSession(), deployRequest);
    } catch (DeploymentException e) {
        throw new RuntimeException(e);
    }
}
Also used : DeployRequest(org.eclipse.aether.deployment.DeployRequest) DeploymentException(org.eclipse.aether.deployment.DeploymentException) SubArtifact(org.eclipse.aether.util.artifact.SubArtifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Aggregations

DeploymentException (org.eclipse.aether.deployment.DeploymentException)4 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)3 MavenPublishable (com.facebook.buck.jvm.java.MavenPublishable)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Artifact (org.eclipse.aether.artifact.Artifact)2 DeployRequest (org.eclipse.aether.deployment.DeployRequest)2 DeployResult (org.eclipse.aether.deployment.DeployResult)2 SubArtifact (org.eclipse.aether.util.artifact.SubArtifact)2 Publisher (com.facebook.buck.maven.Publisher)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 UnflavoredBuildTarget (com.facebook.buck.model.UnflavoredBuildTarget)1 NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)1 BuildRule (com.facebook.buck.rules.BuildRule)1 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)1 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)1 File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1