This commit is contained in:
Marcin Grzejszczak
2023-09-06 18:53:27 +02:00
parent e9abbc8844
commit 9799f8df41
37 changed files with 2889 additions and 1492 deletions

4
.gitignore vendored
View File

@@ -18,4 +18,6 @@ _site/
.factorypath
.vscode/
.flattened-pom.xml
.DS_Store
.DS_Store
node_modules
node

View File

@@ -1,46 +1,43 @@
# PACKAGES antora@3.2.0-alpha.2 @antora/atlas-extension:1.0.0-alpha.1 @antora/collector-extension@1.0.0-alpha.3 @springio/antora-extensions@1.3.0 @asciidoctor/tabs@1.0.0-beta.3 @springio/asciidoctor-extensions @opendevise/antora-release-line-extension@1.0.0
#
# The purpose of this Antora playbook is to build the docs in the current branch.
antora:
extensions:
- '@antora/collector-extension'
- id: '@antora/atlas-extension'
require: '@antora/atlas-extension'
enabled: false
- '@springio/antora-extensions/latest-version-extension'
- require: '@springio/antora-extensions/root-component-extension'
root_component_name: 'micrometer'
- '@springio/antora-extensions/partial-build-extension'
- require: '@springio/antora-extensions/latest-version-extension'
- require: '@springio/antora-extensions/inject-collector-cache-config-extension'
- '@antora/collector-extension'
- '@antora/atlas-extension'
- require: '@springio/antora-extensions/root-component-extension'
root_component_name: 'cloud-build'
# FIXME: Run antora once using this extension to migrate to the Asciidoc Tabs syntax
# and then remove this extension
- require: '@springio/antora-extensions/tabs-migration-extension'
unwrap_example_block: always
save_result: true
site:
title: Micrometer
url: https://micrometer.io/docs/micrometer/reference/
robots: allow
git:
ensure_git_suffix: false
title: Spring Cloud Build
url: https://docs.spring.io/spring-cloud-build/reference/
content:
sources:
- url: ./..
branches: HEAD
start_path: docs
worktrees: true
- url: ./..
branches: HEAD
start_path: docs
worktrees: true
asciidoc:
attributes:
hide-uri-scheme: '@'
page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud
page-pagination: ''
hide-uri-scheme: '@'
tabs-sync-option: '@'
chomp: 'all'
extensions:
- '@asciidoctor/tabs'
- '@springio/asciidoctor-extensions'
- '@springio/asciidoctor-extensions/include-code-extension'
- '@asciidoctor/tabs'
- '@springio/asciidoctor-extensions'
sourcemap: true
urls:
latest_version_segment_strategy: redirect:to
latest_version_segment: ''
redirect_facility: httpd
runtime:
log:
failure_level: error
failure_level: warn
format: pretty
ui:
bundle:
url: https://github.com/rwinch/antora-ui-micrometer/releases/download/latest/ui-bundle.zip
snapshot: true
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.4/ui-bundle.zip

12
docs/antora.yml Normal file
View File

@@ -0,0 +1,12 @@
name: cloud-build
version: true
title: Spring Cloud Build
nav:
- modules/ROOT/nav.adoc
ext:
collector:
run:
command: ./mvnw validate process-resources -Pdocs -pl docs
local: true
scan:
dir: ./target/classes/antora-resources/

View File

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

View File

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

View File

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -1,46 +0,0 @@
antora:
extensions:
- '@springio/antora-extensions/partial-build-extension'
- require: '@springio/antora-extensions/latest-version-extension'
- require: '@springio/antora-extensions/inject-collector-cache-config-extension'
- '@antora/collector-extension'
- '@antora/atlas-extension'
- require: '@springio/antora-extensions/root-component-extension'
root_component_name: 'shell' # FIXME: Change this to match `name:` in antora.yml
# FIXME: Run antora once using this extension to migrate to the Asciidoc Tabs syntax
# and then remove this extension
- require: '@springio/antora-extensions/tabs-migration-extension'
unwrap_example_block: always
save_result: true
site:
title: Spring Shell # FIXME: Change to your Project's title
url: https://docs.spring.io/spring-shell/reference/ # FIXME: Change to your Project's URL
content:
sources:
- url: ./..
branches: HEAD
# FIXME: Change this to the path to the directory containing antora.yml in your project
# See https://docs.antora.org/antora/latest/playbook/content-source-start-path/#start-path-key
start_path: spring-shell-docs
worktrees: true
asciidoc:
attributes:
# FIXME: Change to your stackoverflow URL or remove
page-stackoverflow-url: https://stackoverflow.com/tags/spring-shell
page-pagination: ''
hide-uri-scheme: '@'
tabs-sync-option: '@'
chomp: 'all'
extensions:
- '@asciidoctor/tabs'
- '@springio/asciidoctor-extensions'
sourcemap: true
urls:
latest_version_segment: ''
runtime:
log:
failure_level: warn
format: pretty
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.4/ui-bundle.zip

View File

@@ -1,25 +0,0 @@
name: shell # FIXME: Change to your project name typically just remove spring- from the artifact name
version: true
title: Spring Shell # FIXME: Change to the title of your Project's docs
nav:
- modules/ROOT/nav.adoc
ext:
collector:
run:
# FIXME Change "command" to the command that generates your antora.yml and other antora resources
# See https://gitlab.com/antora/antora-collector-extension/-/blob/main/docs/modules/ROOT/pages/configuration-keys.adoc?ref_type=heads#collector-reference
# HINT: Maven is typically something like:
# ./mvnw validate process-resources -am -Pantora-process-resources
command: gradlew -q "-Dorg.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError" :spring-shell-docs:generateAntoraYml
local: true
scan:
# FIXME Change "dir" to the location that generated files are at
# See https://gitlab.com/antora/antora-collector-extension/-/blob/main/docs/modules/ROOT/pages/configuration-keys.adoc?ref_type=heads#collector-reference
# HINT: Maven is typically something like:
# target/classes/antora-resources/
dir: ./build/generated-antora-resources
asciidoc:
attributes:
attribute-missing: 'warn'
chomp: 'all'

2788
docs/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

11
docs/package.json Normal file
View File

@@ -0,0 +1,11 @@
{
"dependencies": {
"@antora/atlas-extension": "^1.0.0-alpha.1",
"@antora/cli": "^3.2.0-alpha.2",
"@antora/collector-extension": "^1.0.0-alpha.3",
"@antora/site-generator-default": "^3.2.0-alpha.2",
"@asciidoctor/tabs": "^1.0.0-beta.3",
"@springio/antora-extensions": "^1.5.0",
"@springio/asciidoctor-extensions": "^1.0.0-alpha.9"
}
}

View File

