hudson.tasks
Class Maven

java.lang.Object
  extended by hudson.tasks.BuildStepCompatibilityLayer
      extended by hudson.tasks.Builder
          extended by hudson.tasks.Maven
All Implemented Interfaces:
ExtensionPoint, Describable<Builder>, BuildStep

public class Maven
extends Builder

Build by using Maven.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class Maven.DescriptorImpl
           
static class Maven.MavenInstallation
          Represents a Maven installation in a system.
static class Maven.MavenInstaller
          Automatic Maven installer from apache.org.
static interface Maven.ProjectWithMaven
          Optional interface that can be implemented by AbstractProject that has "contextual" Maven.MavenInstallation associated with it.
 
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
static Maven.DescriptorImpl DESCRIPTOR
          Deprecated. as of 1.286 Use Jenkins.getDescriptorByType(Class) to obtain the current instance. For compatibility, this field retains the last created Maven.DescriptorImpl. TODO: fix sonar plugin that depends on this. That's the only plugin that depends on this field.
 String jvmOptions
          MAVEN_OPTS if not null.
 String mavenName
          Identifies Maven.MavenInstallation to be used.
 String pom
          Optional POM file path relative to the workspace.
 String properties
          Optional properties to be passed to Maven.
 String targets
          The targets and other maven options.
 boolean usePrivateRepository
          If true, the build will use its own local Maven repository via "-Dmaven.repo.local=...".
 
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
 
Constructor Summary
Maven(String targets, String name)
           
Maven(String targets, String name, String pom, String properties, String jvmOptions)
           
Maven(String targets, String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository)
           
Maven(String targets, String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository, SettingsProvider settings, GlobalSettingsProvider globalSettings)
           
 
Method Summary
protected  void buildEnvVars(EnvVars env, Maven.MavenInstallation mi)
          Build up the environment variables toward the Maven launch.
 Maven.DescriptorImpl getDescriptor()
          Gets the descriptor for this instance.
 GlobalSettingsProvider getGlobalSettings()
           
 Maven.MavenInstallation getMaven()
          Gets the Maven to invoke, or null to invoke the default one.
 SettingsProvider getSettings()
           
 String getTargets()
           
 boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)
          Runs the step over the given build and reports the progress to the listener.
 void setUsePrivateRepository(boolean usePrivateRepository)
           
 boolean usesPrivateRepository()
           
protected  void wrapUpArguments(ArgumentListBuilder args, String normalizedTarget, AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)
          Allows the derived type to make additional modifications to the arguments list.
 
Methods inherited from class hudson.tasks.Builder
all, getRequiredMonitorService, prebuild
 
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectAction, getProjectActions, perform, prebuild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions, prebuild
 

Field Detail

targets

public final String targets
The targets and other maven options. Can be separated by SP or NL.


mavenName

public final String mavenName
Identifies Maven.MavenInstallation to be used.


jvmOptions

public final String jvmOptions
MAVEN_OPTS if not null.


pom

public final String pom
Optional POM file path relative to the workspace. Used for the Maven '-f' option.


properties

public final String properties
Optional properties to be passed to Maven. Follows Properties syntax.


usePrivateRepository

public boolean usePrivateRepository
If true, the build will use its own local Maven repository via "-Dmaven.repo.local=...".

This would consume additional disk space, but provides isolation with other builds on the same machine, such as mixing SNAPSHOTS. Maven also doesn't try to coordinate the concurrent access to Maven repositories from multiple Maven process, so this helps there too. Identical to logic used in maven-plugin.

Since:
1.322

DESCRIPTOR

public static Maven.DescriptorImpl DESCRIPTOR
Deprecated. as of 1.286 Use Jenkins.getDescriptorByType(Class) to obtain the current instance. For compatibility, this field retains the last created Maven.DescriptorImpl. TODO: fix sonar plugin that depends on this. That's the only plugin that depends on this field.
Constructor Detail

Maven

public Maven(String targets,
             String name)

Maven

public Maven(String targets,
             String name,
             String pom,
             String properties,
             String jvmOptions)

Maven

public Maven(String targets,
             String name,
             String pom,
             String properties,
             String jvmOptions,
             boolean usePrivateRepository)

Maven

@DataBoundConstructor
public Maven(String targets,
                                  String name,
                                  String pom,
                                  String properties,
                                  String jvmOptions,
                                  boolean usePrivateRepository,
                                  SettingsProvider settings,
                                  GlobalSettingsProvider globalSettings)
Method Detail

getTargets

public String getTargets()

getSettings

public SettingsProvider getSettings()
Since:
1.491

getGlobalSettings

public GlobalSettingsProvider getGlobalSettings()
Since:
1.491

setUsePrivateRepository

public void setUsePrivateRepository(boolean usePrivateRepository)

usesPrivateRepository

public boolean usesPrivateRepository()

getMaven

public Maven.MavenInstallation getMaven()
Gets the Maven to invoke, or null to invoke the default one.


perform

public boolean perform(AbstractBuild<?,?> build,
                       Launcher launcher,
                       BuildListener listener)
                throws IOException,
                       InterruptedException
Description copied from interface: BuildStep
Runs the step over the given build and reports the progress to the listener.

A plugin can contribute the action object to Actionable.getActions() so that a 'report' becomes a part of the persisted data of Build. This is how JUnit plugin attaches the test report to a build page, for example.

Specified by:
perform in interface BuildStep
Overrides:
perform in class BuildStepCompatibilityLayer
Returns:
true if the build can continue, false if there was an error and the build needs to be aborted.

Using the return value to indicate success/failure should be considered deprecated, and implementations are encouraged to throw AbortException to indicate a failure.

Throws:
IOException - If the implementation wants to abort the processing when an IOException happens, it can simply propagate the exception to the caller. This will cause the build to fail, with the default error message. Implementations are encouraged to catch IOException on its own to provide a better error message, if it can do so, so that users have better understanding on why it failed.
InterruptedException - If the build is interrupted by the user (in an attempt to abort the build.) Normally the BuildStep implementations may simply forward the exception it got from its lower-level functions.

wrapUpArguments

protected void wrapUpArguments(ArgumentListBuilder args,
                               String normalizedTarget,
                               AbstractBuild<?,?> build,
                               Launcher launcher,
                               BuildListener listener)
                        throws IOException,
                               InterruptedException
Allows the derived type to make additional modifications to the arguments list.

Throws:
IOException
InterruptedException
Since:
1.344

buildEnvVars

protected void buildEnvVars(EnvVars env,
                            Maven.MavenInstallation mi)
                     throws IOException,
                            InterruptedException
Build up the environment variables toward the Maven launch.

Throws:
IOException
InterruptedException

getDescriptor

public Maven.DescriptorImpl getDescriptor()
Description copied from interface: Describable
Gets the descriptor for this instance.

Descriptor is a singleton for every concrete Describable implementation, so if a.getClass()==b.getClass() then a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<Builder>
Overrides:
getDescriptor in class Builder


Copyright © 2004-2013. All Rights Reserved.