public Object execute()

in gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveAction.java [81:132]


    public Object execute(final CommandContext context) throws Exception {
        assert context != null;
        IO io = context.getIo();
        
        assert artifactManager != null;
        ArtifactFactory factory = artifactManager.getArtifactFactory();

        log.debug("Using factory: {}", factory);
        Artifact artifact;

        if (classifier != null) {
            artifact = factory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
            artifact.setScope(scope);
        }
        else {
            artifact = factory.createArtifact(groupId, artifactId, version, scope, type);
        }

        log.debug("Created artifact: {}", artifact);

        ArtifactResolutionRequest request = new ArtifactResolutionRequest();

        if (transitive) {
            io.info("Resolving artifact (transitively): {}", artifact);
            request.setArtifactDependencies(Collections.singleton(artifact));
        }
        else {
            io.info("Resolving artifact: {}", artifact);

            request.setArtifact(artifact);
            Set<Artifact> deps = Collections.emptySet();
            request.setArtifactDependencies(deps);
        }

        if (scope != null) {
            io.debug("Using scope: {}", scope);
            
            request.setFilter(new ScopeArtifactFilter(scope));
        }

        ArtifactResolutionResult result = artifactManager.resolve(request);

        Set<Artifact> artifacts = result.getArtifacts();

        io.info("Resolved artifacts:");

        for (Artifact a : artifacts) {
            io.info("    {}", a);    
        }

        return Result.SUCCESS;
    }