Spring-batch-maven-plugin

From Evgeny Goldin

(Redirected from Maven-spring-batch-plugin)
Jump to: navigation, search

Introduction

Running Spring Batch jobs isn't hard. Now it can be done from Maven as well:

<plugin>
    <groupId>com.github.goldin</groupId>
    <artifactId>spring-batch-maven-plugin</artifactId>
    <version>0.2.5</version>
    <executions>
        <execution>
            <id>run-spring-batch</id>
            <goals>
                <goal>run</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
                <jobId>jobId</jobId>
                <configLocations>
                    classpath:/springbatch/infra/job-runner-context.xml
                    classpath:/springbatch/infra/job-launcher.xml
                    file:/job/context.xml
                </configLocations>
            </configuration>
        </execution>
    </executions>
    <dependencies>
        ...
    </dependencies>
</plugin>

As you see, you only need to specify jobId and a number of ApplicationContext instances. Thats it! You're good to go.


Details

Provided By
Mailing List Nabble
Source Code GitHub
GroovyDoc <groovydoc>
Issue Tracker YouTrack
Build Server Maven
TeamCity
Maven Coordinates
  • com.github.goldin:spring-batch-maven-plugin:0.2.5
Goal
  • run
Default Phase
  • install
Maven Repository Artifactory


<configuration>

<jobId> Required. Specifies "id" of job to run.
<configLocations> Required. Specifies ApplicationContext instances to use, prefixed with "classpath:/" or "file:/".

Multiply instances are specified on multiply lines, optionally separated with commas.

<runIf> Optional. Specifies if plugin needs to be run, see "copy-maven-plugin" documentation for more details
<props> Optional. Contains properties to be used for ${...} replacements in XML definitions. It accepts the properties in one of the following formats:


<props>
    name = value
    classpath:/springbatch/infra/job-runner.properties
    file:/job/context.properties
</props>


For all properties specified an XML with corresponding PropertyPlaceholderConfigurer is generated and appended automatically to <configLocations>:


<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="properties">
      <value>
         name        = value
         anotherName = anotherValue
      </value>
   </property>
</bean>
<params> Optional. Same as JobParameters, specified as a single String
<opts> Optional. Same as optional parameters, specified as a single String
<failIfExitCodeOtherThan> Optional. Comma-separated or a single value of "good" exit codes:


<failIfExitCodeOtherThan>0</failIfExitCodeOtherThan>
<failIfExitCodeOtherThan>0, 2, 4</failIfExitCodeOtherThan>


The build fails if job's exit codes is different from those specified.

If <failIfExitCodeOtherThan> isn't used - exit code is ignored.

Personal tools