@@ -59,14 +59,6 @@
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main</directory>
<excludes>
<exclude>java/**/*.*</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -97,6 +89,12 @@
<profile>
<id>docs</id>
<build>
<resources>
<resource>
<directory>src/main/antora/resources/antora-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
@@ -106,17 +104,25 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<groupId>io.spring.maven.antora</groupId>
<artifactId>antora-component-version-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.spring.maven.antora</groupId>
<artifactId>antora-maven-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>antora</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@@ -1,31 +1,20 @@
name: cloud-build
version: ${antora-component.version}
prerelease: ${antora-component.prerelease}
title: Spring Cloud Build
nav:
- modules/ROOT/nav.adoc
ext:
collector:
run:
command: ./mvnw validate process-resources -am -Pantora-process-resources,docs -pl docs
local: true
scan:
dir: ./target/classes/antora-resources/
version: @antora-component.version@
prerelease: @antora-component.prerelease@
asciidoc:
attributes:
attribute-missing: 'warn'
chomp: 'all'
project-root: ${maven.multiModuleProjectDirectory}
github-repo: ${docs.main}
github-raw: https://raw.githubusercontent.com/spring-cloud/${docs.main}/${github-tag}
github-code: https://github.com/spring-cloud/${docs.main}/tree/${github-tag}
github-issues: https://github.com/spring-cloud/${docs.main}/issues/@
github-wiki: https://github.com/spring-cloud/${docs.main}/wiki
spring-cloud-version: ${project.version}
github-tag: ${github-tag}
version-type: ${version-type}
docs-url: https://docs.spring.io/${docs.main}/docs/${project.version}
raw-docs-url: ${github-raw}
project-version: ${project.version}
project-name: ${docs.main}
project-root: @maven.multiModuleProjectDirectory@
github-repo: @docs.main@
github-raw: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@
github-code: https://github.com/spring-cloud/@docs.main@/tree/@github-tag@
github-issues: https://github.com/spring-cloud/@docs.main@/issues/
github-wiki: https://github.com/spring-cloud/@docs.main@/wiki
spring-cloud-version: @project.version@
github-tag: @github-tag@
version-type: @version-type@
docs-url: https://docs.spring.io/@docs.main@/docs/@project.version@
raw-docs-url: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@
project-version: @project.version@
project-name: @docs.main@

View File

@@ -1,163 +0,0 @@
image::https://github.com/spring-cloud/spring-cloud-build/workflows/Build/badge.svg?branch=main&style=svg["Build",link="https://github.com/spring-cloud/spring-cloud-build/actions"]
Spring Cloud Build is a common utility project for Spring Cloud
to use for plugin and dependency management.
== Building and Deploying
To install locally:
----
$ mvn install -s .settings.xml
----
and to deploy snapshots to repo.spring.io:
----
$ mvn deploy -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/snapshot
----
for a RELEASE build use
----
$ mvn deploy -DaltReleaseDeploymentRepository=repo.spring.io::default::https://repo.spring.io/release
----
and for jcenter use
----
$ mvn deploy -DaltReleaseDeploymentRepository=bintray::default::https://api.bintray.com/maven/spring/jars/org.springframework.cloud:build
----
and for Maven Central use
----
$ mvn deploy -P central -DaltReleaseDeploymentRepository=sonatype-nexus-staging::default::https://oss.sonatype.org/service/local/staging/deploy/maven2
----
(the "central" profile is available for all projects in Spring Cloud and it sets up the gpg jar signing, and the repository has to be specified separately for this project because it is a parent of the starter parent which users in turn have as their own parent).
== Contributing
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/contributing.adoc[]
== Flattening the POMs
To avoid propagating build setup that is required to build a Spring Cloud project, we're using the maven flatten plugin. It has the advantage of letting you use whatever features you need while publishing "clean" pom to the repository.
In order to add it, add the `org.codehaus.mojo:flatten-maven-plugin` to your `pom.xml`.
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
----
== Reusing the documentation
Spring Cloud Build publishes its `spring-cloud-build-docs` module that contains
helpful scripts (e.g. README generation ruby script) and css, xslt and images
for the Spring Cloud documentation. If you want to follow the same convention
approach of generating documentation just add these plugins to your `docs` module
[source,xml]
----
<properties>
<upload-docs-zip.phase>deploy</upload-docs-zip.phase> <8>
</properties>
<profiles>
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId> <1>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <2>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <3>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId> <4>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId> <5>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId> <6>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId> <7>
</plugin>
</plugins>
</build>
</profile>
</profiles>
----
<1> This plugin downloads sets up all the git information of the project
<2> This plugin downloads the resources of the `spring-cloud-build-docs` module
<3> This plugin unpacks the resources of the `spring-cloud-build-docs` module
<4> This plugin generates an `adoc` file with all the configuration properties from the classpath
<5> This plugin is required to parse the Asciidoctor documentation
<6> This plugin is required to copy resources into proper final destinations and to generate main README.adoc and to assert that no files use unresolved links
<7> This plugin ensures that the generated zip docs will get published
<8> This property turns on the "deploy" phase for <7>
IMPORTANT: The order of plugin declaration is important!
In order for the build to generate the `adoc` file with all your configuration properties, your `docs` module should contain all the dependencies on the classpath, that you would want to scan for configuration properties. The file will be output to `${docsModule}/src/main/asciidoc/_configprops.adoc` file (configurable via the `configprops.path` property).
If you want to modify which of the configuration properties are put in the table, you can tweak the `configprops.inclusionPattern` pattern to include only a subset of the properties (e.g. `<configprops.inclusionPattern>spring.sleuth.*</configprops.inclusionPattern>`).
Spring Cloud Build Docs comes with a set of attributes for asciidoctor that you can reuse.
[source,xml]
----
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/pom.xml[tags=attributes,indent=0]
----
== Updating the guides
We assume that your project contains guides under the `guides` folder.
```
.
└── guides
├── gs-guide1
├── gs-guide2
└── gs-guide3
```
This means that the project contains 3 guides that would
correspond to the following guides in Spring Guides org.
- https://github.com/spring-guides/gs-guide1
- https://github.com/spring-guides/gs-guide2
- https://github.com/spring-guides/gs-guide3
If you deploy your project with the `-Pguides` profile like this
```
$ ./mvnw clean deploy -Pguides
```
what will happen is that for GA project versions, we will clone `gs-guide1`, `gs-guide2` and `gs-guide3` and update their contents with the ones being under your `guides` project.
You can skip this by either not adding the `guides` profile, or passing the `-DskipGuides` system property when the profile is turned on.
You can configure the project version passed to guides via the `guides-project.version` (defaults to `${project.version}`). The phase at which guides get updated can be configured by `guides-update.phase` (defaults to `deploy`).

View File

@@ -1,3 +0,0 @@
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/building.adoc[]

View File

