Skip to content

Commit d73bbb7

Browse files
committed
Add intro, license and contributing guidelines to README.
1 parent c2e1cf4 commit d73bbb7

File tree

2 files changed

+344
-1
lines changed

2 files changed

+344
-1
lines changed

README.adoc

Lines changed: 334 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,339 @@ Edit the files in the src/main/asciidoc/ directory instead.
99

1010
image::https://github.com/spring-projects-experimental/spring-cloud-square/workflows/Build/badge.svg?style=svg["Build",link="https://github.com/spring-projects-experimental/spring-cloud-square/actions"]
1111

12+
13+
https://pivotal.io/platform-as-a-service/migrating-to-cloud-native-application-architectures-ebook[Cloud Native] is a style of application development that encourages easy adoption of best practices in the areas of continuous delivery and value-driven development.
14+
A related discipline is that of building https://12factor.net/[12-factor Applications], in which development practices are aligned with delivery and operations goals -- for instance, by using declarative programming and management and monitoring.
15+
Spring Cloud facilitates these styles of development in a number of specific ways.
16+
The starting point is a set of features to which all components in a distributed system need easy access.
17+
18+
Many of those features are covered by https://projects.spring.io/spring-boot[Spring Boot], on which Spring Cloud builds. Some more features are delivered by Spring Cloud as two libraries: Spring Cloud Context and Spring Cloud Commons.
19+
Spring Cloud Context provides utilities and special services for the `ApplicationContext` of a Spring Cloud application (bootstrap context, encryption, refresh scope, and environment endpoints). Spring Cloud Commons is a set of abstractions and common classes used in different Spring Cloud implementations (such Spring Cloud Consul).
20+
21+
If you get an exception due to "Illegal key size" and you use Sun's JDK, you need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.
22+
See the following links for more information:
23+
24+
* https://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html[Java 6 JCE]
25+
* https://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html[Java 7 JCE]
26+
* https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html[Java 8 JCE]
27+
28+
Extract the files into the JDK/jre/lib/security folder for whichever version of JRE/JDK x64/x86 you use.
29+
30+
== Building
31+
32+
:jdkversion: 1.8
33+
34+
=== Basic Compile and Test
35+
36+
To build the source you will need to install JDK {jdkversion}.
37+
38+
Spring Cloud uses Maven for most build-related activities, and you
39+
should be able to get off the ground quite quickly by cloning the
40+
project you are interested in and typing
41+
42+
----
43+
$ ./mvnw install
44+
----
45+
46+
NOTE: You can also install Maven (>=3.3.3) yourself and run the `mvn` command
47+
in place of `./mvnw` in the examples below. If you do that you also
48+
might need to add `-P spring` if your local Maven settings do not
49+
contain repository declarations for spring pre-release artifacts.
50+
51+
NOTE: Be aware that you might need to increase the amount of memory
52+
available to Maven by setting a `MAVEN_OPTS` environment variable with
53+
a value like `-Xmx512m -XX:MaxPermSize=128m`. We try to cover this in
54+
the `.mvn` configuration, so if you find you have to do it to make a
55+
build succeed, please raise a ticket to get the settings added to
56+
source control.
57+
58+
The projects that require middleware (i.e. Redis) for testing generally
59+
require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running.
60+
61+
62+
=== Documentation
63+
64+
The spring-cloud-build module has a "docs" profile, and if you switch
65+
that on it will try to build asciidoc sources from
66+
`src/main/asciidoc`. As part of that process it will look for a
67+
`README.adoc` and process it by loading all the includes, but not
68+
parsing or rendering it, just copying it to `${main.basedir}`
69+
(defaults to `${basedir}`, i.e. the root of the project). If there are
70+
any changes in the README it will then show up after a Maven build as
71+
a modified file in the correct place. Just commit it and push the change.
72+
73+
=== Working with the code
74+
If you don't have an IDE preference we would recommend that you use
75+
https://www.springsource.com/developer/sts[Spring Tools Suite] or
76+
https://eclipse.org[Eclipse] when working with the code. We use the
77+
https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools
78+
should also work without issue as long as they use Maven 3.3.3 or better.
79+
80+
==== Activate the Spring Maven profile
81+
Spring Cloud projects require the 'spring' Maven profile to be activated to resolve
82+
the spring milestone and snapshot repositories. Use your preferred IDE to set this
83+
profile to be active, or you may experience build errors.
84+
85+
==== Importing into eclipse with m2eclipse
86+
We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with
87+
eclipse. If you don't already have m2eclipse installed it is available from the "eclipse
88+
marketplace".
89+
90+
NOTE: Older versions of m2e do not support Maven 3.3, so once the
91+
projects are imported into Eclipse you will also need to tell
92+
m2eclipse to use the right profile for the projects. If you
93+
see many different errors related to the POMs in the projects, check
94+
that you have an up to date installation. If you can't upgrade m2e,
95+
add the "spring" profile to your `settings.xml`. Alternatively you can
96+
copy the repository settings from the "spring" profile of the parent
97+
pom into your `settings.xml`.
98+
99+
==== Importing into eclipse without m2eclipse
100+
If you prefer not to use m2eclipse you can generate eclipse project metadata using the
101+
following command:
102+
103+
[indent=0]
104+
----
105+
$ ./mvnw eclipse:eclipse
106+
----
107+
108+
The generated eclipse projects can be imported by selecting `import existing projects`
109+
from the `file` menu.
110+
111+
112+
== Contributing
113+
114+
:spring-cloud-build-branch: master
115+
116+
Spring Cloud is released under the non-restrictive Apache 2.0 license,
117+
and follows a very standard Github development process, using Github
118+
tracker for issues and merging pull requests into master. If you want
119+
to contribute even something trivial please do not hesitate, but
120+
follow the guidelines below.
121+
122+
=== Sign the Contributor License Agreement
123+
Before we accept a non-trivial patch or pull request we will need you to sign the
124+
https://cla.pivotal.io/sign/spring[Contributor License Agreement].
125+
Signing the contributor's agreement does not grant anyone commit rights to the main
126+
repository, but it does mean that we can accept your contributions, and you will get an
127+
author credit if we do. Active contributors might be asked to join the core team, and
128+
given the ability to merge pull requests.
129+
130+
=== Code of Conduct
131+
This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of
132+
conduct]. By participating, you are expected to uphold this code. Please report
133+
unacceptable behavior to [email protected].
134+
135+
=== Code Conventions and Housekeeping
136+
None of these is essential for a pull request, but they will all help. They can also be
137+
added after the original pull request but before a merge.
138+
139+
* Use the Spring Framework code format conventions. If you use Eclipse
140+
you can import formatter settings using the
141+
`eclipse-code-formatter.xml` file from the
142+
https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring
143+
Cloud Build] project. If using IntelliJ, you can use the
144+
https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter
145+
Plugin] to import the same file.
146+
* Make sure all new `.java` files to have a simple Javadoc class comment with at least an
147+
`@author` tag identifying you, and preferably at least a paragraph on what the class is
148+
for.
149+
* Add the ASF license header comment to all new `.java` files (copy from existing files
150+
in the project)
151+
* Add yourself as an `@author` to the .java files that you modify substantially (more
152+
than cosmetic changes).
153+
* Add some Javadocs and, if you change the namespace, some XSD doc elements.
154+
* A few unit tests would help a lot as well -- someone has to do it.
155+
* If no-one else is using your branch, please rebase it against the current master (or
156+
other target branch in the main project).
157+
* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions],
158+
if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit
159+
message (where XXXX is the issue number).
160+
161+
=== Checkstyle
162+
163+
Spring Cloud Build comes with a set of checkstyle rules. You can find them in the `spring-cloud-build-tools` module. The most notable files under the module are:
164+
165+
.spring-cloud-build-tools/
166+
----
167+
└── src
168+
   ├── checkstyle
