Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jfrog.hudson.maven3;
  
  import hudson.EnvVars;
  import hudson.Extension;
  import hudson.Launcher;
 
 import java.util.List;
 import java.util.Map;

A wrapper that takes over artifacts resolution and using the configured repository for resolution.

The Maven3ExtractorListener is doing the heavy lifting. This class now just holds the configuration.

Author(s):
Tomer Cohen
 
 public class ArtifactoryMaven3NativeConfigurator extends BuildWrapper implements ResolverOverrider {
 
     private final ServerDetails details;
     private final Credentials overridingResolverCredentials;
 
     public ArtifactoryMaven3NativeConfigurator(ServerDetails detailsCredentials overridingResolverCredentials) {
         this. = details;
         this. = overridingResolverCredentials;
     }
 
     public ServerDetails getDetails() {
         return ;
     }
 
     public String getDownloadRepositoryKey() {
         return  != null ? . : null;
     }
 
     public String getArtifactoryName() {
         return  != null ? . : null;
     }
 
     @Override
     public Collection<? extends ActiongetProjectActions(AbstractProject project) {
         return Collections.emptyList();
     }
 
     public boolean isOverridingDefaultResolver() {
         return getOverridingResolverCredentials() != null;
     }
 
         return ;
     }
 
     @Override
     public Environment setUp(final AbstractBuild buildLauncher launcherBuildListener listener)
             throws IOExceptionInterruptedException {
         if (!(build instanceof MavenModuleSetBuild)) {
             return new Environment() {
             };
         }
 
         EnvVars envVars = build.getEnvironment(listener);
         boolean supportedMavenVersion =
                 MavenVersionHelper.isAtLeastResolutionCapableVersion((MavenModuleSetBuildbuildenvVarslistener);
         if (!supportedMavenVersion) {
             listener.getLogger().println("Artifactory resolution is not active. Maven 3.0.2 or higher is required to " +
                     "force resolution from Artifactory.");
             return new Environment() {
             };
         }
 
         return new Environment() {
             @Override
             public void buildEnvVars(Map<StringStringenv) {
                 super.buildEnvVars(env);
             }
 
             @Override
            public boolean tearDown(AbstractBuild buildBuildListener listener)
                    throws IOExceptionInterruptedException {
                return super.tearDown(buildlistener);
            }
        };
    }
        for (ArtifactoryServer server : servers) {
            if (server.getName().equals(getArtifactoryName())) {
                return server;
            }
        }
        return null;
    }
    @Override
    public DescriptorImpl getDescriptor() {
        return (DescriptorImplsuper.getDescriptor();
    }
    private boolean isExtractorUsed(EnvVars env) {
        return Boolean.parseBoolean(env.get(.));
    }
    @Extension(optional = true)
    public static class DescriptorImpl extends BuildWrapperDescriptor {
        public DescriptorImpl() {
            super(ArtifactoryMaven3NativeConfigurator.class);
            load();
        }
        @Override
        public boolean isApplicable(AbstractProject<?, ?> item) {
            return MavenModuleSet.class.equals(item.getClass());
        }
        @Override
        public String getDisplayName() {
            return "Resolve artifacts from Artifactory";
        }
        @Override
        public String getHelpFile() {
            return "/plugin/artifactory/help/ArtifactoryMaven3NativeConfigurator/help.html";
        }
        @Override
        public boolean configure(StaplerRequest reqJSONObject jsonthrows FormException {
            req.bindParameters(this"maven");
            save();
            return true;
        }

        
Returns the list of org.jfrog.hudson.ArtifactoryServer configured.

Returns:
can be empty but never null.
        public List<ArtifactoryServergetArtifactoryServers() {
            ArtifactoryBuilder.DescriptorImpl descriptor = (ArtifactoryBuilder.DescriptorImpl)
                    Hudson.getInstance().getDescriptor(ArtifactoryBuilder.class);
            return descriptor.getArtifactoryServers();
        }
    }
New to GrepCode? Check out our FAQ X