@@ -1,79 +0,0 @@
:jdkversion: 17
=== Basic Compile and Test
To build the source you will need to install JDK {jdkversion}.
Spring Cloud uses Maven for most build-related activities, and you
should be able to get off the ground quite quickly by cloning the
project you are interested in and typing
----
$ ./mvnw install
----
NOTE: You can also install Maven (>=3.3.3) yourself and run the `mvn` command
in place of `./mvnw` in the examples below. If you do that you also
might need to add `-P spring` if your local Maven settings do not
contain repository declarations for spring pre-release artifacts.
NOTE: Be aware that you might need to increase the amount of memory
available to Maven by setting a `MAVEN_OPTS` environment variable with
a value like `-Xmx512m -XX:MaxPermSize=128m`. We try to cover this in
the `.mvn` configuration, so if you find you have to do it to make a
build succeed, please raise a ticket to get the settings added to
source control.
The projects that require middleware (i.e. Redis) for testing generally
require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running.
=== Documentation
The spring-cloud-build module has a "docs" profile, and if you switch
that on it will try to build asciidoc sources from
`src/main/asciidoc`. As part of that process it will look for a
`README.adoc` and process it by loading all the includes, but not
parsing or rendering it, just copying it to `${main.basedir}`
(defaults to `${basedir}`, i.e. the root of the project). If there are
any changes in the README it will then show up after a Maven build as
a modified file in the correct place. Just commit it and push the change.
=== Working with the code
If you don't have an IDE preference we would recommend that you use
https://www.springsource.com/developer/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 as long as they use Maven 3.3.3 or better.
==== Activate the Spring Maven profile
Spring Cloud projects require the 'spring' Maven profile to be activated to resolve
the spring milestone and snapshot repositories. Use your preferred IDE to set this
profile to be active, or you may experience build errors.
==== Importing into eclipse with m2eclipse
We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with
eclipse. If you don't already have m2eclipse installed it is available from the "eclipse
marketplace".
NOTE: Older versions of m2e do not support Maven 3.3, so once the
projects are imported into Eclipse you will also need to tell
m2eclipse to use the right profile for the projects. If you
see many different errors related to the POMs in the projects, check
that you have an up to date installation. If you can't upgrade m2e,
add the "spring" profile to your `settings.xml`. Alternatively you can
copy the repository settings from the "spring" profile of the parent
pom into your `settings.xml`.
==== Importing into eclipse without m2eclipse
If you prefer not to use m2eclipse you can generate eclipse project metadata using the
following command:
[indent=0]
----
$ ./mvnw eclipse:eclipse
----
The generated eclipse projects can be imported by selecting `import existing projects`
from the `file` menu.

View File

@@ -1,45 +0,0 @@
= Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open
and welcoming community, we pledge to respect all people who contribute through reporting
issues, posting feature requests, updating documentation, submitting pull requests or
patches, and other activities.
We are committed to making participation in this project a harassment-free experience for
everyone, regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses,
without explicit permission
* Other unethical or unprofessional conduct
Project maintainers have the right and responsibility to remove, edit, or reject comments,
commits, code, wiki edits, issues, and other contributions that are not aligned to this
Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors
that they deem inappropriate, threatening, offensive, or harmful.
By adopting this Code of Conduct, project maintainers commit themselves to fairly and
consistently applying these principles to every aspect of managing this project. Project
maintainers who do not follow or enforce the Code of Conduct may be permanently removed
from the project team.
This Code of Conduct applies both within project spaces and in public spaces when an
individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
contacting a project maintainer at spring-code-of-conduct@pivotal.io . All complaints will
be reviewed and investigated and will result in a response that is deemed necessary and
appropriate to the circumstances. Maintainers are obligated to maintain confidentiality
with regard to the reporter of an incident.
This Code of Conduct is adapted from the
https://contributor-covenant.org[Contributor Covenant], version 1.3.0, available at
https://contributor-covenant.org/version/1/3/0/[contributor-covenant.org/version/1/3/0/]

View File

@@ -1 +0,0 @@
NOTE: Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at {github-project}[github].

View File

@@ -1,230 +0,0 @@
:spring-cloud-build-branch: master
Spring Cloud is released under the non-restrictive Apache 2.0 license,
and follows a very standard Github development process, using Github
tracker for issues and merging pull requests into master. If you want
to contribute even something trivial please do not hesitate, but
follow the guidelines below.
=== Sign the Contributor License Agreement
Before we accept a non-trivial patch or pull request we will need you to sign the
https://cla.pivotal.io/sign/spring[Contributor License Agreement].
Signing the contributor's agreement does not grant anyone commit rights to the main
repository, but it does mean that we can accept your contributions, and you will get an
author credit if we do. Active contributors might be asked to join the core team, and
given the ability to merge pull requests.
=== Code of Conduct
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
conduct]. By participating, you are expected to uphold this code. Please report
unacceptable behavior to spring-code-of-conduct@pivotal.io.
=== Code Conventions and Housekeeping
None of these is essential for a pull request, but they will all help. They can also be
added after the original pull request but before a merge.
* Use the Spring Framework code format conventions. If you use Eclipse
you can import formatter settings using the
`eclipse-code-formatter.xml` file from the
https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring
Cloud Build] project. If using IntelliJ, you can use the
https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter
Plugin] to import the same file.
* 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.
* Add the ASF license header comment to all new `.java` files (copy from existing files
in the project)
* Add yourself as an `@author` to the .java files that you modify substantially (more
than cosmetic changes).
* Add some Javadocs and, if you change the namespace, some XSD doc elements.
* A few unit tests would help a lot as well -- someone has to do it.
* If no-one else is using your branch, please rebase it against the current master (or
other target branch in the main project).
* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions],
if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit
message (where XXXX is the issue number).
=== Checkstyle
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:
.spring-cloud-build-tools/
----
└── src
   ├── checkstyle
   │   └── checkstyle-suppressions.xml <3>
   └── main
   └── resources
   ├── checkstyle-header.txt <2>
   └── checkstyle.xml <1>
----
<1> Default Checkstyle rules
<2> File header setup
<3> Default suppression rules
==== Checkstyle configuration
Checkstyle rules are *disabled by default*. To add checkstyle to your project just define the following properties and plugins.
.pom.xml
----
<properties>
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError> <1>
<maven-checkstyle-plugin.failsOnViolation>true
</maven-checkstyle-plugin.failsOnViolation> <2>
<maven-checkstyle-plugin.includeTestSourceDirectory>true
</maven-checkstyle-plugin.includeTestSourceDirectory> <3>
</properties>
<build>
<plugins>
<plugin> <4>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
</plugin>
<plugin> <5>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
<reporting>
<plugins>
<plugin> <5>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</build>
----
<1> Fails the build upon Checkstyle errors
<2> Fails the build upon Checkstyle violations
<3> Checkstyle analyzes also the test sources
<4> Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules
<5> Add checkstyle plugin to your build and reporting phases
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:
.projectRoot/src/checkstyle/checkstyle-suppresions.xml
----
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"https://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files=".*ConfigServerApplication\.java" checks="HideUtilityClassConstructor"/>
<suppress files=".*ConfigClientWatch\.java" checks="LineLengthCheck"/>
</suppressions>
----
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:
```bash
$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig
$ touch .springformat
```
=== IDE setup
==== Intellij IDEA
In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin.
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.
.spring-cloud-build-tools/
----
└── src
   ├── checkstyle
   │   └── checkstyle-suppressions.xml <3>
   └── main
   └── resources
   ├── checkstyle-header.txt <2>
   ├── checkstyle.xml <1>
   └── intellij
      ├── Intellij_Project_Defaults.xml <4>
      └── Intellij_Spring_Boot_Java_Conventions.xml <5>