169+
   │   └── checkstyle-suppressions.xml <3>
170+
   └── main
171+
   └── resources
172+
   ├── checkstyle-header.txt <2>
173+
   └── checkstyle.xml <1>
174+
----
175+
<1> Default Checkstyle rules
176+
<2> File header setup
177+
<3> Default suppression rules
178+
179+
==== Checkstyle configuration
180+
181+
Checkstyle rules are *disabled by default*. To add checkstyle to your project just define the following properties and plugins.
182+
183+
.pom.xml
184+
----
185+
<properties>
186+
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError> <1>
187+
<maven-checkstyle-plugin.failsOnViolation>true
188+
</maven-checkstyle-plugin.failsOnViolation> <2>
189+
<maven-checkstyle-plugin.includeTestSourceDirectory>true
190+
</maven-checkstyle-plugin.includeTestSourceDirectory> <3>
191+
</properties>
192+
193+
<build>
194+
<plugins>
195+
<plugin> <4>
196+
<groupId>io.spring.javaformat</groupId>
197+
<artifactId>spring-javaformat-maven-plugin</artifactId>
198+
</plugin>
199+
<plugin> <5>
200+
<groupId>org.apache.maven.plugins</groupId>
201+
<artifactId>maven-checkstyle-plugin</artifactId>
202+
</plugin>
203+
</plugins>
204+
205+
<reporting>
206+
<plugins>
207+
<plugin> <5>
208+
<groupId>org.apache.maven.plugins</groupId>
209+
<artifactId>maven-checkstyle-plugin</artifactId>
210+
</plugin>
211+
</plugins>
212+
</reporting>
213+
</build>
214+
----
215+
<1> Fails the build upon Checkstyle errors
216+
<2> Fails the build upon Checkstyle violations
217+
<3> Checkstyle analyzes also the test sources
218+
<4> Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules
219+
<5> Add checkstyle plugin to your build and reporting phases
220+
221+
If you need to suppress some rules (e.g. line length needs to be longer), then it's enough for you to define a file under `${project.root}/src/checkstyle/checkstyle-suppressions.xml` with your suppressions. Example:
222+
223+
.projectRoot/src/checkstyle/checkstyle-suppresions.xml
224+
----
225+
<?xml version="1.0"?>
226+
<!DOCTYPE suppressions PUBLIC
227+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
228+
"https://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
229+
<suppressions>
230+
<suppress files=".*ConfigServerApplication\.java" checks="HideUtilityClassConstructor"/>
231+
<suppress files=".*ConfigClientWatch\.java" checks="LineLengthCheck"/>
232+
</suppressions>
233+
----
234+
235+
It's advisable to copy the `${spring-cloud-build.rootFolder}/.editorconfig` and `${spring-cloud-build.rootFolder}/.springformat` to your project. That way, some default formatting rules will be applied. You can do so by running this script:
236+
237+
```bash
238+
$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig
239+
$ touch .springformat
240+
```
241+
242+
=== IDE setup
243+
244+
==== Intellij IDEA
245+
246+
In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin.
247+
The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project.
248+
249+
.spring-cloud-build-tools/
250+
----
251+
└── src
252+
   ├── checkstyle
