<commit_before>
[[getting-started]]
= Getting started

[[partintro]]
--
If you're just getting started with Spring Cloud Task, this is the section
for you! Here we answer the basic "`what?`", "`how?`" and "`why?`" questions. You'll
find a gentle introduction to Spring Cloud Task.  We'll then build our first Spring Cloud
Task application, discussing some core principles as we go.
--

[[getting-started-introducing-spring-cloud-task]]
== Introducing Spring Cloud Task

Spring Cloud Task makes it easy to create short lived microservices.  We provide
capabilities that allow short lived JVM processes to be executed on demand in a production
environment.

[[getting-started-system-requirements]]
== System Requirements

You need Java installed (Java 7 or better, we recommend Java 8) and to build you need to have Maven installed as well.

=== Database Requirements

Spring Cloud Task uses a relational database to store the results of an executed task.
While you can begin developing a task without a database (the status of the task is logged
 as part of the task repository's updates), for production environments, you'll want to
utilize a supported database.  Below is a list of the ones currently supported:

- DB2
- H2
- HSQLDB
- MySql
- Oracle
- Postgres
- SqlServer

[[getting-started-developing-first-task]]
== Developing your first Spring Cloud Task application

A good place to start is with a simple "Hello World!" application so we'll create the
Spring Cloud Task equivalent to highlight the features of the framework.  We'll use Apache
Maven as a build tool for this project since most IDEs have good support for it.

NOTE: The spring.io web site contains many “Getting Started” guides that use Spring Boot.
If you’re looking to solve a specific problem; check there first.  You can shortcut the
steps below by going to start.spring.io and creating a new project. This will
automatically generate a new project structure so that you can start coding right the way.
Check the documentation for more details.

Before we begin, open a terminal to check that you have valid versions of Java and Maven
installed.

[source]
$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

[source]
$ mvn -v
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T15:58:10-05:00)
Maven home: /usr/local/Cellar/maven/3.2.3/libexec
Java version: 1.8.0_31, vendor: Oracle Corporation

NOTE: This sample needs to be created in its own folder.  Subsequent instructions assume
you have created a suitable folder and that it is your "current directory".

[[getting-started-creating-the-pom]]
=== Creating the POM

We need to start by creating a Maven `pom.xml` file.  The `pom.xml` is the recipe that
will be used to build your project.  Open your favorite text editor and add the following:

[code,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>myproject</artifactId>
	<packaging>jar</packaging>
	<version>0.0.1-SNAPSHOT</version>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.2.RELEASE</version>
	</parent>

	<properties>
		<start-class>com.example.SampleTask</start-class>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
</project>
----

This should give you a working build.  You can test it out by running `mvn package` (you
can ignore the "jar will be empty - no content was marked for inclusion!" warning for
now).

NOTE: At this point you could import the project into an IDE (most modern Java IDE's
include built-in support for Maven).  For simplicity we will continue to use a plain text
editor for this example.

[[getting-started-adding-classpath-dependencies]]
=== Adding classpath dependencies

A Spring Cloud Task is made up of a Spring Boot application that is expected to end.  In
our POM above, we created the shell of a Spring Boot application from a dependency
perspective by setting our parent to use the `spring-boot-starter-parent`.

Spring Boot provides a number of additional "Starter POMs".  Some of which are appropriate
for use within tasks (`spring-boot-starter-batch`, `spring-boot-starter-jdbc`, etc) and
some may not be ('spring-boot-starter-web` is probably not going to be used in a task).
The indicator of if a starter makes sense or not comes down to if the resulting
application will end (batch based applications typically end, the
`spring-boot-starter-web` dependency bootstraps a servlet container which probably wont').

For this example, we'll only need to add a single additional dependency, the one for
Spring Cloud Task itself:

[source,xml]
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-task-core</artifactId>
			<version>1.2.0.BUILD-SNAPSHOT</version>
		</dependency>

[[getting-started-writing-the-code]]
=== Writing the code

To finish our application, we need to create a single Java file.  Maven will compile the
sources from `src/main/java` by default so you need to create that folder structure.  Then
add a file named `src/main/java/com/example/SampleTask.java`:<commit_msg>Updated docs version to 1.2.0.RC1<commit_after>
[[getting-started]]
= Getting started

[[partintro]]
--
If you're just getting started with Spring Cloud Task, this is the section
for you! Here we answer the basic "`what?`", "`how?`" and "`why?`" questions. You'll
find a gentle introduction to Spring Cloud Task.  We'll then build our first Spring Cloud
Task application, discussing some core principles as we go.
--

[[getting-started-introducing-spring-cloud-task]]
== Introducing Spring Cloud Task

Spring Cloud Task makes it easy to create short lived microservices.  We provide
capabilities that allow short lived JVM processes to be executed on demand in a production
environment.

[[getting-started-system-requirements]]
== System Requirements

You need Java installed (Java 7 or better, we recommend Java 8) and to build you need to have Maven installed as well.

=== Database Requirements

Spring Cloud Task uses a relational database to store the results of an executed task.
While you can begin developing a task without a database (the status of the task is logged
 as part of the task repository's updates), for production environments, you'll want to
utilize a supported database.  Below is a list of the ones currently supported:

- DB2
- H2
- HSQLDB
- MySql
- Oracle
- Postgres
- SqlServer

[[getting-started-developing-first-task]]
== Developing your first Spring Cloud Task application

A good place to start is with a simple "Hello World!" application so we'll create the
Spring Cloud Task equivalent to highlight the features of the framework.  We'll use Apache
Maven as a build tool for this project since most IDEs have good support for it.

NOTE: The spring.io web site contains many “Getting Started” guides that use Spring Boot.
If you’re looking to solve a specific problem; check there first.  You can shortcut the
steps below by going to start.spring.io and creating a new project. This will
automatically generate a new project structure so that you can start coding right the way.
Check the documentation for more details.

Before we begin, open a terminal to check that you have valid versions of Java and Maven
installed.

[source]
$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

[source]
$ mvn -v
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T15:58:10-05:00)
Maven home: /usr/local/Cellar/maven/3.2.3/libexec
Java version: 1.8.0_31, vendor: Oracle Corporation

NOTE: This sample needs to be created in its own folder.  Subsequent instructions assume
you have created a suitable folder and that it is your "current directory".

[[getting-started-creating-the-pom]]
=== Creating the POM

We need to start by creating a Maven `pom.xml` file.  The `pom.xml` is the recipe that
will be used to build your project.  Open your favorite text editor and add the following:

[code,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>myproject</artifactId>
	<packaging>jar</packaging>
	<version>0.0.1-SNAPSHOT</version>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.2.RELEASE</version>
	</parent>

	<properties>
		<start-class>com.example.SampleTask</start-class>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
</project>
----

This should give you a working build.  You can test it out by running `mvn package` (you
can ignore the "jar will be empty - no content was marked for inclusion!" warning for
now).

NOTE: At this point you could import the project into an IDE (most modern Java IDE's
include built-in support for Maven).  For simplicity we will continue to use a plain text
editor for this example.

[[getting-started-adding-classpath-dependencies]]
=== Adding classpath dependencies

A Spring Cloud Task is made up of a Spring Boot application that is expected to end.  In
our POM above, we created the shell of a Spring Boot application from a dependency
perspective by setting our parent to use the `spring-boot-starter-parent`.

Spring Boot provides a number of additional "Starter POMs".  Some of which are appropriate
for use within tasks (`spring-boot-starter-batch`, `spring-boot-starter-jdbc`, etc) and
some may not be ('spring-boot-starter-web` is probably not going to be used in a task).
The indicator of if a starter makes sense or not comes down to if the resulting
application will end (batch based applications typically end, the
`spring-boot-starter-web` dependency bootstraps a servlet container which probably wont').

For this example, we'll only need to add a single additional dependency, the one for
Spring Cloud Task itself:

[source,xml]
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-task-core</artifactId>
			<version>1.2.0.RC1</version>
		</dependency>

[[getting-started-writing-the-code]]
=== Writing the code

To finish our application, we need to create a single Java file.  Maven will compile the
sources from `src/main/java` by default so you need to create that folder structure.  Then
add a file named `src/main/java/com/example/SampleTask.java`:
{'fraction_non_alphanumeric': 0.09266811279826465, 'fraction_numerical': 0.018134490238611713, 'mean_word_length': 4.383465670247548, 'pattern_counts': {'":': 0, '<': 105, '<?xml version=': 2, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6270746', 'n_tokens_mistral': 3650, 'n_tokens_neox': 3284, 'n_words': 1411}