----
<1> Default Checkstyle rules
<2> File header setup
<3> Default suppression rules
<4> Project defaults for Intellij that apply most of Checkstyle rules
<5> Project style conventions for Intellij that apply most of Checkstyle rules
.Code style
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]
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.
.Inspection profiles
image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style]
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.
.Checkstyle
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
image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle]
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:
- `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.
- `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.
- `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`.
IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources.
=== Duplicate Finder
Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath.
==== Duplicate Finder configuration
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`.
.pom.xml
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
----
For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation].
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.
If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project:
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<configuration>
<ignoredClassPatterns>
<ignoredClassPattern>org.joda.time.base.BaseDateTime</ignoredClassPattern>
<ignoredClassPattern>.*module-info</ignoredClassPattern>
</ignoredClassPatterns>
<ignoredResourcePatterns>
<ignoredResourcePattern>changelog.txt</ignoredResourcePattern>
</ignoredResourcePatterns>
</configuration>
</plugin>
</plugins>
</build>
----

View File

@@ -1,423 +0,0 @@
#!/bin/bash
# Usage: (cd <project root>; ghpages.sh -v <version> -b -c)
set -e
export GIT_BIN ROOT_FOLDER COMMIT_CHANGES MAVEN_PATH MAVEN_EXEC REPO_NAME SPRING_CLOUD_STATIC_REPO SPRING_CLOUD_STATIC_REPO_DESTINATION
export CURRENT_BRANCH PREVIOUS_BRANCH
export GITHUB_REPO_USERNAME_ENV="${GITHUB_REPO_USERNAME_ENV:-GITHUB_REPO_USERNAME}"
export GITHUB_REPO_PASSWORD_ENV="${GITHUB_REPO_PASSWORD_ENV:-GITHUB_REPO_PASSWORD}"
REPO_USER="${!GITHUB_REPO_USERNAME_ENV}"
REPO_PASS="${!GITHUB_REPO_PASSWORD_ENV}"
export SPRING_CLOUD_STATIC_REPO_DESTINATION="${SPRING_CLOUD_STATIC_REPO_DESTINATION:-$( dirname "$(mktemp)")/}"
GIT_BIN="${GIT_BIN:-git}"
cat <<EOF
!!! WARNING !!!
THIS SCRIPT IS DEPRECATED!!
We're migrating away from using gh-pages at all. We're moving to using docs.spring.io and the zipped documentation.
Please migrate to the new approach as soon as possible since this script will be removed soon.
!!! WARNING !!!
EOF
# The script should be run from the root folder
ROOT_FOLDER="$( pwd )"
echo "Current folder is [${ROOT_FOLDER}]"
echo "Spring Cloud Static repo is [${SPRING_CLOUD_STATIC_REPO_DESTINATION}]"
# Set default props like MAVEN_PATH, ROOT_FOLDER etc.
function set_default_props() {
if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then
echo "You're not in the root folder of the project!"
exit 1
fi
# Prop that will let commit the changes
COMMIT_CHANGES="no"
MAVEN_PATH=${MAVEN_PATH:-}
if [ -e "${ROOT_FOLDER}/mvnw" ]; then
MAVEN_EXEC="$ROOT_FOLDER/mvnw"
else
MAVEN_EXEC="${MAVEN_PATH}mvn"
fi
echo "Path to Maven is [${MAVEN_EXEC}]"
if [ -z "${REPO_NAME}" ]; then
REPO_NAME="$("${GIT_BIN}" remote -v | grep origin | head -1 | sed -e 's!.*/!!' -e 's/ .*//' -e 's/\.git.*//')"
fi
echo "Repo name is [${REPO_NAME}]"
SPRING_CLOUD_STATIC_REPO=${SPRING_CLOUD_STATIC_REPO:-git@github.com:spring-cloud/spring-cloud-static.git}
echo "Spring Cloud Static repo is [${SPRING_CLOUD_STATIC_REPO}"
}
# Adds the oauth token if present to the remote url
function add_oauth_token_to_remote_url() {
local remote
remote="$( "${GIT_BIN}" config remote.origin.url | sed -e 's/^git:/https:/' )"
echo "Current remote [${remote}]"
if [[ ${remote} != *".git" ]]; then
echo "Remote doesn't end with [.git]"
remote="${remote}.git"
echo "Remote with [.git] suffix: [${remote}]"
fi
if [[ "${REPO_USER}" != "" && ${remote} != *"@"* ]]; then
withUserAndPass=${remote/https:\/\//https://${REPO_USER}:${REPO_PASS}@}
echo "Username and password found. Will reuse it to push the code to [${withUserAndPass}]"
"${GIT_BIN}" remote set-url --push origin "${withUserAndPass}"
elif [[ "${RELEASER_GIT_OAUTH_TOKEN}" != "" && ${remote} != *"@"* ]]; then
withToken=${remote/https:\/\//https://${RELEASER_GIT_OAUTH_TOKEN}@}
echo "OAuth token found. Will reuse it to push the code to [${withToken}]"
"${GIT_BIN}" remote set-url --push origin "${withToken}"
else
echo "No OAuth token found. Will push to [${remote}]"
"${GIT_BIN}" remote set-url --push origin "${remote}"
fi
}
# Check if gh-pages exists and docs have been built
function check_if_anything_to_sync() {
add_oauth_token_to_remote_url
if [[ "${RELEASE_TRAIN}" != "yes" ]] && ! ("${GIT_BIN}" remote set-branches --add origin gh-pages && "${GIT_BIN}" fetch -q) ; then
echo "No gh-pages, so not syncing"
exit 0
fi
if ! [ -d docs/target/generated-docs ] && ! [ "${BUILD}" == "yes" ]; then
echo "No gh-pages sources in docs/target/generated-docs, so not syncing"
exit 0
fi
}
function retrieve_current_branch() {
# Code getting the name of the current branch. For master we want to publish as we did until now
# https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch
# If there is a branch already passed will reuse it - otherwise will try to find it
CURRENT_BRANCH=${BRANCH}
if [[ -z "${CURRENT_BRANCH}" ]] ; then
CURRENT_BRANCH=$("${GIT_BIN}" symbolic-ref -q HEAD)
CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/}
CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD}
fi
echo "Current branch is [${CURRENT_BRANCH}]"
"${GIT_BIN}" checkout "${CURRENT_BRANCH}" || echo "Failed to check the branch... continuing with the script"
PREVIOUS_BRANCH="${CURRENT_BRANCH}"
echo "Previous branch was [${PREVIOUS_BRANCH}]"
}
# Switches to the provided value of the release version. We always prefix it with `v`
function switch_to_tag() {
if [[ "${RELEASE_TRAIN}" != "yes" ]] ; then
"${GIT_BIN}" checkout v"${VERSION}"
else
echo "Not switching to tag"
fi
}
# Build the docs if switch is on
function build_docs_if_applicable() {
if [[ "${BUILD}" == "yes" ]] ; then
./mvnw clean install -P docs -pl docs -DskipTests
else
echo "Not building docs"
fi
}
# Get the name of the `docs.main` property
# Get allowed branches - assumes that a `docs` module is available under `docs` profile
# shellcheck disable=SC2016
function retrieve_doc_properties() {
if [[ "${RELEASE_TRAIN}" == "yes" ]]; then
echo "Will not extract any properties for release train"
return
fi
ALLOW_PROPERTY=${ALLOW_PROPERTY:-"docs.allowed.branches"}
ALLOWED_BRANCHES_VALUE=$("${MAVEN_EXEC}" -q \
-Dexec.executable="echo" \
-Dexec.args="\${${ALLOW_PROPERTY}}" \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \
-P docs \
-pl docs | tail -1 )
echo "Extracted '${ALLOW_PROPERTY}' from Maven build [${ALLOWED_BRANCHES_VALUE}]"
}
# Stash any outstanding changes
function stash_changes() {
local success="false"
"${GIT_BIN}" diff-index --quiet HEAD && dirty=$? && success="true"
if [[ "${success}" == "false" ]]; then
echo "Failed to check if the current repo is dirty. Assuming that it is." && dirty="1"
fi
echo "The repo is dirty [${dirty}]"
if [ "$dirty" != "0" ]; then "${GIT_BIN}" stash; fi
}
# Switch to gh-pages branch to sync it with current branch
function add_docs_from_target() {
local DESTINATION_REPO_FOLDER
if [[ -z "${DESTINATION}" && -z "${CLONE}" ]] ; then
DESTINATION_REPO_FOLDER="${ROOT_FOLDER}"
elif [[ "${CLONE}" == "yes" ]]; then
mkdir -p "${ROOT_FOLDER}"/target
local clonedStatic="${SPRING_CLOUD_STATIC_REPO_DESTINATION}"/spring-cloud-static
if [[ ! -e "${clonedStatic}/.git" ]]; then
echo "Cloning Spring Cloud Static to [${clonedStatic}]"
"${GIT_BIN}" clone "${SPRING_CLOUD_STATIC_REPO}" "${clonedStatic}" && cd "${clonedStatic}" && "${GIT_BIN}" checkout gh-pages
else
echo "Spring Cloud Static already cloned to [${clonedStatic}] - will pull changes"
local pullSuccessful="false"
cd "${clonedStatic}" && "${GIT_BIN}" checkout gh-pages && "${GIT_BIN}" pull origin gh-pages && pullSuccessful="true" || echo "Failed to clone and pull versions - will remove the folder and clone it again"
if [[ "${pullSuccessful}" == "false" ]]; then
cd "${ROOT_FOLDER}"
echo "Removing the [${clonedStatic}] folder"
rm -rf "${clonedStatic}"
echo "Cloning Spring Cloud Static again"
"${GIT_BIN}" clone "${SPRING_CLOUD_STATIC_REPO}" "${clonedStatic}" && cd "${clonedStatic}" && "${GIT_BIN}" checkout gh-pages
fi
fi
if [[ -z "${RELEASE_TRAIN}" ]] ; then
DESTINATION_REPO_FOLDER="${clonedStatic}/${REPO_NAME}"
else
DESTINATION_REPO_FOLDER="${clonedStatic}"
fi
mkdir -p "${DESTINATION_REPO_FOLDER}"
else
if [[ ! -e "${DESTINATION}/.git" ]]; then
echo "[${DESTINATION}] is not a git repository"
exit 1
fi
if [[ -z "${RELEASE_TRAIN}" ]] ; then
DESTINATION_REPO_FOLDER="${DESTINATION}/${REPO_NAME}"
else
DESTINATION_REPO_FOLDER="${DESTINATION}"
fi
mkdir -p "${DESTINATION_REPO_FOLDER}"
echo "Destination was provided [${DESTINATION}]"
fi
cd "${DESTINATION_REPO_FOLDER}"
"${GIT_BIN}" checkout gh-pages
"${GIT_BIN}" pull origin gh-pages
# Add git branches
###################################################################
if [[ -z "${VERSION}" && -z "${RELEASE_TRAIN}" ]] ; then
copy_docs_for_current_version
else
copy_docs_for_provided_version
fi
commit_changes_if_applicable
}
# Copies the docs by using the retrieved properties from Maven build
function copy_docs_for_current_version() {
if [[ "${CURRENT_BRANCH}" == "master" ]] ; then
echo -e "Current branch is master - will copy the current docs only to the root folder"
for f in docs/target/generated-docs/*; do
file=${f#docs/target/generated-docs/*}
if ! "${GIT_BIN}" ls-files -i -o --exclude-standard --directory | grep -q ^"${file}"$; then
# Not ignored...
cp -rf "${f}" "${ROOT_FOLDER}"/
fi
done
"${GIT_BIN}" add -A "${ROOT_FOLDER}"
COMMIT_CHANGES="yes"
else
echo -e "Current branch is [${CURRENT_BRANCH}]"
# https://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin
if [[ ",${ALLOWED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then
mkdir -p "${ROOT_FOLDER}/${CURRENT_BRANCH}"
echo -e "Branch [${CURRENT_BRANCH}] is allowed! Will copy the current docs to the [${CURRENT_BRANCH}] folder"
for f in docs/target/generated-docs/*; do
file="${f#docs/target/generated-docs/*}"
if ! "${GIT_BIN}" ls-files -i -o --exclude-standard --directory | grep -q ^"${file}"$; then
echo "The file [${file}] shouldn't be ignored"
# Not ignored...
# We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html
cp -rf "${f}" "${ROOT_FOLDER}/${CURRENT_BRANCH}"
"${GIT_BIN}" add -A "${ROOT_FOLDER}/${CURRENT_BRANCH}/${file}" || echo "Failed to add the file [${file}]"
fi
done
COMMIT_CHANGES="yes"
else
echo -e "Branch [${CURRENT_BRANCH}] is not on the allow list! Check out the Maven [${ALLOW_PROPERTY}] property in
[docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch."
fi
fi
}
# Copies the docs by using the explicitly provided version
function copy_docs_for_provided_version() {
local FOLDER="${DESTINATION_REPO_FOLDER}/${VERSION}"
mkdir -p "${FOLDER}"
echo -e "Current tag is [v${VERSION}] Will copy the current docs to the [${FOLDER}] folder"
for f in "${ROOT_FOLDER}"/docs/target/generated-docs/*; do
file="${f#${ROOT_FOLDER}/docs/target/generated-docs/*}"
copy_docs_for_branch "${file}" "${FOLDER}"
done
COMMIT_CHANGES="yes"
CURRENT_BRANCH="v${VERSION}"
}
# Copies the docs from target to the provided destination
# Params:
# $1 - file from target
# $2 - destination to which copy the files
function copy_docs_for_branch() {
local file="$1"
local destination="$2"
echo "Copying file [${file}] to destination [${destination}]"
if ! "${GIT_BIN}" ls-files -i -o --exclude-standard --directory | grep -q ^"${file}"$; then
# Not ignored...
cp -rf "${f}" "${destination}"
"${GIT_BIN}" add -A "${destination}"
fi
}
function commit_changes_if_applicable() {
if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then
COMMIT_SUCCESSFUL="no"
"${GIT_BIN}" commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" && COMMIT_SUCCESSFUL="yes" || echo "Failed to commit changes"
# Uncomment the following push if you want to auto push to
# the gh-pages branch whenever you commit to master locally.
# This is a little extreme. Use with care!
###################################################################
if [[ "${COMMIT_SUCCESSFUL}" == "yes" ]] ; then
add_oauth_token_to_remote_url
"${GIT_BIN}" push origin gh-pages
fi
fi
}
# Switch back to the previous branch and exit block
function checkout_previous_branch() {
# If -version was provided we need to come back to root project
cd "${ROOT_FOLDER}"
"${GIT_BIN}" checkout "${PREVIOUS_BRANCH}" || echo "Failed to check the branch... continuing with the script"
if [ "$dirty" != "0" ]; then "${GIT_BIN}" stash pop; fi
return 0
}
# Assert if properties have been properly passed
function assert_properties() {
echo "VERSION [${VERSION}], RELEASE_TRAIN [${RELEASE_TRAIN}], DESTINATION [${DESTINATION}], CLONE [${CLONE}]"
if [[ "${VERSION}" != "" && (-z "${DESTINATION}" && -z "${CLONE}") ]] ; then echo "Version was set but destination / clone was not!"; exit 1;fi
if [[ ("${DESTINATION}" != "" && "${CLONE}" != "") && -z "${VERSION}" ]] ; then echo "Destination / clone was set but version was not!"; exit 1;fi
if [[ "${DESTINATION}" != "" && "${CLONE}" == "yes" ]] ; then echo "Destination and clone was set. Pick one!"; exit 1;fi
if [[ "${RELEASE_TRAIN}" != "" && -z "${VERSION}" ]] ; then echo "Release train was set but no version was passed!"; exit 1;fi
}
# Prints the usage
function print_usage() {
cat <<EOF
The idea of this script is to update gh-pages branch with the generated docs. Without any options
the script will work in the following manner:
- if there's no gh-pages / target for docs module then the script ends
- for master branch the generated docs are copied to the root of gh-pages branch
- for any other branch (if that branch is allowed) a subfolder with branch name is created
and docs are copied there
- if the version switch is passed (-v) then a tag with (v) prefix will be retrieved and a folder
with that version number will be created in the gh-pages branch. WARNING! No allow verification will take place
- if the destination switch is passed (-d) then the script will check if the provided dir is a git repo and then will
switch to gh-pages of that repo and copy the generated docs to [docs/<project-name>/<version>]
- if the destination switch is passed (-d) then the script will check if the provided dir is a git repo and then will
switch to gh-pages of that repo and copy the generated docs to [docs/<project-name>/<version>]
- if the release train switch is passed (-r) then the script will check if the provided dir is a git repo and then will
switch to gh-pages of that repo and copy the generated docs to [docs/<version>]
USAGE:
You can use the following options:
-v|--version - the script will apply the whole procedure for a particular library version
-r|--releasetrain - instead of nesting the docs under the project_name/version folder the docs will end up in version
-d|--destination - the root of destination folder where the docs should be copied. You have to use the full path.
E.g. point to spring-cloud-static folder. Can't be used with (-c)
-b|--build - will run the standard build process after checking out the branch
-c|--clone - will automatically clone the spring-cloud-static repo instead of providing the destination.
Obviously can't be used with (-d)
EOF
}
# ==========================================
# ____ ____ _____ _____ _____ _______
# / ____|/ ____| __ \|_ _| __ \__ __|
# | (___ | | | |__) | | | | |__) | | |
# \___ \| | | _ / | | | ___/ | |
# ____) | |____| | \ \ _| |_| | | |
# |_____/ \_____|_| \_\_____|_| |_|
#
# ==========================================
if [[ "${SOURCE_FUNCTIONS}" == "true" ]]; then
echo "Will just source functions. Will not run any commands"
else
while [[ $# -gt 0 ]]
do
key="$1"
case "${key}" in
-v|--version)
VERSION="$2"
shift # past argument
;;
-r|--releasetrain)
RELEASE_TRAIN="yes"
;;
-d|--destination)
DESTINATION="$2"
shift # past argument
;;
-b|--build)
BUILD="yes"
;;
-c|--clone)
CLONE="yes"
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "Invalid option: [$1]"
print_usage
exit 1
;;
esac
shift # past argument or value
done
assert_properties
set_default_props
check_if_anything_to_sync
retrieve_current_branch
if echo "${VERSION}" | grep -q -E 'SNAPSHOT' || [[ -z "${VERSION}" ]]; then
CLONE=""
VERSION=""
echo "You've provided a version variable but it's a snapshot one. Due to this will not clone spring-cloud-static and publish docs over there"
else
switch_to_tag
fi
build_docs_if_applicable
retrieve_doc_properties
stash_changes
add_docs_from_target
checkout_previous_branch
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -1 +0,0 @@
include::spring-cloud-build.adoc[]

View File

@@ -1,3 +0,0 @@
= Spring Cloud Build
include::README.adoc[]

View File

@@ -1,148 +0,0 @@
#!/bin/bash
set -e
GIT_BIN="${GIT_BIN:-git}"
echo "Project version is [${PROJECT_VERSION}]"
if [[ "${PROJECT_VERSION}" != *"RELEASE"* ]];then
echo "Will not update guides, since the version is not a RELEASE one"
exit 0
fi
# The script should be run from the root folder
[[ -z "${ROOT_FOLDER}" ]] && ROOT_FOLDER="$( pwd )"
echo "Current folder is ${ROOT_FOLDER}"
if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then
echo "You're not in the root folder of the project!"
exit 1
fi
GUIDES_FOLDER="${ROOT_FOLDER}/guides"
SPRING_GUIDES_REPO_ROOT="${SPRING_GUIDES_REPO_ROOT:-git@github.com:spring-guides}"
echo "The Spring Guides repo root is [${SPRING_GUIDES_REPO_ROOT}]"
if [[ ! -d "${GUIDES_FOLDER}" ]]; then
echo "No [guides] folder is present. Won't do anything"
exit 0
fi
function iterate_over_guides() {
for dir in "${GUIDES_FOLDER}"/*/ # list directories in the form "/tmp/dirname/"
do
local dir="${dir%*/}" # remove the trailing "/"
local folderName="${dir##*/}" # print everything after the final "/"
if [[ "${folderName}" == "target" ]]; then
echo "Skipping [${folderName}]"
continue
fi
local guideRepo="${SPRING_GUIDES_REPO_ROOT}/${folderName}"
local clonedGuideFolderParent="${ROOT_FOLDER}/target"
local clonedGuideFolder="${clonedGuideFolderParent}/${folderName}"
echo "Will clone [${guideRepo}] project [${folderName}] to target"
mkdir -p "${clonedGuideFolder}"
rm -rf "${clonedGuideFolder}"
"${GIT_BIN}" clone "${guideRepo}" "${clonedGuideFolder}"
pushd "${clonedGuideFolder}"
echo "Will start the commit process for [${folderName}]"
add_oauth_token_to_remote_url
remove_all_files
copy_new_guide "${GUIDES_FOLDER}/${folderName}" "${clonedGuideFolderParent}"
commit_and_push_new_guide_contents
echo "Successfully copied and pushed new guides for [${guideRepo}]"
popd
done
}
function commit_and_push_new_guide_contents() {
"${GIT_BIN}" add .
"${GIT_BIN}" commit -m "Updating guides" || echo "Nothing to commit"
"${GIT_BIN}" push origin master || echo "Nothing to push"
}
function copy_new_guide() {
local guideFolder="${1}"
local clonedGuideFolder="${2}"
echo "Will copy new guide files from [${guideFolder}/] to [${clonedGuideFolder}]"
cp -r "${guideFolder}/" "${clonedGuideFolder}/"
echo "Copied new guide files"
}
function remove_all_files() {
echo "Removing all non git files in [$( pwd )]"
"${GIT_BIN}" rm -rf "$( pwd )/"
"${GIT_BIN}" clean -fxd
echo "All files removed"
}
# Adds the oauth token if present to the remote url
function add_oauth_token_to_remote_url() {
local remote
remote="$( "${GIT_BIN}" config remote.origin.url | sed -e 's/^git:/https:/' )"
echo "Current remote [${remote}]"
if [[ "${RELEASER_GIT_OAUTH_TOKEN}" != "" && ${remote} != *"@"* ]]; then
echo "OAuth token found. Will reuse it to push the code"
withToken=${remote/https:\/\//https://${RELEASER_GIT_OAUTH_TOKEN}@}
"${GIT_BIN}" remote set-url --push origin "${withToken}"
else
echo "No OAuth token found"
"${GIT_BIN}" remote set-url --push origin "$( "${GIT_BIN}" config remote.origin.url | sed -e 's/^git:/https:/' )"
fi
}
# Prints the usage
function print_usage() {
cat <<EOF
The idea of this script is to keep the Spring guides up to date by taking the
contents of guides from the project's repository and pushing them to Spring guides
repository.
This script iterates over the contents of the [guides] folder. Each its subfolder
corresponds to a repository under the Spring Guides repository (i.e. the https://github.com/spring-guides organization).
Upon the iteration a corresponding guide repository gets cloned and updated with the latest content from the project repository. A commit and push then takes place.
USAGE:
You can use the following options:
-h|--help - display this message
EOF
}
# ==========================================
# ____ ____ _____ _____ _____ _______
# / ____|/ ____| __ \|_ _| __ \__ __|
# | (___ | | | |__) | | | | |__) | | |
# \___ \| | | _ / | | | ___/ | |
# ____) | |____| | \ \ _| |_| | | |
# |_____/ \_____|_| \_\_____|_| |_|
#
# ==========================================
if [[ "${SOURCE_FUNCTIONS}" == "true" ]]; then
echo "Will just source functions. Will not run any commands"
else
while [[ $# -gt 0 ]]
do
key="$1"
case "${key}" in
-h|--help)
print_usage
exit 0
;;
*)
echo "Invalid option: [$1]"
print_usage
exit 1
;;
esac
shift # past argument or value
done
iterate_over_guides
fi

View File

@@ -1,30 +0,0 @@
name: cloud-build
version: true
title: Spring Cloud Build
nav:
- modules/ROOT/nav.adoc
ext:
collector:
run:
command: ./mvnw validate process-resources -am -Pantora-process-resources,docs -pl docs
local: true
scan:
dir: ./target/classes/antora-resources/
asciidoc:
attributes:
attribute-missing: 'warn'
chomp: 'all'
project-root: ${maven.multiModuleProjectDirectory}
github-repo: ${docs.main}
github-raw: https://raw.githubusercontent.com/spring-cloud/${docs.main}/${github-tag}
github-code: https://github.com/spring-cloud/${docs.main}/tree/${github-tag}
github-issues: https://github.com/spring-cloud/${docs.main}/issues/@
github-wiki: https://github.com/spring-cloud/${docs.main}/wiki
spring-cloud-version: ${project.version}
github-tag: ${github-tag}
version-type: ${version-type}
docs-url: https://docs.spring.io/${docs.main}/docs/${project.version}
raw-docs-url: ${github-raw}
project-version: ${project.version}
project-name: ${docs.main}

239
pom.xml
View File

@@ -141,6 +141,7 @@
<generate-docs.phase>prepare-package</generate-docs.phase>
<copy-missing-html-files.phase>package</copy-missing-html-files.phase>
<package-and-attach-docs-zip.phase>package</package-and-attach-docs-zip.phase>
<antora-maven-plugin.version>0.0.4</antora-maven-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -297,6 +298,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.5.0</version>
<inherited>true</inherited>
<executions>
<execution>
@@ -1058,29 +1060,23 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<groupId>io.spring.maven.antora</groupId>
<artifactId>antora-component-version-maven-plugin</artifactId>
<version>${antora-maven-plugin.version}</version>
<executions>
<execution>
<id>copy-asciidoc-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
<goal>antora-component-version</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/refdocs/</outputDirectory>
<resources>
<resource>
<directory>src/main/asciidoc</directory>
<excludes>
<exclude>ghpages.sh</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.spring.maven.antora</groupId>
<artifactId>antora-maven-plugin</artifactId>
<version>${antora-maven-plugin.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
@@ -1117,172 +1113,6 @@
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>${asciidoctor-maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>io.spring.asciidoctor.backends</groupId>
<artifactId>spring-asciidoctor-backends</artifactId>
<version>${spring-asciidoctor-backends.version}</version>
</dependency>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>${asciidoctorj-pdf.version}</version>
</dependency>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-diagram</artifactId>
<version>${asciidoctorj-diagram.version}</version>
</dependency>
</dependencies>
<configuration>
<sourceDirectory>${refdocs.build.directory}</sourceDirectory>
<resources>
<resource>
<directory>${refdocs.build.directory}</directory>
<excludes>
<exclude>**/*.*adoc</exclude>
</excludes>
</resource>
</resources>
<!-- tag::attributes[] -->
<attributes>
<docinfo>shared</docinfo>
<allow-uri-read>true</allow-uri-read>
<nofooter/>
<toc>left</toc>
<toc-levels>4</toc-levels>
<sectlinks>true</sectlinks>
<sources-root>${project.basedir}/src@</sources-root>
<asciidoc-sources-root>${project.basedir}/src/main/asciidoc@</asciidoc-sources-root>
<generated-resources-root>${project.basedir}/target/generated-resources@
</generated-resources-root>
<!-- Use this attribute the reference code from another module -->
<!-- Note the @ at the end, lowering the precedence of the attribute -->
<project-root>${maven.multiModuleProjectDirectory}@</project-root>
<!-- It's mandatory for you to pass the docs.main property -->
<github-repo>${docs.main}@</github-repo>
<github-project>https://github.com/spring-cloud/${docs.main}@</github-project>
<github-raw>
https://raw.githubusercontent.com/spring-cloud/${docs.main}/${github-tag}@
</github-raw>
<github-code>https://github.com/spring-cloud/${docs.main}/tree/${github-tag}@
</github-code>
<github-issues>https://github.com/spring-cloud/${docs.main}/issues/@</github-issues>
<github-wiki>https://github.com/spring-cloud/${docs.main}/wiki@</github-wiki>
<github-master-code>https://github.com/spring-cloud/${docs.main}/tree/master@
</github-master-code>
<index-link>${index-link}@</index-link>
<!-- Spring Cloud specific -->
<!-- for backward compatibility -->
<spring-cloud-version>${project.version}@</spring-cloud-version>
<project-version>${project.version}@</project-version>
<github-tag>${github-tag}@</github-tag>
<version-type>${version-type}@</version-type>
<docs-url>https://docs.spring.io/${docs.main}/docs/${project.version}@</docs-url>
<raw-docs-url>${github-raw}@</raw-docs-url>
<project-version>${project.version}@</project-version>
<project-name>${docs.main}@</project-name>
<source-highlighter>highlight.js</source-highlighter>
</attributes>
<!-- end::attributes[] -->
<requires>
<require>asciidoctor-diagram</require>
</requires>
</configuration>
<executions>
<execution>
<id>generate-html-documentation</id>
<phase>${generate-docs.phase}</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>spring-html</backend>
<sourceDocumentExtensions>
<sourceDocumentExtension>.adoc</sourceDocumentExtension>
<sourceDocumentExtension>.htmladoc</sourceDocumentExtension>
</sourceDocumentExtensions>
<outputDirectory>${generated-docs-multipage-output.dir}
</outputDirectory>
<doctype>book</doctype>
<attributes>
<docinfo>shared</docinfo>
<stylesdir>css/</stylesdir>
<stylesheet>site.css</stylesheet>
<linkcss>true</linkcss>
<icons>font</icons>
<highlightjsdir>js/highlight</highlightjsdir>
<highlightjs-theme>github</highlightjs-theme>
<imagesdir>./images</imagesdir>
<attribute-missing>warn</attribute-missing>
<source-highlighter>highlight.js</source-highlighter>
</attributes>
<logHandler>
<outputToConsole>true</outputToConsole>
<failIf>
<!-- <severity>DEBUG</severity>-->
</failIf>
</logHandler>
</configuration>
</execution>
<execution>
<id>generate-htmlsingle-documentation</id>
<phase>${generate-docs.phase}</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>spring-html</backend>
<sourceDocumentExtensions>
<sourceDocumentExtension>.htmlsingleadoc</sourceDocumentExtension>
</sourceDocumentExtensions>
<outputDirectory>
${generated-docs-singlepage-output.dir}
</outputDirectory>
<doctype>book</doctype>
<attributes>
<source-highlighter>highlight.js</source-highlighter>
<docinfo>shared</docinfo>
<stylesdir>css/</stylesdir>
<stylesheet>site.css</stylesheet>
<linkcss>true</linkcss>
<icons>font</icons>
<highlightjsdir>js/highlight</highlightjsdir>
<highlightjs-theme>github</highlightjs-theme>
<imagesdir>./images</imagesdir>
</attributes>
</configuration>
</execution>
<execution>
<id>generate-pdf-documentation</id>
<phase>${generate-docs.phase}</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>pdf</backend>
<sourceDocumentExtensions>
<sourceDocumentExtension>.pdfadoc</sourceDocumentExtension>
</sourceDocumentExtensions>
<outputDirectory>${generated-docs-pdf-output.dir}
</outputDirectory>
<resources>
<resource>
<directory>${refdocs.build.directory}</directory>
<excludes>
<exclude>**/*</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@@ -1350,7 +1180,7 @@
</goals>
<configuration>
<target>
<fileset id="unresolved.file" dir="${basedir}/target/generated-docs/"
<fileset id="unresolved.file" dir="${basedir}/target/antora/site/"
includes="**/*.html">
<contains text="Unresolved"/>
</fileset>
@@ -1364,21 +1194,6 @@
</target>
</configuration>
</execution>
<execution>
<id>copy-missing-html-files</id>
<phase>${copy-missing-html-files.phase}</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<failOnError>false</failOnError>
<target>
<copy tofile="${project.build.directory}/generated-docs/reference/htmlsingle/index.html">
<fileset dir="${project.build.directory}/generated-docs/reference/htmlsingle" includes="${docs.main}.html" />
</copy>
</target>
</configuration>
</execution>
<execution>
<id>package-and-attach-docs-zip</id>
<phase>${package-and-attach-docs-zip.phase}</phase>
@@ -1411,7 +1226,7 @@
<taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask"/>
<var name="version-type" value="${revision}"/>
<propertyregex property="version-type" override="true"
input="${version-type}" regexp=".*\.(.*)" replace="\1"/>
input="${version-type}" regexp=".*\-(.*)" replace="\1"/>
<propertyregex property="version-type" override="true"
input="${version-type}" regexp="(M)\d+" replace="MILESTONE"/>
<propertyregex property="version-type" override="true"
@@ -1432,32 +1247,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>${artifactory-maven-plugin.version}</version>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<deployProperties>
<zip.deployed>true</zip.deployed>
<zip.type>docs</zip.type>
</deployProperties>
<publisher>
<contextUrl>https://repo.spring.io
</contextUrl>
<repoKey>libs-release-local</repoKey>
<snapshotRepoKey>libs-snapshots-local
</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>