Skip to content

Commit

Permalink
Port the build to Gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Jan 10, 2020
1 parent abe95fa commit ce99db1
Show file tree
Hide file tree
Showing 974 changed files with 17,092 additions and 26,580 deletions.
28 changes: 0 additions & 28 deletions .bomr/bomr.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ MANIFEST.MF
_site/
activemq-data
bin
build
!/**/src/**/bin
!/**/src/**/build
build.log
dependency-reduced-pom.xml
dump.rdb
interpolated*.xml
lib/
manifest.yml
out
overridedb.*
target
transaction-logs
Expand Down
1 change: 0 additions & 1 deletion .mvn/jvm.config

This file was deleted.

Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties

This file was deleted.

105 changes: 22 additions & 83 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ added after the original pull request but before a merge.
* We use the https://github.com/spring-io/spring-javaformat/[Spring JavaFormat] project
to apply code formatting conventions. If you use Eclipse and you follow the '`Importing
into eclipse`' instructions below you should get project specific formatting
automatically. You can also install the https://github.com/spring-io/spring-javaformat/#intellij-idea[Spring JavaFormat IntelliJ Plugin]
or format the code from the Maven build by running
`./mvnw io.spring.javaformat:spring-javaformat-maven-plugin:apply`.
automatically. You can also install the
https://github.com/spring-io/spring-javaformat/#intellij-idea[Spring JavaFormat IntelliJ
Plugin] or format the code from the Gradle build by running
`./gradlew format`.
* The build includes checkstyle rules for many of our code conventions. Run
`./mvnw validate` if you want to check you changes are compliant.
`./gradlew checkstyleMain checkstyleTest` if you want to check you changes are
compliant.
* Make sure all new `.java` files to have a simple Javadoc class comment with at least an
`@author` tag identifying you, and preferably at least a paragraph on what the class is
for.
Expand All @@ -75,75 +77,31 @@ added after the original pull request but before a merge.
If you don't have an IDE preference we would recommend that you use
https://spring.io/tools/sts[Spring Tools Suite] or
https://eclipse.org[Eclipse] when working with the code. We use the
https://eclipse.org/m2e/[M2Eclipse] eclipse plugin for maven support. Other IDEs and tools
should also work without issue.
https://projects.eclipse.org/projects/tools.buildship[Buildship] Eclipse plugin for Gradle
support. Other IDEs and tools should also work without issue.



=== Building from Source
Spring Boot source can be built from the command line using
https://maven.apache.org/run-maven/index.html[Apache Maven] on JDK 1.8 or above. We
include '`Maven Wrapper`' scripts (`./mvnw` or `mvnw.bat`) that you can run rather than
needing to install Maven locally.
Spring Boot source can be built from the command line using https://gradle.org[Gradle] on
JDK 1.8 or above. We include https://docs.gradle.org/current/userguide/gradle_wrapper.html[Gradle's
wrapper scripts] (`./gradlew` or `gradlew.bat`) that you can run rather than needing to
install Gradle locally.



==== Default Build
The project can be built from the root directory using the standard Maven command:

[indent=0]
----
$ ./mvnw clean install
----

NOTE: You may need to increase the amount of memory available to Maven by setting
a `MAVEN_OPTS` environment variable with the value `-Xmx512m`

If you are rebuilding often, you might also want to skip the tests and the execution of
checkstyle until you are ready to submit a pull request:

[indent=0]
----
$ ./mvnw clean install -DskipTests -Pfast
----



==== Full Build
You can run a full build using the following command:
The project can be built from the root directory using the standard Gradle command:

[indent=0]
----
$ ./mvnw -Pfull clean install
$ ./gradlew build
----

NOTE: As for the standard build, you may need to increase the amount of memory available
to Maven by setting a `MAVEN_OPTS` environment variable with the value `-Xmx512m`. We
generate more artifacts when running the full build (such as Javadoc jars), so you may
find the process a little slower than the standard build.

[TIP]
====
If you want to run a build without the smoke tests and integration tests, building the
`spring-boot-project` module is enough. You can cd there and run the same command, or you
can run this from the top-level directory:
[indent=0]
----
$ ./mvnw -f spring-boot-project -Pfull clean install
----
====



=== Importing into Eclipse
You can import the Spring Boot code into any Eclipse 2019-09-based distribution. The
easiest way to setup a new environment is to use the Eclipse Installer with the provided
`spring-boot-project.setup` file (in the `/eclipse` folder).

NOTE: Due to m2e issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=548652[#548652] you need to be running m2e 1.14.0 or higher.
An early milestone is available from https://download.eclipse.org/technology/m2e/milestones/1.14/.



==== Using the Eclipse Installer
Expand All @@ -169,23 +127,20 @@ Once complete you should find that a local workspace has been provisioned comple
all required Eclipse plugins. Projects will be grouped into working-sets to make the code
easier to navigate.

If you want to work on the `spring-boot-gradle-plugin` you should remove the imported Maven
project and reimport it as a Gradle project.

TIP: If you see import errors with `com.sun` packages make sure you have setup a valid
`JavaSE-1.8` environment. From preferences select "`Java`", "`Installed JREs`",
"`Execution Environments`" and make sure "`JavaSE-1.8`" points to a Java 1.8
install (we use AdoptOpenJDK on our CI).



==== Manual Installation with M2Eclipse
==== Manual Installation with Buildship
If you prefer to install Eclipse yourself you should use the
https://eclipse.org/m2e/[M2Eclipse] eclipse plugin. If you don't already have m2eclipse
installed it is available from the "`Eclipse marketplace`".
https://projects.eclipse.org/projects/tools.buildship[Buildship] Eclipse plugin. If you
don't already have Buildship installed it is available from the "`Eclipse marketplace`".

Spring Boot includes project specific source formatting settings, in order to have these
work with m2eclipse, we provide an additional Eclipse plugin that you can install:
work with Buildship, we provide an additional Eclipse plugin that you can install:



Expand All @@ -197,21 +152,13 @@ work with m2eclipse, we provide an additional Eclipse plugin that you can instal
NOTE: The plugin is optional. Projects can be imported without the plugins, your code
changes just won't be automatically formatted.

With the requisite eclipse plugins installed you can select
`import existing maven projects` from the `file` menu to import the code. You will
need to import the root `spring-boot` pom and the `spring-boot-smoke-tests` pom separately.
With the requisite Eclipse plugins installed you can select
`Gradle -> Existing Gradle project` from the `File -> Import…` menu to import the code.



=== Importing into IntelliJ IDEA
**Please, do this first!**
Go to `Preferences | Build, Execution, Deployment | Build Tools | Maven | Importing`
and set `VM options for importer` to `-Xmx2g` to allocate sufficient memory for IDEA's
Maven import process to parse the Spring Boot project structure. _Not doing so could
mean the import fails silently, leaving the project setup incomplete._

For the actual import use "`File`" -> "`Open`" and select the root `pom.xml`, or the
`spring-boot-project/pom.xml` if you only want the Spring Boot project sources.
Use "`File`" -> "`Open`" and then select the root `build.gradle` file to import the code.



Expand Down Expand Up @@ -239,16 +186,8 @@ needs to be added.


=== Importing into Other IDEs
Maven is well supported by most Java IDEs. Refer to your vendor documentation.


Gradle is well supported by most Java IDEs. Refer to your vendor documentation.

== Integration Tests
The smoke tests run as part of the build when you `./mvnw install`.
Due to the fact that they make use of the `spring-boot-maven-plugin`
they cannot be called directly, and so instead are launched via the
`maven-invoker-plugin`. If you encounter build failures running the integration tests,
check the `build.log` file in the appropriate smoke test directory.


== Cloning the git repository on Windows
Expand Down
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id 'org.jetbrains.kotlin.jvm' apply false // https://youtrack.jetbrains.com/issue/KT-30276
}

description = 'Spring Boot Build'

allprojects {
group 'org.springframework.boot'

repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 60, 'minutes'
}

}
26 changes: 26 additions & 0 deletions buildSrc/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
= BOM Plugin

Allows one to publish a BOM from Gradle.
Properties, dependencies, and other BOMs are applied to the `bom {}` extension.

This plugin applies the `java-platform` and `maven-publish` plugins to the Project it's applied to.

== Usage

[source,groovy,indent=0]
----
plugins {
id 'org.springframework.boot.bom'
}
bom {
property 'logback.version', '1.2.3'
property 'junit-jupiter.version', '5.3.2'
dependency 'ch.qos.logback', 'logback-classic', '${logback.version}'
dependency 'ch.qos.logback', 'logback-core', '${logback.version}'
bomImport 'org.junit', 'junit-bom', '${junit-jupiter.version}'
}
----

84 changes: 84 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
plugins {
id 'java-gradle-plugin'
id 'io.spring.javaformat' version '0.0.18-SNAPSHOT'
id 'checkstyle'
}

repositories {
mavenCentral()
gradlePluginPortal()
maven { url 'https://repo.spring.io/release' }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
checkstyle 'io.spring.javaformat:spring-javaformat-checkstyle:0.0.15'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.0'
implementation 'commons-codec:commons-codec:1.13'
implementation 'org.apache.maven:maven-embedder:3.6.2'
implementation 'org.asciidoctor:asciidoctor-gradle-jvm:2.4.0'
implementation 'org.springframework:spring-core:5.2.2.RELEASE'
implementation 'org.springframework:spring-web:5.2.2.RELEASE'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.15'
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.apache.logging.log4j:log4j-core:2.12.1'
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
}

checkstyle {
def archive = configurations.checkstyle.filter { it.name.startsWith('spring-javaformat-checkstyle')}
config = resources.text.fromArchiveEntry(archive, 'io/spring/javaformat/checkstyle/checkstyle.xml')
toolVersion = 8.11
}

gradlePlugin {
plugins {
autoConfigurationPlugin {
id = "org.springframework.boot.auto-configuration"
implementationClass = "org.springframework.boot.build.autoconfigure.AutoConfigurationPlugin"
}
bomPlugin {
id = "org.springframework.boot.bom"
implementationClass = "org.springframework.boot.build.bom.BomPlugin"
}
configurationPropertiesPlugin {
id = "org.springframework.boot.configuration-properties"
implementationClass = "org.springframework.boot.build.context.properties.ConfigurationPropertiesPlugin"
}
conventionsPlugin {
id = "org.springframework.boot.conventions"
implementationClass = "org.springframework.boot.build.ConventionsPlugin"
}
deployedPlugin {
id = "org.springframework.boot.deployed"
implementationClass = "org.springframework.boot.build.DeployedPlugin"
}
integrationTestPlugin {
id = "org.springframework.boot.integration-test"
implementationClass = "org.springframework.boot.build.test.IntegrationTestPlugin"
}
mavenPluginPlugin {
id = "org.springframework.boot.maven-plugin"
implementationClass = "org.springframework.boot.build.mavenplugin.MavenPluginPlugin"
}
mavenRepositoryPlugin {
id = "org.springframework.boot.maven-repository"
implementationClass = "org.springframework.boot.build.MavenRepositoryPlugin"
}
optionalDependenciesPlugin {
id = "org.springframework.boot.optional-dependencies"
implementationClass = "org.springframework.boot.build.optional.OptionalDependenciesPlugin"
}
starterPlugin {
id = "org.springframework.boot.starter"
implementationClass = "org.springframework.boot.build.starters.StarterPlugin"
}
}
}

test {
useJUnitPlatform()
}
16 changes: 16 additions & 0 deletions buildSrc/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven { url 'https://repo.spring.io/snapshot' }
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == 'io.spring.javaformat') {
useModule "io.spring.javaformat:spring-javaformat-gradle-plugin:${requested.version}"
}
}
}
}

apply from: new File(settingsDir, '../gradle/build-cache-settings.gradle')
Loading

0 comments on commit ce99db1

Please sign in to comment.