253+
   │   └── checkstyle-suppressions.xml <3>
254+
   └── main
255+
   └── resources
256+
   ├── checkstyle-header.txt <2>
257+
   ├── checkstyle.xml <1>
258+
   └── intellij
259+
      ├── Intellij_Project_Defaults.xml <4>
260+
      └── Intellij_Spring_Boot_Java_Conventions.xml <5>
261+
----
262+
<1> Default Checkstyle rules
263+
<2> File header setup
264+
<3> Default suppression rules
265+
<4> Project defaults for Intellij that apply most of Checkstyle rules
266+
<5> Project style conventions for Intellij that apply most of Checkstyle rules
267+
268+
.Code style
269+
270+
image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style]
271+
272+
Go to `File` -> `Settings` -> `Editor` -> `Code style`. There click on the icon next to the `Scheme` section. There, click on the `Import Scheme` value and pick the `Intellij IDEA code style XML` option. Import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml` file.
273+
274+
.Inspection profiles
275+
276+
image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style]
277+
278+
Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon next to the `Profile` section. There, click on the `Import Profile` and import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml` file.
279+
280+
.Checkstyle
281+
282+
To have Intellij work with Checkstyle, you have to install the `Checkstyle` plugin. It's advisable to also install the `Assertions2Assertj` to automatically convert the JUnit assertions
283+
284+
image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle]
285+
286+
Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables:
287+
288+
- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL.
289+
- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL.
290+
- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`.
291+
292+
IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources.
293+
294+
=== Duplicate Finder
295+
296+
Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath.
297+
298+
==== Duplicate Finder configuration
299+
300+
Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`.
301+
302+
.pom.xml
303+
[source,xml]
304+
----
305+
<build>
306+
<plugins>
307+
<plugin>
308+
<groupId>org.basepom.maven</groupId>
309+
<artifactId>duplicate-finder-maven-plugin</artifactId>
310+
</plugin>
311+
</plugins>
312+
</build>
313+
----
314+
315+
For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation].
316+
317+
You can easily override them but setting the value of the selected property prefixed with `duplicate-finder-maven-plugin`. For example, set `duplicate-finder-maven-plugin.skip` to `true` in order to skip duplicates check in your build.
318+
319+
If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project:
320+
321+
[source,xml]
322+
----
323+
<build>
324+
<plugins>
325+
<plugin>
326+
<groupId>org.basepom.maven</groupId>
327+
<artifactId>duplicate-finder-maven-plugin</artifactId>
328+
<configuration>
329+
<ignoredClassPatterns>
330+
<ignoredClassPattern>org.joda.time.base.BaseDateTime</ignoredClassPattern>
331+
<ignoredClassPattern>.*module-info</ignoredClassPattern>
332+
</ignoredClassPatterns>
333+
<ignoredResourcePatterns>
334+
<ignoredResourcePattern>changelog.txt</ignoredResourcePattern>
335+
</ignoredResourcePatterns>
336+
</configuration>
337+
</plugin>
338+
</plugins>
339+
</build>
340+
341+
342+
----
343+
344+
12345
== Quick Start
13346

14347
:leveloffset: +1
@@ -172,7 +505,7 @@ class AService {
172505
@Autowired
173506
HelloClient client;
174507
175-
public String hello() throws IOException {
508+
public Mono<String> hello() throws IOException {
176509
return client.hello();
177510
}
178511
}

docs/src/main/asciidoc/README.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
image::https://github.com/spring-projects-experimental/spring-cloud-square/workflows/Build/badge.svg?style=svg["Build",link="https://github.com/spring-projects-experimental/spring-cloud-square/actions"]
44

5+
include::intro.adoc[]
6+
7+
== Building
8+
9+
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/building.adoc[]
10+
11+
== Contributing
12+
13+
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/contributing.adoc[]
14+
515
== Quick Start
616

717
include::quickstart.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)