From 591d22ed83bac5b773f15de0de28e136a6144673 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 15 Feb 2019 12:13:54 +0100 Subject: [PATCH] Added checkstyle rules --- .editorconfig | 24 + .settings.xml | 144 ++-- .springformat | 1 + docs/pom.xml | 4 +- pom.xml | 36 +- spring-cloud-release-tools-core/pom.xml | 4 +- .../cloud/release/internal/Releaser.java | 89 +- .../release/internal/ReleaserProperties.java | 502 ++++++------ .../internal/ReleaserPropertiesAware.java | 33 + .../internal/docs/DocumentationUpdater.java | 85 +- .../docs/ProjectDocumentationUpdater.java | 104 ++- .../internal/docs/ReleaseTrainContents.java | 48 +- .../docs/ReleaseTrainContentsUpdater.java | 259 ++++-- .../cloud/release/internal/docs/Row.java | 70 +- .../cloud/release/internal/docs/Title.java | 58 +- .../cloud/release/internal/git/GitRepo.java | 198 +++-- .../release/internal/git/GithubIssues.java | 63 +- .../internal/git/GithubMilestones.java | 82 +- .../internal/git/ProjectGitHandler.java | 109 ++- .../internal/gradle/GradleUpdater.java | 96 ++- .../cloud/release/internal/pom/BomParser.java | 88 +- .../cloud/release/internal/pom/PomReader.java | 50 +- .../release/internal/pom/PomUpdater.java | 257 +++--- .../internal/pom/ProjectPomUpdater.java | 118 ++- .../release/internal/pom/ProjectVersion.java | 106 ++- .../cloud/release/internal/pom/Projects.java | 106 ++- .../internal/pom/SpringCloudConstants.java | 40 +- .../cloud/release/internal/pom/Versions.java | 160 ++-- .../internal/post/PostReleaseActions.java | 187 +++-- .../internal/project/ProjectBuilder.java | 140 +++- .../cloud/release/internal/sagan/Project.java | 64 +- .../cloud/release/internal/sagan/Release.java | 65 +- .../release/internal/sagan/ReleaseUpdate.java | 53 +- .../release/internal/sagan/Repository.java | 47 +- .../sagan/RestTemplateSaganClient.java | 83 +- .../release/internal/sagan/SaganClient.java | 36 + .../release/internal/sagan/SaganUpdater.java | 72 +- .../internal/tech/HandlebarsHelper.java | 41 +- .../tech/MakeBuildUnstableException.java | 28 +- .../template/BlogTemplateGenerator.java | 77 +- .../template/EmailTemplateGenerator.java | 44 +- .../internal/template/NotesGenerator.java | 77 +- .../ReleaseNotesTemplateGenerator.java | 43 +- .../internal/template/TemplateGenerator.java | 64 +- .../template/TwitterTemplateGenerator.java | 45 +- .../main/resources/templates/cloud/email.hbs | 2 +- .../main/resources/templates/cloud/notes.hbs | 2 +- .../templates/cloud/spring-project.hbs | 2 +- .../main/resources/templates/cloud/tweet.hbs | 2 +- .../internal/PomUpdateAcceptanceTests.java | 99 ++- .../internal/ReleaserPropertiesTests.java | 35 +- .../cloud/release/internal/ReleaserTests.java | 107 ++- .../ProjectDocumentationUpdaterTests.java | 148 ++-- .../ReleaseTrainContentsGeneratorTests.java | 140 ++-- .../docs/ReleaseTrainContentsParserTests.java | 27 +- .../ReleaseTrainContentsUpdaterTests.java | 110 ++- .../cloud/release/internal/docs/RowTests.java | 25 +- .../docs/SpringCloudGhPagesParserTests.java | 91 ++- .../release/internal/git/GitRepoTests.java | 114 ++- .../release/internal/git/GitTestUtils.java | 22 +- .../internal/git/GithubIssuesTests.java | 81 +- .../internal/git/GithubMilestonesTests.java | 124 ++- .../internal/git/ProjectGitHandlerTests.java | 69 +- .../internal/gradle/GradleUpdaterTests.java | 62 +- .../release/internal/pom/BomParserTests.java | 51 +- .../internal/pom/LoggerToMavenLogTests.java | 74 +- .../release/internal/pom/PomReaderTests.java | 53 +- .../release/internal/pom/PomUpdaterTests.java | 363 +++++--- .../internal/pom/ProjectPomUpdaterTests.java | 62 +- .../internal/pom/ProjectVersionTests.java | 101 ++- .../release/internal/pom/ProjectsTests.java | 44 +- .../internal/pom/PropertyStorerTests.java | 36 +- .../pom/PropertyVersionChangerTests.java | 55 +- .../release/internal/pom/TestPomReader.java | 18 +- .../cloud/release/internal/pom/TestUtils.java | 21 +- .../internal/pom/VersionChangeAssertions.java | 27 +- .../release/internal/pom/VersionsTests.java | 130 ++- .../post/PostReleaseActionsTests.java | 94 ++- .../internal/project/ProjectBuilderTests.java | 188 +++-- .../sagan/RestTemplateSaganClientTests.java | 49 +- .../internal/sagan/SaganUpdaterTest.java | 76 +- .../template/TemplateGeneratorTests.java | 249 +++--- .../projects/project/children/pom.xml | 4 +- .../children/pom_case_from_contract.xml | 5 +- .../project/children/pom_different_group.xml | 6 +- .../pom_different_group_boot_parent.xml | 6 +- ...different_group_skip_deployment_plugin.xml | 6 +- ...nt_group_skip_deployment_plugin_mngmnt.xml | 6 +- ...m_different_group_skip_deployment_prop.xml | 6 +- .../children/pom_matching_artifact.xml | 4 +- .../project/children/pom_matching_parent.xml | 4 +- .../children/pom_matching_parent_v2.xml | 4 +- .../children/pom_matching_properties.xml | 4 +- .../test/resources/projects/project/pom.xml | 4 +- .../project/pom_matching_artifact.xml | 4 +- .../pom_matching_artifact_same_version.xml | 4 +- .../projects/project/pom_matching_parent.xml | 4 +- .../project/pom_matching_parent_v2.xml | 4 +- .../project/pom_matching_properties.xml | 4 +- .../pom_matching_with_parent_suffix.xml | 4 +- .../project/pom_with_parent_suffix.xml | 4 +- .../projects/spring-cloud-consul/.gitignore | 2 +- .../projects/spring-cloud-consul/pom.xml | 4 +- .../spring-cloud-starter-consul/pom.xml | 4 +- .../projects/spring-cloud-contract/pom.xml | 4 +- .../pom.xml | 4 +- .../spring-cloud-contract-tools/pom.xml | 4 +- .../spring-cloud-contract-converters/pom.xml | 6 +- .../spring-cloud-core-tests/.settings.xml | 128 +-- .../spring-cloud-core-tests/.travis.yml | 8 +- .../spring-cloud-core-tests/bootstrap/pom.xml | 6 +- .../java/demo/BootstrapClientApplication.java | 17 + .../src/main/resources/bootstrap.yml | 4 +- .../demo/BootstrapClientApplicationTests.java | 25 +- .../spring-cloud-core-tests/bus/pom.xml | 6 +- .../demo/StandaloneClientApplication.java | 17 + .../StandaloneClientApplicationTests.java | 21 +- .../config-client-decrypt/pom.xml | 6 +- .../BootstrapDecryptionClientApplication.java | 27 +- ...strapDecryptionClientApplicationTests.java | 28 +- .../config-client/pom.xml | 6 +- .../demo/StandaloneClientApplication.java | 17 + .../StandaloneClientApplicationTests.java | 21 +- .../config-retry/pom.xml | 6 +- .../java/bootstrap/RetryConfiguration.java | 17 + .../demo/StandaloneClientApplication.java | 21 +- .../src/test/java/apps/ConfigServer.java | 19 +- .../StandaloneClientApplicationTests.java | 64 +- .../configserver-bootstrap/pom.xml | 4 +- .../ConfigServerBootstrapApplication.java | 16 + .../ConfigServerEurekaApplicationTests.java | 17 + .../configserver-eureka/pom.xml | 4 +- .../demo/ConfigServerEurekaApplication.java | 16 + .../ConfigServerEurekaApplicationTests.java | 30 +- .../configserver/pom.xml | 4 +- .../java/demo/ConfigServerApplication.java | 16 + .../demo/ConfigServerApplicationTests.java | 17 + .../eureka-client/pom.xml | 6 +- .../java/demo/EurekaClientApplication.java | 25 +- .../demo/EurekaClientApplicationTests.java | 21 +- .../eureka-first/pom.xml | 4 +- .../java/demo/EurekaFirstApplication.java | 17 + .../demo/EurekaFirstApplicationTests.java | 29 +- .../eureka-noweb/pom.xml | 6 +- .../demo/StandaloneClientApplication.java | 30 +- ...faultStandaloneClientApplicationTests.java | 17 + .../StandaloneClientApplicationTests.java | 30 +- .../eureka-server/pom.xml | 4 +- .../src/main/java/demo/EurekaApplication.java | 23 +- .../demo/EurekaServerApplicationTests.java | 36 +- .../feign-eager-instantiation/pom.xml | 226 ++--- .../src/main/java/demo/ExampleClient.java | 21 +- .../FeignEagerInstantiationApplication.java | 23 +- ...ignEagerInstantiationApplicationTests.java | 17 + .../feign-eureka/pom.xml | 6 +- .../java/demo/HelloClientApplication.java | 42 +- .../demo/HelloClientApplicationTests.java | 25 +- .../test/java/demo/NoWebApplicationTests.java | 17 + .../feign-hystrix/pom.xml | 6 +- .../java/demo/FeignClientApplication.java | 39 +- .../src/test/java/demo/AdhocTestSuite.java | 16 + .../demo/FeignClientApplicationTests.java | 40 +- ...nClientWithServerListApplicationTests.java | 51 +- .../spring-cloud-core-tests/feign/pom.xml | 6 +- .../java/demo/FeignClientApplication.java | 31 +- .../src/test/java/demo/AdhocTestSuite.java | 16 + .../demo/FeignClientApplicationTests.java | 25 +- ...nClientWithServerListApplicationTests.java | 35 +- .../hystrix-amqp/pom.xml | 6 +- .../main/java/demo/HystrixApplication.java | 55 +- .../src/main/java/demo/MyService.java | 17 + .../src/main/resources/application.properties | 6 +- .../java/demo/HystrixApplicationTests.java | 42 +- .../spring-cloud-core-tests/hystrix/pom.xml | 6 +- .../main/java/demo/HystrixApplication.java | 32 +- .../hystrix/src/main/java/demo/MyService.java | 23 +- .../src/main/resources/application.properties | 4 +- .../java/demo/HystrixApplicationTests.java | 42 +- .../netflix-sidecar/pom.xml | 4 +- .../main/java/demo/SidecarApplication.java | 17 + .../src/main/resources/health.json | 4 +- .../java/demo/SidecarApplicationTests.java | 25 +- .../spring-cloud-core-tests/noweb/pom.xml | 6 +- .../src/main/java/demo/NotWebApplication.java | 17 + .../java/demo/NotWebApplicationTests.java | 17 + .../test/DiscoveryNotWebApplicationTests.java | 25 +- .../oauth2-ribbon/pom.xml | 6 +- .../java/demo/RibbonClientApplication.java | 32 +- .../src/main/resources/application.properties | 6 +- .../demo/RibbonClientApplicationTests.java | 81 +- .../oauth2-zuul/pom.xml | 6 +- .../src/main/java/demo/ZuulApplication.java | 17 + .../src/main/resources/application.properties | 10 +- .../test/java/demo/ZuulApplicationTests.java | 34 +- .../projects/spring-cloud-core-tests/pom.xml | 17 +- .../ribbon-default-config/pom.xml | 15 +- .../main/java/demo/MyDefaultRibbonConfig.java | 26 +- .../demo/RibbonDefaultConfigApplication.java | 51 +- .../RibbonDefaultConfigApplicationTests.java | 19 +- .../ribbon-eureka/pom.xml | 6 +- .../java/demo/HelloClientApplication.java | 25 +- .../java/apps/EurekaServerApplication.java | 21 +- .../src/test/java/apps/SimpleApplication.java | 25 +- .../demo/HelloClientApplicationTests.java | 31 +- .../src/test/resources/eureka.properties | 4 +- .../src/test/resources/simple.properties | 10 +- .../spring-cloud-core-tests/sleuth/pom.xml | 24 +- .../src/main/java/demo/TraceApplication.java | 27 +- .../test/java/demo/TraceApplicationTests.java | 18 + .../stream-bus/pom.xml | 6 +- .../main/java/demo/StreamBusApplication.java | 17 + .../java/demo/StreamBusApplicationTests.java | 24 +- .../turbine-amqp/pom.xml | 6 +- .../java/demo/TurbineStreamApplication.java | 17 + .../src/main/resources/application.properties | 8 +- .../demo/TurbineStreamApplicationTests.java | 45 +- .../src/test/resources/eureka.properties | 4 +- .../src/test/resources/simple.properties | 4 +- .../spring-cloud-core-tests/turbine/pom.xml | 4 +- .../main/java/demo/TurbineApplication.java | 23 +- .../java/apps/EurekaServerApplication.java | 21 +- .../src/test/java/apps/OtherApplication.java | 34 +- .../src/test/java/apps/SimpleApplication.java | 34 +- .../java/demo/TurbineApplicationTests.java | 26 +- .../src/test/resources/eureka.properties | 4 +- .../src/test/resources/other.properties | 6 +- .../src/test/resources/simple.properties | 6 +- .../spring-cloud-core-tests/vanilla/pom.xml | 6 +- .../main/java/demo/VanillaApplication.java | 23 +- .../java/demo/VanillaApplicationTests.java | 21 +- .../spring-cloud-core-tests/zipkin/pom.xml | 22 +- .../src/main/java/demo/ZipkinApplication.java | 41 +- .../java/demo/ZipkinApplicationTests.java | 34 +- .../zuul-config-discovery/pom.xml | 32 +- .../demo/ZuulConfigDiscoveryApplication.java | 16 + .../ZuulConfigDiscoveryApplicationTests.java | 19 +- .../zuul-proxy-eureka/pom.xml | 6 +- .../java/demo/ZuulProxyEurekaApplication.java | 17 + .../src/main/resources/application.properties | 6 +- .../demo/ZuulProxyEurekaApplicationTests.java | 30 +- .../zuul-proxy/pom.xml | 6 +- .../main/java/demo/ZuulProxyApplication.java | 23 +- .../src/main/resources/application.properties | 30 +- .../src/test/java/apps/UiApplication.java | 25 +- .../java/demo/ZuulProxyApplicationTests.java | 34 +- .../src/test/resources/ui.properties | 6 +- .../spring-cloud-core-tests/zuul/pom.xml | 24 +- .../src/main/java/demo/ZuulApplication.java | 24 +- .../src/main/resources/application.properties | 6 +- .../test/java/demo/ZuulApplicationTests.java | 22 +- .../zuul/src/test/resources/ui.properties | 6 +- .../spring-cloud-release/.settings.xml | 128 +-- .../projects/spring-cloud-release/.travis.yml | 2 +- .../spring-cloud-release/docs/pom.xml | 4 +- .../projects/spring-cloud-release/pom.xml | 8 +- .../spring-cloud-dependencies/pom.xml | 6 +- .../spring-cloud-starter-parent/pom.xml | 9 +- .../pom.xml | 6 +- .../spring-cloud-sleuth-core/pom.xml | 4 +- .../spring-cloud-sleuth-dependencies/pom.xml | 4 +- .../spring-cloud-sleuth-samples/pom.xml | 4 +- .../pom.xml | 12 +- .../projects/spring-cloud-sleuth/pom.xml | 6 +- .../spring-cloud-sleuth-core/pom.xml | 4 +- .../spring-cloud-sleuth-dependencies/pom.xml | 4 +- .../spring-cloud-sleuth-samples/pom.xml | 4 +- .../pom.xml | 4 +- .../spring-cloud-static/current/index.html | 5 +- .../src/test/resources/raw/some-file.html | 1 + .../raw/spring-cloud-gh-pages-index.html | 773 ++++++++++-------- spring-cloud-release-tools-spring/pom.xml | 10 +- .../release/internal/ReleaserApplication.java | 64 +- .../release/internal/options/Options.java | 77 +- .../internal/options/OptionsBuilder.java | 46 +- .../release/internal/options/Parser.java | 36 +- .../internal/sagan/SaganConfiguration.java | 42 +- .../cloud/release/internal/spring/Args.java | 72 +- .../internal/spring/BuildCompleted.java | 19 +- .../spring/ConsoleInputStepSkipper.java | 36 +- .../internal/spring/OptionsParser.java | 125 +-- .../internal/spring/OptionsProcessor.java | 120 ++- .../spring/ReleaserConfiguration.java | 61 +- .../spring/ReleaserPropertiesUpdater.java | 80 +- .../release/internal/spring/ReleaserTask.java | 20 +- .../internal/spring/SpringReleaser.java | 200 +++-- .../release/internal/spring/StepSkipper.java | 34 + .../cloud/release/internal/spring/Task.java | 62 +- .../internal/spring/TaskAndException.java | 25 +- .../internal/spring/TaskCollector.java | 57 +- .../internal/spring/TaskCompleted.java | 26 +- .../cloud/release/internal/spring/Tasks.java | 213 ++--- .../src/main/resources/application.yml | 2 +- .../docs/TestDocumentationUpdater.java | 54 +- .../release/internal/git/GitTestUtils.java | 22 +- .../release/internal/pom/TestPomReader.java | 17 + .../cloud/release/internal/pom/TestUtils.java | 24 +- .../internal/spring/AcceptanceTests.java | 533 +++++++----- .../spring/CompositeConsumerTests.java | 36 +- .../internal/spring/OptionsParserTests.java | 51 +- .../spring/OptionsProcessorTests.java | 117 ++- .../spring/ReleaserApplicationEventTests.java | 28 +- .../ReleaserPropertiesIntegrationTests.java | 71 +- .../ReleaserPropertiesUpdaterTests.java | 32 +- .../internal/spring/SpringReleaserTests.java | 55 +- .../release/internal/spring/TaskTests.java | 34 +- .../project-with-config/config/releaser.yml | 2 +- .../config/releaser.yml | 2 +- .../releaser-updater/config/releaser.yml | 2 +- .../projects/spring-cloud-build/.settings.xml | 128 +-- .../projects/spring-cloud-build/.travis.yml | 26 +- .../projects/spring-cloud-build/docs/pom.xml | 4 +- .../docs/src/main/docbook/css/highlight.css | 20 +- .../src/main/docbook/css/manual-multipage.css | 2 +- .../main/docbook/css/manual-singlepage.css | 2 +- .../docs/src/main/docbook/css/manual.css | 362 ++++---- .../docs/src/main/docbook/xsl/common.xsl | 8 +- .../docs/src/main/docbook/xsl/epub.xsl | 8 +- .../src/main/docbook/xsl/html-multipage.xsl | 6 +- .../docs/src/main/docbook/xsl/html.xsl | 42 +- .../docs/src/main/docbook/xsl/pdf.xsl | 42 +- .../src/main/docbook/xsl/xslthl-config.xml | 40 +- .../main/docbook/xsl/xslthl/asciidoc-hl.xml | 66 +- .../src/main/docbook/xsl/xslthl/bourne-hl.xml | 12 +- .../docs/src/main/docbook/xsl/xslthl/c-hl.xml | 8 +- .../src/main/docbook/xsl/xslthl/cpp-hl.xml | 6 +- .../src/main/docbook/xsl/xslthl/csharp-hl.xml | 8 +- .../src/main/docbook/xsl/xslthl/css-hl.xml | 280 +++---- .../src/main/docbook/xsl/xslthl/html-hl.xml | 218 ++--- .../src/main/docbook/xsl/xslthl/java-hl.xml | 4 +- .../main/docbook/xsl/xslthl/javascript-hl.xml | 4 +- .../src/main/docbook/xsl/xslthl/json-hl.xml | 2 +- .../src/main/docbook/xsl/xslthl/perl-hl.xml | 6 +- .../src/main/docbook/xsl/xslthl/php-hl.xml | 10 +- .../src/main/docbook/xsl/xslthl/python-hl.xml | 10 +- .../src/main/docbook/xsl/xslthl/ruby-hl.xml | 4 +- .../main/docbook/xsl/xslthl/sql2003-hl.xml | 16 +- .../src/main/docbook/xsl/xslthl/yaml-hl.xml | 2 +- .../projects/spring-cloud-build/pom.xml | 157 ++-- .../spring-cloud-build-dependencies/pom.xml | 13 +- .../spring-cloud-build-tools/pom.xml | 6 +- .../src/main/resources/checkstyle.xml | 4 +- .../eclipse-code-formatter.xml | 688 +++++++++------- .../spring-cloud-dependencies-parent/pom.xml | 31 +- .../projects/spring-cloud-consul/.gitignore | 2 +- .../projects/spring-cloud-consul/pom.xml | 4 +- .../spring-cloud-starter-consul/pom.xml | 4 +- .../.mvn/jvm.config | 2 +- .../.mvn/wrapper/maven-wrapper.properties | 3 +- .../.settings.xml | 128 +-- .../.travis.yml | 2 +- .../README.adoc | 2 +- .../docs/pom.xml | 4 +- .../docs/src/main/asciidoc/ghpages.sh | 2 +- .../docs/src/main/asciidoc/intro.adoc | 2 +- .../pom.xml | 8 +- .../spring-cloud-dependencies/pom.xml | 6 +- .../main/resources/META-INF/spring.provides | 2 +- .../spring-cloud-starter-parent/pom.xml | 9 +- .../main/resources/META-INF/spring.provides | 2 +- .../spring-cloud-release/.settings.xml | 128 +-- .../projects/spring-cloud-release/.travis.yml | 2 +- .../projects/spring-cloud-release/README.adoc | 2 +- .../spring-cloud-release/docs/pom.xml | 4 +- .../docs/src/main/asciidoc/ghpages.sh | 2 +- .../docs/src/main/asciidoc/intro.adoc | 2 +- .../projects/spring-cloud-release/pom.xml | 8 +- .../spring-cloud-dependencies/pom.xml | 6 +- .../main/resources/META-INF/spring.provides | 2 +- .../spring-cloud-starter-parent/pom.xml | 9 +- .../main/resources/META-INF/spring.provides | 2 +- .../current/index.html | 5 +- .../spring-cloud-static/current/index.html | 5 +- .../projects/spring-cloud-wiki/Home.asciidoc | 2 +- .../Spring-Cloud-Angel-Release-Notes.asciidoc | 2 +- ...pring-Cloud-Brixton-Release-Notes.asciidoc | 2 +- src/checkstyle/checkstyle-suppressions.xml | 31 + 376 files changed, 11007 insertions(+), 5402 deletions(-) create mode 100644 .editorconfig create mode 100644 .springformat create mode 100644 src/checkstyle/checkstyle-suppressions.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..ddda9782 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,24 @@ +root = true + +[*.java] +indent_style = tab +indent_size = 4 +continuation_indent_size = 8 + +[*.groovy] +indent_style = tab +indent_size = 4 +continuation_indent_size = 8 + +[*.xml] +indent_style = tab +indent_size = 4 +continuation_indent_size = 8 + +[*.yml] +indent_style = space +indent_size = 2 + +[*.yaml] +indent_style = space +indent_size = 2 diff --git a/.settings.xml b/.settings.xml index 32e8266c..1261ef8f 100644 --- a/.settings.xml +++ b/.settings.xml @@ -1,73 +1,77 @@ - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - true - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - http://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - - - - ide - true - - + + + repo.spring.io + ${env.CI_DEPLOY_USERNAME} + ${env.CI_DEPLOY_PASSWORD} + + + + + + spring + + true + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + http://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + + + + ide + + true + + + diff --git a/.springformat b/.springformat new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/.springformat @@ -0,0 +1 @@ + diff --git a/docs/pom.xml b/docs/pom.xml index 74acef4d..9de368b3 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.internal diff --git a/pom.xml b/pom.xml index 4a3e9c45..ae1bc2da 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -12,7 +12,7 @@ org.springframework.cloud spring-cloud-build - 2.1.2.RELEASE + 2.1.3.BUILD-SNAPSHOT @@ -24,7 +24,13 @@ - Greenwich.RELEASE + Greenwich.BUILD-SNAPSHOT + + true + true + + true + @@ -39,6 +45,28 @@ + + + + io.spring.javaformat + spring-javaformat-maven-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + spring-snapshots diff --git a/spring-cloud-release-tools-core/pom.xml b/spring-cloud-release-tools-core/pom.xml index 2b1b3783..1a963a11 100644 --- a/spring-cloud-release-tools-core/pom.xml +++ b/spring-cloud-release-tools-core/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java index 99e1a4e6..89ea0c9e 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal; import java.io.File; @@ -22,24 +54,34 @@ import org.springframework.util.Assert; * @author Marcin Grzejszczak */ public class Releaser { + private static final Logger log = LoggerFactory.getLogger(Releaser.class); private static boolean ASSERT_SNAPSHOTS = true; + private static boolean SKIP_SNAPSHOT_ASSERTION = false; private final ProjectPomUpdater projectPomUpdater; + private final ProjectBuilder projectBuilder; + private final ProjectGitHandler projectGitHandler; + private final TemplateGenerator templateGenerator; + private final GradleUpdater gradleUpdater; + private final SaganUpdater saganUpdater; + private final DocumentationUpdater documentationUpdater; + private final PostReleaseActions postReleaseActions; public Releaser(ProjectPomUpdater projectPomUpdater, ProjectBuilder projectBuilder, ProjectGitHandler projectGitHandler, TemplateGenerator templateGenerator, GradleUpdater gradleUpdater, SaganUpdater saganUpdater, - DocumentationUpdater documentationUpdater, PostReleaseActions postReleaseActions) { + DocumentationUpdater documentationUpdater, + PostReleaseActions postReleaseActions) { this.projectPomUpdater = projectPomUpdater; this.projectBuilder = projectBuilder; this.projectGitHandler = projectGitHandler; @@ -71,8 +113,8 @@ public class Releaser { ProjectVersion versionFromScRelease, boolean assertSnapshots) { this.projectPomUpdater.updateProjectFromReleaseTrain(project, versions, versionFromScRelease, assertSnapshots); - this.gradleUpdater.updateProjectFromBom(project, versions, - versionFromScRelease, assertSnapshots); + this.gradleUpdater.updateProjectFromBom(project, versions, versionFromScRelease, + assertSnapshots); ProjectVersion changedVersion = new ProjectVersion(project); log.info("\n\nProject was successfully updated to [{}]", changedVersion); } @@ -97,7 +139,8 @@ public class Releaser { log.info("\nThe docs were published successfully"); } - public void rollbackReleaseVersion(File project, Projects projects, ProjectVersion scReleaseVersion) { + public void rollbackReleaseVersion(File project, Projects projects, + ProjectVersion scReleaseVersion) { if (scReleaseVersion.isSnapshot()) { log.info("\nWon't rollback a snapshot version"); return; @@ -105,15 +148,17 @@ public class Releaser { this.projectGitHandler.revertChangesIfApplicable(project, scReleaseVersion); ProjectVersion originalVersion = originalVersion(project); log.info("Original project version is [{}]", originalVersion); - if ((scReleaseVersion.isRelease() || scReleaseVersion - .isServiceRelease()) && originalVersion.isSnapshot()) { + if ((scReleaseVersion.isRelease() || scReleaseVersion.isServiceRelease()) + && originalVersion.isSnapshot()) { Projects newProjects = Projects.forRollback(projects, originalVersion); - updateProjectFromBom(project, newProjects, originalVersion, SKIP_SNAPSHOT_ASSERTION); + updateProjectFromBom(project, newProjects, originalVersion, + SKIP_SNAPSHOT_ASSERTION); this.projectGitHandler.commitAfterBumpingVersions(project, originalVersion); log.info("\nSuccessfully reverted the commit and bumped snapshot versions"); } else { - log.info("\nSuccessfully reverted the commit and came back to snapshot versions"); + log.info( + "\nSuccessfully reverted the commit and came back to snapshot versions"); } } @@ -134,14 +179,17 @@ public class Releaser { try { this.projectGitHandler.closeMilestone(releaseVersion); log.info("\nSuccessfully closed milestone"); - } catch (Exception ex) { + } + catch (Exception ex) { throw new MakeBuildUnstableException("Failed to create an email template"); } } public void createEmail(ProjectVersion releaseVersion, Projects projects) { - Assert.notNull(releaseVersion, "You must provide a release version for your project"); - Assert.notNull(releaseVersion.version, "You must provide a release version for your project"); + Assert.notNull(releaseVersion, + "You must provide a release version for your project"); + Assert.notNull(releaseVersion.version, + "You must provide a release version for your project"); if (releaseVersion.isSnapshot()) { log.info("\nWon't create email template for a SNAPSHOT version"); return; @@ -152,11 +200,13 @@ public class Releaser { log.info("\nSuccessfully created email template at location [{}]", email); } else { - throw new MakeBuildUnstableException("Failed to create an email template"); + throw new MakeBuildUnstableException( + "Failed to create an email template"); } } catch (Exception ex) { - throw new MakeBuildUnstableException("Failed to create an email template", ex); + throw new MakeBuildUnstableException("Failed to create an email template", + ex); } } @@ -181,14 +231,16 @@ public class Releaser { public void updateSpringGuides(ProjectVersion releaseVersion, Projects projects) { if (!(releaseVersion.isRelease() || releaseVersion.isServiceRelease())) { - log.info("\nWon't update Spring Guides for a non Release / Service Release version"); + log.info( + "\nWon't update Spring Guides for a non Release / Service Release version"); return; } try { this.projectGitHandler.createIssueInSpringGuides(projects, releaseVersion); } catch (Exception ex) { - throw new MakeBuildUnstableException("Successfully updated Spring Guides issues", ex); + throw new MakeBuildUnstableException( + "Successfully updated Spring Guides issues", ex); } } @@ -237,10 +289,12 @@ public class Releaser { } } - public void updateDocumentationRepository(ReleaserProperties properties, ProjectVersion releaseVersion) { + public void updateDocumentationRepository(ReleaserProperties properties, + ProjectVersion releaseVersion) { String releaseBranch = properties.getPom().getBranch(); this.documentationUpdater.updateDocsRepo(releaseVersion, releaseBranch); - log.info("\nSuccessfully updated documentation repository for branch [{}]", releaseBranch); + log.info("\nSuccessfully updated documentation repository for branch [{}]", + releaseBranch); } public void updateSpringProjectPage(Projects projects) { @@ -271,4 +325,5 @@ public class Releaser { this.documentationUpdater.updateReleaseTrainWiki(projects); log.info("\nSuccessfully updated project wiki"); } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java index 18c82d71..7f0f0f67 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java @@ -1,18 +1,35 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal; import java.io.Serializable; @@ -29,8 +46,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.util.StringUtils; /** - * Since, we are making a deep copy of this object, remember to have all the - * nested classes to implement the Serializable interface. + * Since, we are making a deep copy of this object, remember to have all the nested + * classes to implement the Serializable interface. * * @author Marcin Grzejszczak */ @@ -44,7 +61,7 @@ public class ReleaserProperties implements Serializable { private String workingDir; /** - * If set to {@code true} will run only post release tasks + * If set to {@code true} will run only post release tasks. */ private boolean postReleaseTasksOnly = false; @@ -61,40 +78,133 @@ public class ReleaserProperties implements Serializable { private Template template = new Template(); /** - * Project name to its version - overrides all versions - * retrieved from a repository like Spring Cloud Release + * Project name to its version - overrides all versions retrieved from a repository + * like Spring Cloud Release. */ private Map fixedVersions = new LinkedHashMap<>(); private MetaRelease metaRelease = new MetaRelease(); + public String getWorkingDir() { + return StringUtils.hasText(this.workingDir) ? this.workingDir + : System.getProperty("user.dir"); + } + + public void setWorkingDir(String workingDir) { + this.workingDir = workingDir; + } + + public Git getGit() { + return this.git; + } + + public void setGit(Git git) { + this.git = git; + } + + public Pom getPom() { + return this.pom; + } + + public void setPom(Pom pom) { + this.pom = pom; + } + + public Maven getMaven() { + return this.maven; + } + + public void setMaven(Maven maven) { + this.maven = maven; + } + + public Gradle getGradle() { + return this.gradle; + } + + public void setGradle(Gradle gradle) { + this.gradle = gradle; + } + + public Map getFixedVersions() { + return this.fixedVersions; + } + + public void setFixedVersions(Map fixedVersions) { + this.fixedVersions = fixedVersions; + } + + public MetaRelease getMetaRelease() { + return this.metaRelease; + } + + public void setMetaRelease(MetaRelease metaRelease) { + this.metaRelease = metaRelease; + } + + public Sagan getSagan() { + return this.sagan; + } + + public void setSagan(Sagan sagan) { + this.sagan = sagan; + } + + public Template getTemplate() { + return this.template; + } + + public void setTemplate(Template template) { + this.template = template; + } + + public boolean isPostReleaseTasksOnly() { + return this.postReleaseTasksOnly; + } + + public void setPostReleaseTasksOnly(boolean postReleaseTasksOnly) { + this.postReleaseTasksOnly = postReleaseTasksOnly; + } + + @Override + public String toString() { + return "ReleaserProperties{" + "workingDir='" + this.workingDir + '\'' + ", git=" + + this.git + ", pom=" + this.pom + ", maven=" + this.maven + ", gradle=" + + this.gradle + ", sagan=" + this.sagan + ", fixedVersions=" + + this.fixedVersions + ", metaRelease=" + this.metaRelease + ", template=" + + this.template + '}'; + } + + public ReleaserProperties copy() { + return (ReleaserProperties) SerializationUtils.clone(this); + } + public static class MetaRelease implements Serializable { + /** * Are we releasing the whole suite of apps or only one? */ private boolean enabled = false; /** - * Name of the release train project + * Name of the release train project. */ private String releaseTrainProjectName = "spring-cloud-release"; /** - * All the names of dependencies that should be updated with the release - * train project version + * All the names of dependencies that should be updated with the release train + * project version. */ - private List releaseTrainDependencyNames = Arrays.asList( - "spring-cloud", "spring-cloud-dependencies", "spring-cloud-starter" - ); + private List releaseTrainDependencyNames = Arrays.asList("spring-cloud", + "spring-cloud-dependencies", "spring-cloud-starter"); /** - * The URL of the Git organization. We'll append each project's - * name to it + * The URL of the Git organization. We'll append each project's name to it. */ private String gitOrgUrl = "https://github.com/spring-cloud"; /** - * Names of projects to skip deployment for meta-release + * Names of projects to skip deployment for meta-release. */ private List projectsToSkip = new ArrayList() { { @@ -132,7 +242,8 @@ public class ReleaserProperties implements Serializable { return this.releaseTrainDependencyNames; } - public void setReleaseTrainDependencyNames(List releaseTrainDependencyNames) { + public void setReleaseTrainDependencyNames( + List releaseTrainDependencyNames) { this.releaseTrainDependencyNames = releaseTrainDependencyNames; } @@ -146,101 +257,102 @@ public class ReleaserProperties implements Serializable { @Override public String toString() { - return "MetaRelease{" + - "enabled=" + this.enabled + - ", releaseTrainProjectName='" + this.releaseTrainProjectName + '\'' + - ", gitOrgUrl='" + this.gitOrgUrl + '\'' + - ", projectsToSkip=" + this.projectsToSkip + - '}'; + return "MetaRelease{" + "enabled=" + this.enabled + + ", releaseTrainProjectName='" + this.releaseTrainProjectName + '\'' + + ", gitOrgUrl='" + this.gitOrgUrl + '\'' + ", projectsToSkip=" + + this.projectsToSkip + '}'; } + } public static class Git implements Serializable { /** - * URL to Spring Cloud Release Git repository + * URL to Spring Cloud Release Git repository. */ private String releaseTrainBomUrl = "https://github.com/spring-cloud/spring-cloud-release"; /** - * URL to the documentation Git repository + * URL to the documentation Git repository. */ private String documentationUrl = "https://github.com/spring-cloud/spring-cloud-static"; /** - * URL to main release train project repository + * URL to main release train project repository. */ private String springProjectUrl = "https://github.com/spring-projects/spring-cloud"; /** - * URL to test samples + * URL to test samples. */ private String testSamplesProjectUrl = "https://github.com/spring-cloud/spring-cloud-core-tests"; /** - * URL to the release train documentation + * URL to the release train documentation. */ private String releaseTrainDocsUrl = "https://github.com/spring-cloud-samples/scripts"; /** - * URL to the release train wiki + * URL to the release train wiki. */ private String releaseTrainWikiUrl = "https://github.com/spring-projects/spring-cloud.wiki"; /** - * Branch to check out for the documentation project + * Branch to check out for the documentation project. */ private String documentationBranch = "gh-pages"; /** - * Branch to check out for the release train project + * Branch to check out for the release train project. */ private String springProjectBranch = "gh-pages"; /** - * Branch to check out for the test samples + * Branch to check out for the test samples. */ private String testSamplesBranch = "master"; /** - * Branch to check out for the release train docs + * Branch to check out for the release train docs. */ private String releaseTrainDocsBranch = "master"; /** - * Page prefix for the release train wiki. E.g. for [Spring-Cloud-Finchley-Release-Notes] - * it would be [Spring-Cloud]. + * Page prefix for the release train wiki. E.g. for + * [Spring-Cloud-Finchley-Release-Notes] it would be [Spring-Cloud]. */ private String releaseTrainWikiPagePrefix = "Spring-Cloud"; /** - * Where should the Spring Cloud Release repo get cloned to. If {@code null} defaults to a temporary directory + * Where should the Spring Cloud Release repo get cloned to. If {@code null} + * defaults to a temporary directory. */ private String cloneDestinationDir; /** - * If {@code true} then should fill the map of versions from Git. If {@code false} then picks fixed versions + * If {@code true} then should fill the map of versions from Git. If {@code false} + * then picks fixed versions. */ private boolean fetchVersionsFromGit = true; /** - * GitHub OAuth token to be used to interact with GitHub repo + * GitHub OAuth token to be used to interact with GitHub repo. */ private String oauthToken = ""; /** - * Optional Git username. If not passed keys will be used for authentication + * Optional Git username. If not passed keys will be used for authentication. */ private String username; /** - * Optional Git password. If not passed keys will be used for authentication + * Optional Git password. If not passed keys will be used for authentication. */ private String password; /** - * In order not to iterate endlessly over milestones we introduce a threshold of milestones - * that we will go through to find the matching milestone + * In order not to iterate endlessly over milestones we introduce a threshold of + * milestones that we will go through to find the matching milestone. */ private Integer numberOfCheckedMilestones = 50; @@ -255,28 +367,29 @@ public class ReleaserProperties implements Serializable { private boolean updateSpringGuides = true; /** - * If set to {@code false}, will not update the Spring Project for a release train. - * E.g. for Spring Cloud will not update https://cloud.spring.io + * If set to {@code false}, will not update the Spring Project for a release + * train. E.g. for Spring Cloud will not update https://cloud.spring.io . */ private boolean updateSpringProject = true; /** - * If set to {@code false}, will not update the test samples + * If set to {@code false}, will not update the test samples. */ private boolean runUpdatedSamples = true; /** - * If set to {@code false}, will not update the release train docs + * If set to {@code false}, will not update the release train docs. */ private boolean updateReleaseTrainDocs = true; /** - * If set to {@code false}, will not clone and update the release train wiki + * If set to {@code false}, will not clone and update the release train wiki. */ private boolean updateReleaseTrainWiki = true; /** - * If set to {@code false}, will not clone and update the samples for all projects + * If set to {@code false}, will not clone and update the samples for all + * projects. */ private boolean updateAllTestSamples = true; @@ -286,15 +399,13 @@ public class ReleaserProperties implements Serializable { */ private Map> allTestSampleUrls = new HashMap>() { { - this.put("spring-cloud-sleuth" , Arrays.asList( + this.put("spring-cloud-sleuth", Arrays.asList( "https://github.com/spring-cloud-samples/sleuth-issues", - "https://github.com/spring-cloud-samples/sleuth-documentation-apps") - ); - this.put("spring-cloud-contract" , Arrays.asList( + "https://github.com/spring-cloud-samples/sleuth-documentation-apps")); + this.put("spring-cloud-contract", Arrays.asList( "https://github.com/spring-cloud-samples/spring-cloud-contract-samples", "https://github.com/spring-cloud-samples/the-legacy-app", - "https://github.com/spring-cloud-samples/sc-contract-car-rental") - ); + "https://github.com/spring-cloud-samples/sc-contract-car-rental")); } }; @@ -366,6 +477,10 @@ public class ReleaserProperties implements Serializable { return this.runUpdatedSamples; } + public void setRunUpdatedSamples(boolean runUpdatedSamples) { + this.runUpdatedSamples = runUpdatedSamples; + } + public boolean isUpdateAllTestSamples() { return this.updateAllTestSamples; } @@ -374,10 +489,6 @@ public class ReleaserProperties implements Serializable { this.updateAllTestSamples = updateAllTestSamples; } - public void setRunUpdatedSamples(boolean runUpdatedSamples) { - this.runUpdatedSamples = runUpdatedSamples; - } - public String getCloneDestinationDir() { return this.cloneDestinationDir; } @@ -500,57 +611,57 @@ public class ReleaserProperties implements Serializable { @Override public String toString() { - return "Git{" + - "releaseTrainBomUrl='" + this.releaseTrainBomUrl + '\'' + - ", documentationUrl='" + this.documentationUrl + '\'' + - ", documentationBranch='" + this.documentationBranch + '\'' + - ", releaseTrainWikiUrl='" + this.releaseTrainWikiUrl + '\'' + - ", updateDocumentationRepo=" + this.updateDocumentationRepo + - ", springProjectUrl=" + this.springProjectUrl+ - ", springProjectBranch=" + this.springProjectBranch + - ", releaseTrainWikiPagePrefix=" + this.releaseTrainWikiPagePrefix + - ", cloneDestinationDir='" + this.cloneDestinationDir + '\'' + - ", fetchVersionsFromGit=" + this.fetchVersionsFromGit + - ", numberOfCheckedMilestones=" + this.numberOfCheckedMilestones + - ", updateSpringGuides=" + this.updateSpringGuides + - ", updateSpringProject=" + this.updateSpringProject + - ", sampleUrlsSize=" + this.allTestSampleUrls.size() + - '}'; + return "Git{" + "releaseTrainBomUrl='" + this.releaseTrainBomUrl + '\'' + + ", documentationUrl='" + this.documentationUrl + '\'' + + ", documentationBranch='" + this.documentationBranch + '\'' + + ", releaseTrainWikiUrl='" + this.releaseTrainWikiUrl + '\'' + + ", updateDocumentationRepo=" + this.updateDocumentationRepo + + ", springProjectUrl=" + this.springProjectUrl + + ", springProjectBranch=" + this.springProjectBranch + + ", releaseTrainWikiPagePrefix=" + this.releaseTrainWikiPagePrefix + + ", cloneDestinationDir='" + this.cloneDestinationDir + '\'' + + ", fetchVersionsFromGit=" + this.fetchVersionsFromGit + + ", numberOfCheckedMilestones=" + this.numberOfCheckedMilestones + + ", updateSpringGuides=" + this.updateSpringGuides + + ", updateSpringProject=" + this.updateSpringProject + + ", sampleUrlsSize=" + this.allTestSampleUrls.size() + '}'; } + } public static class Pom implements Serializable { /** - * Which branch of release train BOM should be checked out. Defaults to {@code master} + * Which branch of release train BOM should be checked out. Defaults to + * {@code master}. */ private String branch = "master"; /** - * Subfolder of the pom that contains the {@code spring-boot-starer-parent} dependency + * Subfolder of the pom that contains the {@code spring-boot-starer-parent} + * dependency. */ private String pomWithBootStarterParent = "spring-cloud-starter-parent/pom.xml"; /** - * Subfolder of the pom that contains the versions for the release train + * Subfolder of the pom that contains the versions for the release train. */ private String thisTrainBom = "spring-cloud-dependencies/pom.xml"; /** - * The pattern to match a version property in a BOM + * The pattern to match a version property in a BOM. */ private String bomVersionPattern = "^(spring-cloud-.*)\\.version$"; /** - * List of regular expressions of ignored poms. Defaults to test projects and samples. + * List of regular expressions of ignored poms. Defaults to test projects and + * samples. */ @SuppressWarnings("unchecked") - private List ignoredPomRegex = Arrays.asList( - "^.*\\.git/.*$", + private List ignoredPomRegex = Arrays.asList("^.*\\.git/.*$", "^.*spring-cloud-contract-maven-plugin/src/test/projects/.*$", "^.*spring-cloud-contract-maven-plugin/target/.*$", - "^.*samples/standalone/[a-z]+/.*$" - ); + "^.*samples/standalone/[a-z]+/.*$"); public String getBranch() { return this.branch; @@ -594,54 +705,57 @@ public class ReleaserProperties implements Serializable { @Override public String toString() { - return "Pom{" + - "branch='" + this.branch + '\'' + - ", pomWithBootStarterParent='" + this.pomWithBootStarterParent + '\'' + - ", thisTrainBom='" + this.thisTrainBom + '\'' + - ", bomVersionPattern='" + this.bomVersionPattern + '\'' + - ", ignoredPomRegex=" + this.ignoredPomRegex + - '}'; + return "Pom{" + "branch='" + this.branch + '\'' + + ", pomWithBootStarterParent='" + this.pomWithBootStarterParent + + '\'' + ", thisTrainBom='" + this.thisTrainBom + '\'' + + ", bomVersionPattern='" + this.bomVersionPattern + '\'' + + ", ignoredPomRegex=" + this.ignoredPomRegex + '}'; } + } public static class Maven implements Serializable { /** - * Command to be executed to build the project + * Placeholder for system properties. + */ + public static final String SYSTEM_PROPS_PLACEHOLDER = "{{systemProps}}"; + + /** + * Command to be executed to build the project. */ private String buildCommand = "./mvnw clean install -B -Pdocs {{systemProps}}"; /** - * Command to be executed to deploy a built project + * Command to be executed to deploy a built project. */ private String deployCommand = "./mvnw deploy -DskipTests -B -Pfast,deploy {{systemProps}}"; /** - * Command to be executed to publish documentation. If present "{{version}}" will be replaced by the - * provided version + * Command to be executed to publish documentation. If present "{{version}}" will + * be replaced by the provided version. */ - private String[] publishDocsCommands = { - "mkdir -p target", - "wget https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/ghpages.sh -O target/gh-pages.sh", - "chmod +x target/gh-pages.sh", - "./target/gh-pages.sh -v {{version}} -c" - }; + private String[] publishDocsCommands = { "mkdir -p target", + "wget https://raw.githubusercontent.com/spring-cloud/" + + "spring-cloud-build/master/" + + "docs/src/main/asciidoc/ghpages.sh -O target/gh-pages.sh", + "chmod +x target/gh-pages.sh", "./target/gh-pages.sh -v {{version}} -c" }; /** - * Command to be executed to generate release train documentation + * Command to be executed to generate release train documentation. */ - private String generateReleaseTrainDocsCommand = "bash release_train.sh --retrieveversions --version {{version}} --ghpages --auto"; - - public static final String SYSTEM_PROPS_PLACEHOLDER = "{{systemProps}}"; + private String generateReleaseTrainDocsCommand = "bash release_train.sh " + + "--retrieveversions --version {{version}} --ghpages --auto"; /** - * Additional system properties that should be passed to the build / deploy commands. - * If present in other commands "{{systemProps}}" will be substituted with this property. + * Additional system properties that should be passed to the build / deploy + * commands. If present in other commands "{{systemProps}}" will be substituted + * with this property. */ private String systemProperties = ""; /** - * Max wait time in minutes for the process to finish + * Max wait time in minutes for the process to finish. */ private long waitTimeInMinutes = 20; @@ -673,18 +787,19 @@ public class ReleaserProperties implements Serializable { return this.publishDocsCommands; } + public void setPublishDocsCommands(String[] publishDocsCommands) { + this.publishDocsCommands = publishDocsCommands; + } + public String getGenerateReleaseTrainDocsCommand() { return this.generateReleaseTrainDocsCommand; } - public void setGenerateReleaseTrainDocsCommand(String generateReleaseTrainDocsCommand) { + public void setGenerateReleaseTrainDocsCommand( + String generateReleaseTrainDocsCommand) { this.generateReleaseTrainDocsCommand = generateReleaseTrainDocsCommand; } - public void setPublishDocsCommands(String[] publishDocsCommands) { - this.publishDocsCommands = publishDocsCommands; - } - public String getSystemProperties() { return this.systemProperties; } @@ -693,26 +808,29 @@ public class ReleaserProperties implements Serializable { this.systemProperties = systemProperties; } - @Override public String toString() { - return "Maven{" + "buildCommand='" + this.buildCommand + '\'' + ", deployCommand='" - + this.deployCommand + '\'' + ", publishDocsCommands=" + Arrays - .toString(this.publishDocsCommands) + - "generateReleaseTrainDocsCommand='" + this.generateReleaseTrainDocsCommand + '\'' + - ", waitTimeInMinutes=" + this.waitTimeInMinutes + '}'; + @Override + public String toString() { + return "Maven{" + "buildCommand='" + this.buildCommand + '\'' + + ", deployCommand='" + this.deployCommand + '\'' + + ", publishDocsCommands=" + Arrays.toString(this.publishDocsCommands) + + "generateReleaseTrainDocsCommand='" + + this.generateReleaseTrainDocsCommand + '\'' + ", waitTimeInMinutes=" + + this.waitTimeInMinutes + '}'; } + } public static class Gradle implements Serializable { /** - * A mapping that should be applied to {@code gradle.properties} in order - * to perform a substitution of properties. The mapping is from a property - * inside {@code gradle.properties} to the projects name. Example + * A mapping that should be applied to {@code gradle.properties} in order to + * perform a substitution of properties. The mapping is from a property inside + * {@code gradle.properties} to the projects name. Example. * - * In {@code gradle.properties} you have {@code verifierVersion=1.0.0} . You - * want this property to get updated with the value of {@code spring-cloud-contract} - * version. Then it's enough to do the mapping like this for this Releaser's property: - * {@code verifierVersion=spring-cloud-contract} + * In {@code gradle.properties} you have {@code verifierVersion=1.0.0} . You want + * this property to get updated with the value of {@code spring-cloud-contract} + * version. Then it's enough to do the mapping like this for this Releaser's + * property: {@code verifierVersion=spring-cloud-contract}. */ private Map gradlePropsSubstitution = new HashMap() { { @@ -725,15 +843,14 @@ public class ReleaserProperties implements Serializable { }; /** - * List of regular expressions of ignored gradle props. - * Defaults to test projects and samples. + * List of regular expressions of ignored gradle props. Defaults to test projects + * and samples. */ @SuppressWarnings("unchecked") private List ignoredGradleRegex = Arrays.asList( "^.*spring-cloud-contract-maven-plugin/src/test/projects/.*$", "^.*spring-cloud-contract-maven-plugin/target/.*$", - "^.*samples/standalone/[a-z]+/.*$" - ); + "^.*samples/standalone/[a-z]+/.*$"); public Map getGradlePropsSubstitution() { return this.gradlePropsSubstitution; @@ -752,21 +869,23 @@ public class ReleaserProperties implements Serializable { this.ignoredGradleRegex = ignoredGradleRegex; } - @Override public String toString() { + @Override + public String toString() { return "Gradle{" + "gradlePropsSubstitution=" + this.gradlePropsSubstitution + ", ignoredGradleRegex=" + this.ignoredGradleRegex + '}'; } + } public static class Sagan implements Serializable { /** - * If set to {@code false} will not update Sagan + * If set to {@code false} will not update Sagan. */ private boolean updateSagan = true; /** - * URL to the Sagan API + * URL to the Sagan API. */ private String baseUrl = "https://spring.io"; @@ -786,14 +905,17 @@ public class ReleaserProperties implements Serializable { this.updateSagan = updateSagan; } - @Override public String toString() { + @Override + public String toString() { return "Sagan{" + "baseUrl='" + this.baseUrl + '\'' + '}'; } + } public static class Template implements Serializable { + /** - * Folder in which blog, email etc. templates are stored + * Folder in which blog, email etc. templates are stored. */ private String templateFolder = "cloud"; @@ -807,101 +929,9 @@ public class ReleaserProperties implements Serializable { @Override public String toString() { - return "Template{" + - "templateFolder='" + this.templateFolder + '\'' + - '}'; + return "Template{" + "templateFolder='" + this.templateFolder + '\'' + '}'; } + } - public String getWorkingDir() { - return StringUtils.hasText(this.workingDir) ? - this.workingDir : System.getProperty("user.dir"); - } - - public void setWorkingDir(String workingDir) { - this.workingDir = workingDir; - } - - public Git getGit() { - return this.git; - } - - public void setGit(Git git) { - this.git = git; - } - - public Pom getPom() { - return this.pom; - } - - public void setPom(Pom pom) { - this.pom = pom; - } - - public Maven getMaven() { - return this.maven; - } - - public void setMaven(Maven maven) { - this.maven = maven; - } - - public Gradle getGradle() { - return this.gradle; - } - - public void setGradle(Gradle gradle) { - this.gradle = gradle; - } - - public Map getFixedVersions() { - return this.fixedVersions; - } - - public void setFixedVersions(Map fixedVersions) { - this.fixedVersions = fixedVersions; - } - - public MetaRelease getMetaRelease() { - return this.metaRelease; - } - - public void setMetaRelease(MetaRelease metaRelease) { - this.metaRelease = metaRelease; - } - - public Sagan getSagan() { - return this.sagan; - } - - public void setSagan(Sagan sagan) { - this.sagan = sagan; - } - - public Template getTemplate() { - return this.template; - } - - public void setTemplate(Template template) { - this.template = template; - } - - public boolean isPostReleaseTasksOnly() { - return this.postReleaseTasksOnly; - } - - public void setPostReleaseTasksOnly(boolean postReleaseTasksOnly) { - this.postReleaseTasksOnly = postReleaseTasksOnly; - } - - @Override public String toString() { - return "ReleaserProperties{" + "workingDir='" + this.workingDir + '\'' + ", git=" + this.git - + ", pom=" + this.pom + ", maven=" + this.maven + ", gradle=" + this.gradle + ", sagan=" - + this.sagan + ", fixedVersions=" + this.fixedVersions + ", metaRelease=" - + this.metaRelease + ", template=" + this.template + '}'; - } - - public ReleaserProperties copy() { - return (ReleaserProperties) SerializationUtils.clone(this); - } } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserPropertiesAware.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserPropertiesAware.java index 99b0c251..55256c65 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserPropertiesAware.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserPropertiesAware.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal; /** @@ -6,4 +38,5 @@ package org.springframework.cloud.release.internal; public interface ReleaserPropertiesAware { void setReleaserProperties(ReleaserProperties properties); + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java index 8966db2c..98032d1e 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.io.File; @@ -15,18 +47,22 @@ import org.springframework.cloud.release.internal.template.TemplateGenerator; public class DocumentationUpdater implements ReleaserPropertiesAware { private final ProjectDocumentationUpdater projectDocumentationUpdater; + private final ReleaseTrainContentsUpdater releaseTrainContentsUpdater; + private ReleaserProperties properties; - public DocumentationUpdater(ProjectGitHandler gitHandler, ReleaserProperties properties, - TemplateGenerator templateGenerator) { + public DocumentationUpdater(ProjectGitHandler gitHandler, + ReleaserProperties properties, TemplateGenerator templateGenerator) { this.properties = properties; - this.projectDocumentationUpdater = new ProjectDocumentationUpdater(this.properties, gitHandler); - this.releaseTrainContentsUpdater = new ReleaseTrainContentsUpdater(this.properties, gitHandler, - templateGenerator); + this.projectDocumentationUpdater = new ProjectDocumentationUpdater( + this.properties, gitHandler); + this.releaseTrainContentsUpdater = new ReleaseTrainContentsUpdater( + this.properties, gitHandler, templateGenerator); } - DocumentationUpdater(ReleaserProperties properties, ProjectDocumentationUpdater updater, + DocumentationUpdater(ReleaserProperties properties, + ProjectDocumentationUpdater updater, ReleaseTrainContentsUpdater contentsUpdater) { this.properties = properties; this.projectDocumentationUpdater = updater; @@ -34,34 +70,34 @@ public class DocumentationUpdater implements ReleaserPropertiesAware { } /** - * Updates the documentation repository if current release train version is greater or equal - * than the one stored in the repo. - * - * @param currentProject - * @param springCloudReleaseBranch - * @return {@link File cloned temporary directory} - {@code null} if wrong version is used + * Updates the documentation repository if current release train version is greater or + * equal than the one stored in the repo. + * @param currentProject the project we're parsing + * @param bomReleaseBranch branch of the BOM + * @return {@link File cloned temporary directory} - {@code null} if wrong version is + * used */ - public File updateDocsRepo(ProjectVersion currentProject, String springCloudReleaseBranch) { - return this.projectDocumentationUpdater - .updateDocsRepo(currentProject, springCloudReleaseBranch); + public File updateDocsRepo(ProjectVersion currentProject, String bomReleaseBranch) { + return this.projectDocumentationUpdater.updateDocsRepo(currentProject, + bomReleaseBranch); } /** - * Updates the project page if current release train version is greater or equal - * than the one stored in the repo. - * - * @param projects - * @return {@link File cloned temporary directory} - {@code null} if wrong version is used or the switch is turned off + * Updates the project page if current release train version is greater or equal than + * the one stored in the repo. + * @param projects list of projects to update versions for + * @return {@link File cloned temporary directory} - {@code null} if wrong version is + * used or the switch is turned off */ public File updateProjectRepo(Projects projects) { return this.releaseTrainContentsUpdater.updateProjectRepo(projects); } /** - * Updates the release train wiki page - * - * @param projects - * @return {@link File cloned temporary directory} - {@code null} if wrong version is used or the switch is turned off + * Updates the release train wiki page. + * @param projects list of projects to update versions for + * @return {@link File cloned temporary directory} - {@code null} if wrong version is + * used or the switch is turned off */ public File updateReleaseTrainWiki(Projects projects) { return this.releaseTrainContentsUpdater.updateReleaseTrainWiki(projects); @@ -73,4 +109,5 @@ public class DocumentationUpdater implements ReleaserPropertiesAware { this.projectDocumentationUpdater.setReleaserProperties(properties); this.releaseTrainContentsUpdater.setReleaserProperties(properties); } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java index f75262aa..2b3f760e 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.io.File; @@ -18,9 +50,12 @@ import org.springframework.cloud.release.internal.pom.ProjectVersion; class ProjectDocumentationUpdater implements ReleaserPropertiesAware { private static final String SC_STATIC_URL = "http://cloud.spring.io/spring-cloud-static/"; - private static final Logger log = LoggerFactory.getLogger(ProjectDocumentationUpdater.class); + + private static final Logger log = LoggerFactory + .getLogger(ProjectDocumentationUpdater.class); private final ProjectGitHandler gitHandler; + private ReleaserProperties properties; ProjectDocumentationUpdater(ReleaserProperties properties, @@ -30,21 +65,24 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware { } /** - * Updates the documentation repository if current release train version is greater or equal - * than the one stored in the repo. - * - * @param currentProject - * @param springCloudReleaseBranch - * @return {@link File cloned temporary directory} - {@code null} if wrong version is used + * Updates the documentation repository if current release train version is greater or + * equal than the one stored in the repo. + * @param currentProject project to update the docs repo for + * @param bomBranch the bom project branch + * @return {@link File cloned temporary directory} - {@code null} if wrong version is + * used */ - File updateDocsRepo(ProjectVersion currentProject, String springCloudReleaseBranch) { + File updateDocsRepo(ProjectVersion currentProject, String bomBranch) { if (!this.properties.getGit().isUpdateDocumentationRepo()) { - log.info("Will not update documentation repository, since the switch to do so " - + "is off. Set [releaser.git.update-documentation-repo] to [true] to change that"); + log.info( + "Will not update documentation repository, since the switch to do so " + + "is off. Set [releaser.git.update-documentation-repo] to [true] to change that"); return null; } if (!currentProject.isReleaseOrServiceRelease()) { - log.info("Will not update documentation repository for non release or service release [{}]", currentProject.version); + log.info( + "Will not update documentation repository for non release or service release [{}]", + currentProject.version); return null; } File documentationProject = this.gitHandler.cloneDocumentationProject(); @@ -52,28 +90,38 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware { String pathToIndexHtml = "current/index.html"; File indexHtml = new File(documentationProject, pathToIndexHtml); if (!indexHtml.exists()) { - throw new IllegalStateException("index.html is not present at [" + pathToIndexHtml + "]"); + throw new IllegalStateException( + "index.html is not present at [" + pathToIndexHtml + "]"); } - return updateTheDocsRepo(springCloudReleaseBranch, documentationProject, indexHtml); + return updateTheDocsRepo(bomBranch, documentationProject, indexHtml); } - private File updateTheDocsRepo(String springCloudReleaseBranch, File documentationProject, File indexHtml) { + private File updateTheDocsRepo(String springCloudReleaseBranch, + File documentationProject, File indexHtml) { try { String indexHtmlText = readIndexHtmlContents(indexHtml); int index = indexHtmlText.indexOf(SC_STATIC_URL); if (index == -1) { - throw new IllegalStateException("The URL to the documentation repo not found in the index.html file"); + throw new IllegalStateException( + "The URL to the documentation repo not found in the index.html file"); } int beginIndex = index + SC_STATIC_URL.length(); String storedReleaseTrainLine = indexHtmlText.substring(beginIndex); - String storedReleaseTrain = storedReleaseTrainLine.substring(0, storedReleaseTrainLine.indexOf("/")); - String firstLetterOfReleaseTrain = String.valueOf(storedReleaseTrain.charAt(0)); - String currentReleaseTrainVersion = branchToReleaseVersion(springCloudReleaseBranch); - String firstLetterOfCurrentReleaseTrain = String.valueOf(currentReleaseTrainVersion.charAt(0)); - boolean newerOrEqualReleaseTrain = (!storedReleaseTrain.equals(currentReleaseTrainVersion)) && firstLetterOfCurrentReleaseTrain - .compareToIgnoreCase(firstLetterOfReleaseTrain) >= 0; + String storedReleaseTrain = storedReleaseTrainLine.substring(0, + storedReleaseTrainLine.indexOf("/")); + String firstLetterOfReleaseTrain = String + .valueOf(storedReleaseTrain.charAt(0)); + String currentReleaseTrainVersion = branchToReleaseVersion( + springCloudReleaseBranch); + String firstLetterOfCurrentReleaseTrain = String + .valueOf(currentReleaseTrainVersion.charAt(0)); + boolean newerOrEqualReleaseTrain = (!storedReleaseTrain + .equals(currentReleaseTrainVersion)) + && firstLetterOfCurrentReleaseTrain + .compareToIgnoreCase(firstLetterOfReleaseTrain) >= 0; if (!newerOrEqualReleaseTrain) { - log.info("Current release train [{}] is not newer than the stored one [{}]", + log.info( + "Current release train [{}] is not newer than the stored one [{}]", currentReleaseTrainVersion, storedReleaseTrain); return documentationProject; } @@ -95,11 +143,14 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware { private File pushCommitedChanges(String currentReleaseTrainVersion, File documentationProject, File indexHtml, String indexHtmlText, String storedReleaseTrain) throws IOException { - String replacedIndexHtml = indexHtmlText.replace(storedReleaseTrain, currentReleaseTrainVersion); + String replacedIndexHtml = indexHtmlText.replace(storedReleaseTrain, + currentReleaseTrainVersion); Files.write(indexHtml.toPath(), replacedIndexHtml.getBytes()); - log.info("Stored the release train [{}] in [{}]", - currentReleaseTrainVersion, indexHtml.getAbsolutePath()); - this.gitHandler.commit(documentationProject, "Updating the link to the current version to [" + currentReleaseTrainVersion + "]"); + log.info("Stored the release train [{}] in [{}]", currentReleaseTrainVersion, + indexHtml.getAbsolutePath()); + this.gitHandler.commit(documentationProject, + "Updating the link to the current version to [" + + currentReleaseTrainVersion + "]"); this.gitHandler.pushCurrentBranch(documentationProject); log.info("Committed and pushed changes to the documentation project"); return documentationProject; @@ -113,4 +164,5 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware { public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContents.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContents.java index 2f2a6a1a..6b68e064 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContents.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContents.java @@ -1,10 +1,44 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.util.List; import java.util.Objects; public class ReleaseTrainContents { + final Title title; + final List rows; ReleaseTrainContents(Title title, List rows) { @@ -14,11 +48,15 @@ public class ReleaseTrainContents { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } ReleaseTrainContents contents = (ReleaseTrainContents) o; - return Objects.equals(this.title, contents.title) && - Objects.equals(this.rows, contents.rows); + return Objects.equals(this.title, contents.title) + && Objects.equals(this.rows, contents.rows); } @Override @@ -33,5 +71,5 @@ public class ReleaseTrainContents { public List getRows() { return this.rows; } -} +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdater.java index 6052e962..7d52af73 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdater.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.io.File; @@ -31,13 +63,18 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware { private static final Logger log = LoggerFactory .getLogger(ReleaseTrainContentsUpdater.class); - private ReleaserProperties properties; private final ReleaseTrainContentsGitHandler handler; + private final ReleaseTrainContentsParser parser; + private final ReleaseTrainContentsGenerator generator; + private final TemplateGenerator templateGenerator; - ReleaseTrainContentsUpdater(ReleaserProperties properties, ProjectGitHandler handler, TemplateGenerator templateGenerator) { + private ReleaserProperties properties; + + ReleaseTrainContentsUpdater(ReleaserProperties properties, ProjectGitHandler handler, + TemplateGenerator templateGenerator) { this.properties = properties; this.handler = new ReleaseTrainContentsGitHandler(handler); this.templateGenerator = templateGenerator; @@ -46,22 +83,24 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware { } /** - * Updates the project page if current release train version is greater or equal - * than the one stored in the repo. - * - * @param projects - * @return {@link File cloned temporary directory} - {@code null} if wrong version is used or the switch is turned off + * Updates the project page if current release train version is greater or equal than + * the one stored in the repo. + * @param projects projects to update project repo for + * @return {@link File cloned temporary directory} - {@code null} if wrong version is + * used or the switch is turned off */ File updateProjectRepo(Projects projects) { if (!this.properties.getGit().isUpdateSpringProject()) { - log.info("Will not update the Spring Project cause the switch is turned off. Set [releaser.git.update-spring-project=true]."); + log.info("Will not update the Spring Project cause " + + "the switch is turned off. Set [releaser.git.update-spring-project=true]."); return null; } File releaseTrainProject = this.handler.cloneSpringDocProject(); File index = new File(releaseTrainProject, "index.html"); ReleaseTrainContents contents = this.parser.parseProjectPage(index); if (contents == null) { - log.warn("There are no markers for the index.html page - I don't really know what to do, so I'll back away"); + log.warn( + "There are no markers for the index.html page - I don't really know what to do, so I'll back away"); return null; } String newContents = this.generator.releaseTrainContents(contents, projects); @@ -72,8 +111,8 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware { return pushNewContents(projects, releaseTrainProject, index, newContents); } - private File pushNewContents(Projects projects, File releaseTrainProject, - File index, String newContents) { + private File pushNewContents(Projects projects, File releaseTrainProject, File index, + String newContents) { try { log.debug("Storing new contents to the page"); Files.write(index.toPath(), newContents.getBytes()); @@ -88,28 +127,35 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware { } /** - * Clones the test project, updates it and runs tests - * + * Clones the test project, updates it and runs tests. * @param projects - set of project with versions to assert against */ File updateReleaseTrainWiki(Projects projects) { - if (!this.properties.getGit().isUpdateReleaseTrainWiki() || - !this.properties.getMetaRelease().isEnabled()) { - log.info("Will not clone and update the release train wiki, since the switch to do so " - + "is off or it's not a meta-release. Set [releaser.git.update-release-train-wiki] to [true] to change that"); + if (!this.properties.getGit().isUpdateReleaseTrainWiki() + || !this.properties.getMetaRelease().isEnabled()) { + log.info( + "Will not clone and update the release train wiki, since the switch to do so " + + "is off or it's not a meta-release. Set [releaser.git.update-release-train-wiki] to [true] to change that"); return null; } File releaseTrainWiki = this.handler.cloneReleaseTrainWiki(); ProjectVersion releaseTrain = projects.releaseTrain(this.properties); String releaseTrainName = releaseTrain.major(); String wikiPagePrefix = this.properties.getGit().getReleaseTrainWikiPagePrefix(); - String releaseTrainDocFileName = releaseTrainDocFileName(releaseTrainName, wikiPagePrefix); - log.info("Reading the file [{}] for the current release train", releaseTrainDocFileName); - File releaseTrainDocFile = releaseTrainDocFile(releaseTrainWiki, releaseTrainDocFileName); - String releaseVersionFromCurrentFile = this.parser.latestReleaseTrainFromWiki(releaseTrainDocFile); - log.info("Latest release train version in the file is [{}]", releaseVersionFromCurrentFile); - if (!isThisReleaseTrainVersionNewer(releaseTrain, releaseVersionFromCurrentFile)) { - log.info("Current release train version [{}] is not " + String releaseTrainDocFileName = releaseTrainDocFileName(releaseTrainName, + wikiPagePrefix); + log.info("Reading the file [{}] for the current release train", + releaseTrainDocFileName); + File releaseTrainDocFile = releaseTrainDocFile(releaseTrainWiki, + releaseTrainDocFileName); + String releaseVersionFromCurrentFile = this.parser + .latestReleaseTrainFromWiki(releaseTrainDocFile); + log.info("Latest release train version in the file is [{}]", + releaseVersionFromCurrentFile); + if (!isThisReleaseTrainVersionNewer(releaseTrain, + releaseVersionFromCurrentFile)) { + log.info( + "Current release train version [{}] is not " + "newer than the version taken from the wiki [{}]", releaseTrain.version, releaseVersionFromCurrentFile); return releaseTrainWiki; @@ -118,7 +164,9 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware { releaseTrainName, releaseTrainDocFile, releaseVersionFromCurrentFile); } - private File generateNewWikiEntry(Projects projects, File releaseTrainWiki, ProjectVersion releaseTrain, String releaseTrainName, File releaseTrainDocFile, String releaseVersionFromCurrentFile) { + private File generateNewWikiEntry(Projects projects, File releaseTrainWiki, + ProjectVersion releaseTrain, String releaseTrainName, + File releaseTrainDocFile, String releaseVersionFromCurrentFile) { File releaseNotes = this.templateGenerator.releaseNotes(projects); try { List lines = Files.readAllLines(releaseTrainDocFile.toPath()); @@ -128,44 +176,54 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware { break; } } - return insertNewWikiContentBeforeTheLatestRelease(releaseTrainWiki, releaseTrain, - releaseTrainName, releaseTrainDocFile, releaseNotes, lines, lineIndex); + return insertNewWikiContentBeforeTheLatestRelease(releaseTrainWiki, + releaseTrain, releaseTrainName, releaseTrainDocFile, releaseNotes, + lines, lineIndex); } catch (IOException ex) { throw new IllegalStateException(ex); } } - private File insertNewWikiContentBeforeTheLatestRelease(File releaseTrainWiki, ProjectVersion releaseTrain, String releaseTrainName, File releaseTrainDocFile, File releaseNotes, List lines, int lineIndex) throws IOException { + private File insertNewWikiContentBeforeTheLatestRelease(File releaseTrainWiki, + ProjectVersion releaseTrain, String releaseTrainName, + File releaseTrainDocFile, File releaseNotes, List lines, + int lineIndex) throws IOException { String newContent = new StringJoiner("\n") - .add(String.join("\n", lines.subList(0, lineIndex))) - .add("\n").add(new String(Files.readAllBytes(releaseNotes.toPath()))) + .add(String.join("\n", lines.subList(0, lineIndex))).add("\n") + .add(new String(Files.readAllBytes(releaseNotes.toPath()))) .add(String.join("\n", lines.subList(lineIndex, lines.size()))) .toString(); Files.write(releaseTrainDocFile.toPath(), newContent.getBytes()); - log.info("Successfully stored new wiki contents for release train [{}]", releaseTrainName); + log.info("Successfully stored new wiki contents for release train [{}]", + releaseTrainName); this.handler.commitAndPushChanges(releaseTrainWiki, releaseTrain); return releaseTrainWiki; } - private String releaseTrainDocFileName(String releaseTrainName, String wikiPagePrefix) { - return new StringJoiner("-") - .add(wikiPagePrefix).add(releaseTrainName).add("Release-Notes.md").toString(); + private String releaseTrainDocFileName(String releaseTrainName, + String wikiPagePrefix) { + return new StringJoiner("-").add(wikiPagePrefix).add(releaseTrainName) + .add("Release-Notes.md").toString(); } - private boolean isThisReleaseTrainVersionNewer(ProjectVersion releaseTrain, String releaseVersionFromCurrentFile) { + private boolean isThisReleaseTrainVersionNewer(ProjectVersion releaseTrain, + String releaseVersionFromCurrentFile) { if (StringUtils.hasText(releaseVersionFromCurrentFile)) { - return releaseTrain.compareToReleaseTrainName(releaseVersionFromCurrentFile) > 0; + return releaseTrain + .compareToReleaseTrainName(releaseVersionFromCurrentFile) > 0; } return true; } - private File releaseTrainDocFile(File releaseTrainWiki, String releaseTrainDocFileName) { + private File releaseTrainDocFile(File releaseTrainWiki, + String releaseTrainDocFileName) { File releaseTrainDocFile = new File(releaseTrainWiki, releaseTrainDocFileName); if (!releaseTrainDocFile.exists()) { try { if (!releaseTrainDocFile.createNewFile()) { - throw new IllegalStateException("Failed to create releae train doc file"); + throw new IllegalStateException( + "Failed to create releae train doc file"); } } catch (IOException e) { @@ -180,6 +238,7 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware { this.properties = properties; this.generator.setReleaserProperties(properties); } + } /** @@ -189,29 +248,36 @@ class ReleaseTrainContentsGenerator implements ReleaserPropertiesAware { private static final Logger log = LoggerFactory .getLogger(ReleaseTrainContentsGenerator.class); + private static final String SPRING_PROJECT_TEMPLATE = "spring-project"; - private ReleaserProperties properties; private final File projectOutput; + private ReleaserProperties properties; + ReleaseTrainContentsGenerator(ReleaserProperties properties) { this.properties = properties; this.projectOutput = new File("target/index.html"); } String releaseTrainContents(ReleaseTrainContents currentContents, Projects projects) { - String trainProject = this.properties.getMetaRelease().getReleaseTrainProjectName(); + String trainProject = this.properties.getMetaRelease() + .getReleaseTrainProjectName(); ProjectVersion currentReleaseTrainProject = currentReleaseTrainProject(projects); - ProjectVersion lastGa = new ProjectVersion(trainProject, currentContents.title.lastGaTrainName); - ProjectVersion currentGa = new ProjectVersion(trainProject, currentContents.title.currentGaTrainName); - ReleaseTrainContents newReleaseTrainContents = updateReleaseTrainContentsIfNecessary(currentContents, projects, - currentReleaseTrainProject, lastGa, currentGa); + ProjectVersion lastGa = new ProjectVersion(trainProject, + currentContents.title.lastGaTrainName); + ProjectVersion currentGa = new ProjectVersion(trainProject, + currentContents.title.currentGaTrainName); + ReleaseTrainContents newReleaseTrainContents = updateReleaseTrainContentsIfNecessary( + currentContents, projects, currentReleaseTrainProject, lastGa, currentGa); if (!currentContents.equals(newReleaseTrainContents)) { - Template template = HandlebarsHelper.template(this.properties.getTemplate() - .getTemplateFolder(), SPRING_PROJECT_TEMPLATE); + Template template = HandlebarsHelper.template( + this.properties.getTemplate().getTemplateFolder(), + SPRING_PROJECT_TEMPLATE); return generate(this.projectOutput, template, newReleaseTrainContents); } - log.warn("Current release train [{}] is neither last [{}] or current [{}] or the projects haven't changed. Will not update the contents", + log.warn("Current release train [{}] is neither last [{}] " + + "or current [{}] or the projects haven't changed. Will not update the contents", currentReleaseTrainProject.version, lastGa, currentGa); return ""; } @@ -220,14 +286,16 @@ class ReleaseTrainContentsGenerator implements ReleaserPropertiesAware { return projects.releaseTrain(this.properties); } - private String generate(File contentOutput, Template template, ReleaseTrainContents releaseTrainContents) { + private String generate(File contentOutput, Template template, + ReleaseTrainContents releaseTrainContents) { try { Map map = ImmutableMap.builder() .put("lastGaTrainName", releaseTrainContents.title.lastGaTrainName) - .put("currentGaTrainName", releaseTrainContents.title.currentGaTrainName) - .put("currentSnapshotTrainName", releaseTrainContents.title.currentSnapshotTrainName) - .put("projects", releaseTrainContents.rows) - .build(); + .put("currentGaTrainName", + releaseTrainContents.title.currentGaTrainName) + .put("currentSnapshotTrainName", + releaseTrainContents.title.currentSnapshotTrainName) + .put("projects", releaseTrainContents.rows).build(); String contents = template.apply(map); Files.write(contentOutput.toPath(), contents.getBytes()); return contents; @@ -237,61 +305,77 @@ class ReleaseTrainContentsGenerator implements ReleaserPropertiesAware { } } - private ReleaseTrainContents updateReleaseTrainContentsIfNecessary(ReleaseTrainContents currentContents, Projects projects, - ProjectVersion currentReleaseTrainProject, ProjectVersion lastGa, ProjectVersion currentGa) { + private ReleaseTrainContents updateReleaseTrainContentsIfNecessary( + ReleaseTrainContents currentContents, Projects projects, + ProjectVersion currentReleaseTrainProject, ProjectVersion lastGa, + ProjectVersion currentGa) { ReleaseTrainContents newReleaseTrainContents = currentContents; // current GA is greater than the last GA if (greaterMinorOfLastGaReleaseTrain(currentReleaseTrainProject, lastGa)) { - Title title = new Title(currentReleaseTrainProject.version, currentContents.title.currentGaTrainName, + Title title = new Title(currentReleaseTrainProject.version, + currentContents.title.currentGaTrainName, currentContents.title.currentSnapshotTrainName); return updatedReleaseTrainContents(currentContents, projects, title, true); - } else if (currentReleaseTrainProject.isSameReleaseTrainName(currentGa.version)) { - Title title = new Title(currentContents.title.lastGaTrainName, currentReleaseTrainProject.isReleaseOrServiceRelease() ? - currentReleaseTrainProject.version : currentContents.title.currentGaTrainName, currentReleaseTrainProject.isSnapshot() ? - currentReleaseTrainProject.version : currentContents.title.currentSnapshotTrainName); + } + else if (currentReleaseTrainProject.isSameReleaseTrainName(currentGa.version)) { + Title title = new Title(currentContents.title.lastGaTrainName, + currentReleaseTrainProject.isReleaseOrServiceRelease() + ? currentReleaseTrainProject.version + : currentContents.title.currentGaTrainName, + currentReleaseTrainProject.isSnapshot() + ? currentReleaseTrainProject.version + : currentContents.title.currentSnapshotTrainName); return updatedReleaseTrainContents(currentContents, projects, title, false); } return newReleaseTrainContents; } - private boolean greaterMinorOfLastGaReleaseTrain(ProjectVersion currentReleaseTrainProject, ProjectVersion lastGa) { - return currentReleaseTrainProject.isSameReleaseTrainName(lastGa.version) && - currentReleaseTrainProject.isReleaseOrServiceRelease() && - currentReleaseTrainProject.compareToReleaseTrainName(lastGa.version) > 0; + private boolean greaterMinorOfLastGaReleaseTrain( + ProjectVersion currentReleaseTrainProject, ProjectVersion lastGa) { + return currentReleaseTrainProject.isSameReleaseTrainName(lastGa.version) + && currentReleaseTrainProject.isReleaseOrServiceRelease() + && currentReleaseTrainProject + .compareToReleaseTrainName(lastGa.version) > 0; } - private ReleaseTrainContents updatedReleaseTrainContents(ReleaseTrainContents currentContents, Projects projects, - Title title, boolean lastGa) { + private ReleaseTrainContents updatedReleaseTrainContents( + ReleaseTrainContents currentContents, Projects projects, Title title, + boolean lastGa) { List rows = Row.fromProjects(projects, lastGa); - return new ReleaseTrainContents( - title, currentContents.rows.stream().map(current -> { - Row projectRow = rows.stream().filter(row -> - current.componentName.equals(row.componentName)).findFirst().orElse(current); - if (projectRow == current) { - return projectRow; - } - return from(current, projectRow); - }).collect(Collectors.toCollection(LinkedList::new))); + return new ReleaseTrainContents(title, + currentContents.rows.stream().map(current -> { + Row projectRow = rows.stream().filter( + row -> current.componentName.equals(row.componentName)) + .findFirst().orElse(current); + if (projectRow == current) { + return projectRow; + } + return from(current, projectRow); + }).collect(Collectors.toCollection(LinkedList::new))); } private Row from(Row current, Row project) { - return new Row(current.componentName, StringUtils.hasText(project.lastGaVersion) ? - project.lastGaVersion : current.lastGaVersion, - StringUtils.hasText(project.currentGaVersion) ? - project.currentGaVersion : current.currentGaVersion, - StringUtils.hasText(project.currentSnapshotVersion) ? - project.currentSnapshotVersion : current.currentSnapshotVersion); + return new Row(current.componentName, + StringUtils.hasText(project.lastGaVersion) ? project.lastGaVersion + : current.lastGaVersion, + StringUtils.hasText(project.currentGaVersion) ? project.currentGaVersion + : current.currentGaVersion, + StringUtils.hasText(project.currentSnapshotVersion) + ? project.currentSnapshotVersion + : current.currentSnapshotVersion); } @Override public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; } + } class ReleaseTrainContentsGitHandler { - private static final Logger log = LoggerFactory.getLogger(ReleaseTrainContentsGitHandler.class); + private static final Logger log = LoggerFactory + .getLogger(ReleaseTrainContentsGitHandler.class); private static final String PROJECT_PAGE_UPDATED_COMMIT_MSG = "Updating project page to release train [%s]"; @@ -311,7 +395,8 @@ class ReleaseTrainContentsGitHandler { void commitAndPushChanges(File repo, ProjectVersion releaseTrain) { log.debug("Committing and pushing changes"); - this.handler.commit(repo, String.format(PROJECT_PAGE_UPDATED_COMMIT_MSG, releaseTrain.version)); + this.handler.commit(repo, + String.format(PROJECT_PAGE_UPDATED_COMMIT_MSG, releaseTrain.version)); this.handler.pushCurrentBranch(repo); } @@ -327,7 +412,8 @@ class ReleaseTrainContentsParser { String contents = new String(Files.readAllBytes(rawHtml.toPath())); String[] split = contents.split(""); if (split.length != 3) { - log.warn("The page is missing the components table markers. Please add [] and [] to the file."); + log.warn("The page is missing the components table markers. " + + "Please add [] and [] to the file."); return null; } String table = split[1]; @@ -349,14 +435,13 @@ class ReleaseTrainContentsParser { String latestReleaseTrainFromWiki(File rawMd) { try { return Files.readAllLines(rawMd.toPath()).stream() - .filter(s -> s.trim().startsWith("#")) - .map(s -> s.substring(1).trim()) - .filter(s -> new ProjectVersion("foo", s).isValid()) - .findFirst() + .filter(s -> s.trim().startsWith("#")).map(s -> s.substring(1).trim()) + .filter(s -> new ProjectVersion("foo", s).isValid()).findFirst() .orElse(""); } catch (IOException e) { throw new IllegalStateException(e); } } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Row.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Row.java index 11a44844..ae63ebd9 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Row.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Row.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.util.LinkedList; @@ -12,9 +44,13 @@ import org.springframework.cloud.release.internal.pom.Projects; * @author Marcin Grzejszczak */ public class Row { + final String componentName; + final String lastGaVersion; + final String currentGaVersion; + final String currentSnapshotVersion; Row(String[] row) { @@ -25,7 +61,8 @@ public class Row { this.currentSnapshotVersion = row[initialIndex + 3].trim(); } - Row(String componentName, String lastGaVersion, String currentGaVersion, String currentSnapshotVersion) { + Row(String componentName, String lastGaVersion, String currentGaVersion, + String currentSnapshotVersion) { this.componentName = componentName.trim(); this.lastGaVersion = lastGaVersion.trim(); this.currentGaVersion = currentGaVersion.trim(); @@ -33,34 +70,36 @@ public class Row { } static List fromProjects(Projects projects, boolean lastGa) { - return projects - .stream() + return projects.stream() .map(v -> new Row(v.projectName, lastGa ? versionOrEmptyForGa(v) : "", - !lastGa ? versionOrEmptyForGa(v) : "", v.isSnapshot() ? v.version : "")) + !lastGa ? versionOrEmptyForGa(v) : "", + v.isSnapshot() ? v.version : "")) .collect(Collectors.toCollection(LinkedList::new)); } private static String versionOrEmptyForGa(ProjectVersion v) { - return v.isReleaseOrServiceRelease() ? - v.version : ""; + return v.isReleaseOrServiceRelease() ? v.version : ""; } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } Row row = (Row) o; - return Objects.equals(this.componentName, row.componentName) && - Objects.equals(this.lastGaVersion, row.lastGaVersion) && - Objects.equals(this.currentGaVersion, row.currentGaVersion) && - Objects.equals(this.currentSnapshotVersion, row.currentSnapshotVersion); + return Objects.equals(this.componentName, row.componentName) + && Objects.equals(this.lastGaVersion, row.lastGaVersion) + && Objects.equals(this.currentGaVersion, row.currentGaVersion) && Objects + .equals(this.currentSnapshotVersion, row.currentSnapshotVersion); } @Override public int hashCode() { - return Objects - .hash(this.componentName, this.lastGaVersion, - this.currentGaVersion, this.currentSnapshotVersion); + return Objects.hash(this.componentName, this.lastGaVersion, this.currentGaVersion, + this.currentSnapshotVersion); } public String getComponentName() { @@ -78,4 +117,5 @@ public class Row { public String getCurrentSnapshotVersion() { return this.currentSnapshotVersion; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Title.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Title.java index fe5bfbe5..57b20610 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Title.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Title.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.util.Objects; @@ -8,7 +40,9 @@ import java.util.Objects; public class Title { final String lastGaTrainName; + final String currentGaTrainName; + final String currentSnapshotTrainName; Title(String[] row) { @@ -18,7 +52,8 @@ public class Title { this.currentSnapshotTrainName = row[initialIndex + 2].trim(); } - Title(String lastGaTrainName, String currentGaTrainName, String currentSnapshotTrainName) { + Title(String lastGaTrainName, String currentGaTrainName, + String currentSnapshotTrainName) { this.lastGaTrainName = lastGaTrainName.trim(); this.currentGaTrainName = currentGaTrainName.trim(); this.currentSnapshotTrainName = currentSnapshotTrainName.trim(); @@ -26,19 +61,23 @@ public class Title { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } Title title = (Title) o; - return Objects.equals(this.lastGaTrainName, title.lastGaTrainName) && - Objects.equals(this.currentGaTrainName, title.currentGaTrainName) && - Objects - .equals(this.currentSnapshotTrainName, title.currentSnapshotTrainName); + return Objects.equals(this.lastGaTrainName, title.lastGaTrainName) + && Objects.equals(this.currentGaTrainName, title.currentGaTrainName) + && Objects.equals(this.currentSnapshotTrainName, + title.currentSnapshotTrainName); } @Override public int hashCode() { - return Objects - .hash(this.lastGaTrainName, this.currentGaTrainName, this.currentSnapshotTrainName); + return Objects.hash(this.lastGaTrainName, this.currentGaTrainName, + this.currentSnapshotTrainName); } public String getLastGaTrainName() { @@ -52,4 +91,5 @@ public class Title { public String getCurrentSnapshotTrainName() { return this.currentSnapshotTrainName; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GitRepo.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GitRepo.java index bc2c310d..eb0b4645 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GitRepo.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GitRepo.java @@ -1,18 +1,35 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.File; @@ -58,8 +75,8 @@ import org.springframework.util.ResourceUtils; import org.springframework.util.StringUtils; /** - * Abstraction over a Git repo. Can cloned repo from a given location - * and check its branch. + * Abstraction over a Git repo. Can cloned repo from a given location and check its + * branch. * * @author Marcin Grzejszczak */ @@ -89,7 +106,7 @@ class GitRepo { } /** - * Clones the project + * Clones the project. * @param projectUri - URI of the project * @return file where the project was cloned */ @@ -111,7 +128,7 @@ class GitRepo { } /** - * Checks out a branch for a project + * Checks out a branch for a project. * @param branch - branch to check out */ void checkout(String branch) { @@ -126,31 +143,35 @@ class GitRepo { } /** - * Performs a commit + * Performs a commit. * @param message - commit message */ void commit(String message) { - try(Git git = this.gitFactory.open(file(this.basedir))) { + try (Git git = this.gitFactory.open(file(this.basedir))) { git.add().addFilepattern(".").call(); git.commit().setAllowEmpty(false).setMessage(message).call(); printLog(git); - } catch (EmtpyCommitException e) { + } + catch (EmtpyCommitException e) { log.info("There were no changes detected. Will not commit an empty commit"); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } boolean hasBranch(String branch) { - try(Git git = this.gitFactory.open(file(this.basedir))) { + try (Git git = this.gitFactory.open(file(this.basedir))) { List refs = git.branchList().setListMode(ListBranchCommand.ListMode.ALL) .call(); - boolean present = refs.stream().anyMatch(ref -> branch.equals(nameOfBranch(ref.getName()))); + boolean present = refs.stream() + .anyMatch(ref -> branch.equals(nameOfBranch(ref.getName()))); if (log.isDebugEnabled()) { log.debug("Branch [{}] is present [{}]", branch, present); } return present; - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } @@ -165,84 +186,92 @@ class GitRepo { log.info("Printing [{}] last commits for branch [{}]", maxCount, currentBranch); Iterable commits = git.log().setMaxCount(maxCount).call(); for (RevCommit commit : commits) { - log.info("Name [{}], msg [{}]", commit.getId().name(), commit.getShortMessage()); + log.info("Name [{}], msg [{}]", commit.getId().name(), + commit.getShortMessage()); } } /** - * Creates a tag with a given name - * @param tagName + * Creates a tag with a given name. + * @param tagName name of the tag to set */ void tag(String tagName) { - try(Git git = this.gitFactory.open(file(this.basedir))) { + try (Git git = this.gitFactory.open(file(this.basedir))) { git.tag().setName(tagName).call(); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } /** - * Pushes the commits to {@code origin} remote branch + * Pushes the commits to {@code origin} remote branch. * @param branch - remote branch to which the code should be pushed */ void pushBranch(String branch) { - try(Git git = this.gitFactory.open(file(this.basedir))) { + try (Git git = this.gitFactory.open(file(this.basedir))) { String localBranch = git.getRepository().getFullBranch(); RefSpec refSpec = new RefSpec(localBranch + ":" + branch); this.gitFactory.push(git).setPushTags().setRefSpecs(refSpec).call(); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } /** - * Pushes the commits od current branch + * Pushes the commits od current branch. */ void pushCurrentBranch() { - try(Git git = this.gitFactory.open(file(this.basedir))) { + try (Git git = this.gitFactory.open(file(this.basedir))) { this.gitFactory.push(git).call(); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } /** - * Pushes the commits to {@code origin} remote tag + * Pushes the commits to {@code origin} remote tag. * @param tagName - remote tag to which the code should be pushed */ void pushTag(String tagName) { - try(Git git = this.gitFactory.open(file(this.basedir))) { + try (Git git = this.gitFactory.open(file(this.basedir))) { String localBranch = git.getRepository().getFullBranch(); RefSpec refSpec = new RefSpec(localBranch + ":" + "refs/tags/" + tagName); this.gitFactory.push(git).setPushTags().setRefSpecs(refSpec).call(); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } void revert(String message) { - try(Git git = this.gitFactory.open(file(this.basedir))) { + try (Git git = this.gitFactory.open(file(this.basedir))) { RevCommit commit = git.log().setMaxCount(1).call().iterator().next(); String shortMessage = commit.getShortMessage(); String id = commit.getId().getName(); if (!shortMessage.contains("Update SNAPSHOT to ")) { - throw new IllegalStateException("Won't revert the commit with id [" + id + "] " - + "and message [" + shortMessage + "]. Only commit that updated " - + "snapshot to another version can be reverted"); + throw new IllegalStateException( + "Won't revert the commit with id [" + id + "] " + "and message [" + + shortMessage + "]. Only commit that updated " + + "snapshot to another version can be reverted"); } log.debug("The commit to be reverted is [{}]", commit); git.revert().include(commit).call(); git.commit().setAmend(true).setMessage(message).call(); printLog(git); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } String currentBranch() { - try(Git git = this.gitFactory.open(file(this.basedir))) { + try (Git git = this.gitFactory.open(file(this.basedir))) { return git.getRepository().getBranch(); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } @@ -254,8 +283,8 @@ class GitRepo { private Git cloneToBasedir(URIish projectUrl, File destinationFolder) throws GitAPIException { CloneCommand command = this.gitFactory.getCloneCommandByCloneRepository() - .setURI(projectUrl.toString() + ".git").setDirectory( - humanishDestination(projectUrl, destinationFolder)); + .setURI(projectUrl.toString() + ".git") + .setDirectory(humanishDestination(projectUrl, destinationFolder)); try { return command.call(); } @@ -269,8 +298,7 @@ class GitRepo { return new File(destinationFolder, projectUrl.getHumanishName()); } - private Ref checkoutBranch(File projectDir, String branch) - throws GitAPIException { + private Ref checkoutBranch(File projectDir, String branch) throws GitAPIException { Git git = this.gitFactory.open(projectDir); CheckoutCommand command = git.checkout().setName(branch); try { @@ -282,7 +310,8 @@ class GitRepo { catch (GitAPIException e) { deleteBaseDirIfExists(); throw e; - } finally { + } + finally { git.close(); } } @@ -305,8 +334,8 @@ class GitRepo { return containsBranch(git, label, null); } - private boolean containsBranch(Git git, String label, ListBranchCommand.ListMode listMode) - throws GitAPIException { + private boolean containsBranch(Git git, String label, + ListBranchCommand.ListMode listMode) throws GitAPIException { ListBranchCommand command = git.branchList(); if (listMode != null) { command.setListMode(listMode); @@ -336,31 +365,37 @@ class GitRepo { * {@link org.eclipse.jgit.api.CloneCommand} allowing for easier unit testing. */ static class JGitFactory { + private static final Logger log = LoggerFactory.getLogger(JGitFactory.class); private final JschConfigSessionFactory factory = new JschConfigSessionFactory() { - @Override protected void configure(OpenSshConfig.Host host, Session session) { + @Override + protected void configure(OpenSshConfig.Host host, Session session) { } @Override protected JSch createDefaultJSch(FS fs) throws JSchException { Connector connector = null; try { - if(SSHAgentConnector.isConnectorAvailable()){ + if (SSHAgentConnector.isConnectorAvailable()) { USocketFactory usf = new JNAUSocketFactory(); connector = new SSHAgentConnector(usf); } log.info("Successfully connected to an agent"); - } catch (AgentProxyException e) { - log.error("Exception occurred while trying to connect to agent. Will create" - + "the default JSch connection", e); + } + catch (AgentProxyException e) { + log.error( + "Exception occurred while trying to connect to agent. Will create" + + "the default JSch connection", + e); return super.createDefaultJSch(fs); } final JSch jsch = super.createDefaultJSch(fs); if (connector != null) { JSch.setConfig("PreferredAuthentications", "publickey,password"); - IdentityRepository identityRepository = new RemoteIdentityRepository(connector); + IdentityRepository identityRepository = new RemoteIdentityRepository( + connector); jsch.setIdentityRepository(identityRepository); } return jsch; @@ -369,27 +404,6 @@ class GitRepo { private final CredentialsProvider provider; - JGitFactory(ReleaserProperties releaserProperties) { - if (StringUtils.hasText(releaserProperties.getGit().getUsername())) { - log.info("Passed username and password - will set a custom credentials provider"); - this.provider = credentialsProvider(releaserProperties); - } else { - log.info("No custom credentials provider will be set"); - this.provider = null; - } - } - - CredentialsProvider credentialsProvider(ReleaserProperties properties) { - return new UsernamePasswordCredentialsProvider( - properties.getGit().getUsername(), - properties.getGit().getPassword()); - } - - // for tests - JGitFactory() { - this.provider = null; - } - private final TransportConfigCallback callback = transport -> { if (transport instanceof SshTransport) { SshTransport sshTransport = (SshTransport) transport; @@ -397,15 +411,35 @@ class GitRepo { } }; + JGitFactory(ReleaserProperties releaserProperties) { + if (StringUtils.hasText(releaserProperties.getGit().getUsername())) { + log.info( + "Passed username and password - will set a custom credentials provider"); + this.provider = credentialsProvider(releaserProperties); + } + else { + log.info("No custom credentials provider will be set"); + this.provider = null; + } + } + + // for tests + JGitFactory() { + this.provider = null; + } + + CredentialsProvider credentialsProvider(ReleaserProperties properties) { + return new UsernamePasswordCredentialsProvider( + properties.getGit().getUsername(), properties.getGit().getPassword()); + } + CloneCommand getCloneCommandByCloneRepository() { - return Git.cloneRepository() - .setCredentialsProvider(this.provider) + return Git.cloneRepository().setCredentialsProvider(this.provider) .setTransportConfigCallback(this.callback); } PushCommand push(Git git) { - return git.push() - .setCredentialsProvider(this.provider) + return git.push().setCredentialsProvider(this.provider) .setTransportConfigCallback(this.callback); } @@ -417,5 +451,7 @@ class GitRepo { throw new IllegalStateException(e); } } + } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubIssues.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubIssues.java index a55fd86c..c4ba2202 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubIssues.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubIssues.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.IOException; @@ -12,6 +44,7 @@ import com.jcabi.github.RtGithub; import com.jcabi.http.wire.RetryWire; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.pom.ProjectVersion; import org.springframework.cloud.release.internal.pom.Projects; @@ -24,14 +57,16 @@ import org.springframework.util.StringUtils; class GithubIssues { private static final Logger log = LoggerFactory.getLogger(GithubIssues.class); + private static final String GITHUB_ISSUE_TITLE = "Spring Cloud Release took place"; private final Github github; + private final ReleaserProperties properties; GithubIssues(ReleaserProperties properties) { - this.github = new RtGithub(new RtGithub( - properties.getGit().getOauthToken()).entry().through(RetryWire.class)); + this.github = new RtGithub(new RtGithub(properties.getGit().getOauthToken()) + .entry().through(RetryWire.class)); this.properties = properties; } @@ -51,12 +86,15 @@ class GithubIssues { // do this only for RELEASE & SR String releaseVersion = parsedVersion(); if (!(version.isRelease() || version.isServiceRelease())) { - log.info("Guide issue creation will occur only for Release or Service Release versions. Your version is [{}]", releaseVersion); + log.info( + "Guide issue creation will occur only for Release or Service Release versions. Your version is [{}]", + releaseVersion); return; } Repo springGuides = this.github.repos() .get(new Coordinates.Simple("spring-guides", "getting-started-guides")); - String issueTitle = StringUtils.capitalize(releaseVersion) + " " + GITHUB_ISSUE_TITLE; + String issueTitle = StringUtils.capitalize(releaseVersion) + " " + + GITHUB_ISSUE_TITLE; // check if the issue is not already there boolean issueAlreadyFiled = issueAlreadyFiled(springGuides, issueTitle); if (issueAlreadyFiled) { @@ -66,7 +104,9 @@ class GithubIssues { try { int number = springGuides.issues().create(issueTitle, issueText(projects)) .number(); - log.info("Successfully created an issue with title [{}] in Spring Guides under: https://github.com/spring-guides/getting-started-guides/issues/" + number, issueTitle); + log.info("Successfully created an issue with " + + "title [{}] in Spring Guides under: https://github.com/spring-guides/getting-started-guides/issues/" + + number, issueTitle); } catch (IOException e) { log.error("Exception occurred while trying to create the issue in guides", e); @@ -82,15 +122,11 @@ class GithubIssues { } private String issueText(Projects projects) { - StringBuilder builder = new StringBuilder() - .append("Spring Cloud [") - .append(parsedVersion()) - .append("] Released with the following projects:") + StringBuilder builder = new StringBuilder().append("Spring Cloud [") + .append(parsedVersion()).append("] Released with the following projects:") .append("\n\n"); - projects.forEach(project -> builder - .append(project.projectName).append(" : ") - .append("`").append(project.version).append("`") - .append("\n")); + projects.forEach(project -> builder.append(project.projectName).append(" : ") + .append("`").append(project.version).append("`").append("\n")); return builder.toString(); } @@ -116,4 +152,5 @@ class GithubIssues { } return false; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java index f19ebeca..cae7c0a1 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.IOException; @@ -25,16 +57,18 @@ import org.springframework.util.StringUtils; */ class GithubMilestones { - private static final Logger log = LoggerFactory.getLogger(GithubMilestones.class); - - private final Github github; - private final ReleaserProperties properties; static final Map MILESTONE_URL_CACHE = new ConcurrentHashMap<>(); static final Map MILESTONE_CACHE = new ConcurrentHashMap<>(); + private static final Logger log = LoggerFactory.getLogger(GithubMilestones.class); + + private final Github github; + + private final ReleaserProperties properties; + GithubMilestones(ReleaserProperties properties) { - this.github = new RtGithub(new RtGithub( - properties.getGit().getOauthToken()).entry().through(RetryWire.class)); + this.github = new RtGithub(new RtGithub(properties.getGit().getOauthToken()) + .entry().through(RetryWire.class)); this.properties = properties; } @@ -66,32 +100,35 @@ class GithubMilestones { catch (IOException e) { log.error("Exception occurred while trying to retrieve the milestone", e); } - } else { + } + else { log.warn("No matching milestone was found"); } } - Milestone.Smart matchingMilestone(String tagVersion, - Iterable milestones) { + Milestone.Smart matchingMilestone(String tagVersion, Iterable milestones) { log.debug("Successfully received list of milestones [{}]", milestones); log.info("Will try to match against tag version [{}]", tagVersion); try { int counter = 0; for (Milestone milestone : milestones) { - if (counter++ >= this.properties.getGit().getNumberOfCheckedMilestones()) { - log.warn("No matching milestones were found within the provided threshold [{}] of checked milestones", + if (counter++ >= this.properties.getGit() + .getNumberOfCheckedMilestones()) { + log.warn( + "No matching milestones were found within the provided threshold [{}] of checked milestones", this.properties.getGit().getNumberOfCheckedMilestones()); return null; } Milestone.Smart smartMilestone = new Milestone.Smart(milestone); String title = milestoneTitle(smartMilestone); - if (tagVersion.equals(title) || numericVersion(tagVersion) - .equals(title)) { + if (tagVersion.equals(title) + || numericVersion(tagVersion).equals(title)) { log.info("Found a matching milestone [{}]", smartMilestone.number()); return smartMilestone; } } - } catch (AssertionError | IOException e) { + } + catch (AssertionError | IOException e) { log.error("Exception occurred while trying to retrieve the milestone", e); return null; } @@ -107,7 +144,8 @@ class GithubMilestones { Assert.hasText(this.properties.getGit().getOauthToken(), "You have to pass Github OAuth token for milestone closing to be operational"); String tagVersion = version.version; - Milestone.Smart foundMilestone = matchingMilestone(tagVersion, closedMilestones(version)); + Milestone.Smart foundMilestone = matchingMilestone(tagVersion, + closedMilestones(version)); String foundUrl = ""; if (foundMilestone != null) { try { @@ -115,7 +153,7 @@ class GithubMilestones { log.info("Found a matching milestone with issues URL [{}]", url); foundUrl = url.toString() .replace("https://api.github.com/repos", "https://github.com") - .replace("milestones", "milestone")+ "?closed=1"; + .replace("milestones", "milestone") + "?closed=1"; } catch (IOException e) { throw new IllegalStateException(e); @@ -129,8 +167,8 @@ class GithubMilestones { } private String numericVersion(String version) { - return version.contains("RELEASE") ? - version.substring(0, version.lastIndexOf(".")) : ""; + return version.contains("RELEASE") + ? version.substring(0, version.lastIndexOf(".")) : ""; } String milestoneTitle(Milestone.Smart milestone) throws IOException { @@ -145,9 +183,10 @@ class GithubMilestones { Map map) { try { return this.github.repos() - .get(new Coordinates.Simple(org(), version.projectName)) - .milestones().iterate(map); - } catch (AssertionError e) { + .get(new Coordinates.Simple(org(), version.projectName)).milestones() + .iterate(map); + } + catch (AssertionError e) { log.error("Exception occurred while trying to fetch milestones", e); return new ArrayList<>(); } @@ -180,4 +219,5 @@ class GithubMilestones { params.put("direction", "desc"); return params; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java index 40bdd295..3cbba140 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.File; @@ -15,7 +47,7 @@ import org.springframework.cloud.release.internal.pom.Projects; import org.springframework.util.StringUtils; /** - * Contains business logic around Git & Github operations + * Contains business logic around Git & Github operations. * * @author Marcin Grzejszczak */ @@ -24,11 +56,17 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { private static final Logger log = LoggerFactory.getLogger(ProjectGitHandler.class); private static final String MSG = "Bumping versions"; + private static final String PRE_RELEASE_MSG = "Update SNAPSHOT to %s"; + private static final String POST_RELEASE_MSG = "Going back to snapshots"; + private static final String POST_RELEASE_BUMP_MSG = "Bumping versions to %s after release"; + private final GithubMilestones githubMilestones; + private final GithubIssues githubIssues; + private ReleaserProperties properties; public ProjectGitHandler(ReleaserProperties properties) { @@ -40,11 +78,14 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { public void commitAndTagIfApplicable(File project, ProjectVersion version) { GitRepo gitRepo = gitRepo(project); if (version.isSnapshot()) { - log.info("Snapshot version [{}] found. Will only commit the changed poms", version); + log.info("Snapshot version [{}] found. Will only commit the changed poms", + version); gitRepo.commit(MSG); } else { - log.info("NON-snapshot version [{}] found. Will commit the changed poms, tag the version and push the tag", version); + log.info( + "NON-snapshot version [{}] found. Will commit the changed poms, tag the version and push the tag", + version); gitRepo.commit(String.format(PRE_RELEASE_MSG, version.version)); String tagName = "v" + version.version; gitRepo.tag(tagName); @@ -54,9 +95,10 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { public void commitAfterBumpingVersions(File project, ProjectVersion version) { if (version.isSnapshot()) { - log.info("Snapshot version [{}] found. Will only commit the changed poms", version); - commit(project, String - .format(POST_RELEASE_BUMP_MSG, version.bumpedVersion())); + log.info("Snapshot version [{}] found. Will only commit the changed poms", + version); + commit(project, + String.format(POST_RELEASE_BUMP_MSG, version.bumpedVersion())); } else { log.info("Non snapshot version [{}] found. Won't do anything", version); @@ -87,18 +129,17 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { } public File cloneDocumentationProject() { - return cloneAndCheckOut(this.properties.getGit() - .getDocumentationUrl(), this.properties.getGit() - .getDocumentationBranch()); + return cloneAndCheckOut(this.properties.getGit().getDocumentationUrl(), + this.properties.getGit().getDocumentationBranch()); } public File cloneSpringDocProject() { - return cloneAndCheckOut(this.properties.getGit() - .getSpringProjectUrl(), this.properties.getGit() - .getSpringProjectBranch()); + return cloneAndCheckOut(this.properties.getGit().getSpringProjectUrl(), + this.properties.getGit().getSpringProjectBranch()); } - private File cloneAndCheckOut(String springProjectUrl, String springProjectUrlBranch) { + private File cloneAndCheckOut(String springProjectUrl, + String springProjectUrlBranch) { File clonedProject = cloneProject(springProjectUrl); checkout(clonedProject, springProjectUrlBranch); return clonedProject; @@ -111,8 +152,8 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { */ public File cloneProjectFromOrg(String projectName) { String orgUrl = this.properties.getMetaRelease().getGitOrgUrl(); - String fullUrl = orgUrl.endsWith("/") ? (orgUrl + projectName) : (orgUrl + "/" + - projectName + suffixNonHttpRepo(orgUrl)); + String fullUrl = orgUrl.endsWith("/") ? (orgUrl + projectName) + : (orgUrl + "/" + projectName + suffixNonHttpRepo(orgUrl)); if (log.isDebugEnabled()) { log.debug("Full url of the project is [{}]", fullUrl); } @@ -122,20 +163,20 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { } String version = this.properties.getFixedVersions().get(projectName); if (StringUtils.isEmpty(version)) { - throw new IllegalStateException("You haven't provided a version for project [" + projectName + "]"); + throw new IllegalStateException( + "You haven't provided a version for project [" + projectName + "]"); } return findAndCheckOutBranchForVersion(clonedProject, new String[] { version }); } - /** - * From the version analyzes the branch and checks it out. E.g. - * - for spring-cloud-release’s `Finchley.RELEASE version will resolve either Finchley - * branch or will fallback to master if there’s no Finchley branch - * - for spring-cloud-sleuth’s `2.1.0.RELEASE version will resolve 2.1.x branch - * + * From the version analyzes the branch and checks it out. E.g. - for + * spring-cloud-release’s `Finchley.RELEASE version will resolve either Finchley + * branch or will fallback to master if there’s no Finchley branch - for + * spring-cloud-sleuth’s `2.1.0.RELEASE version will resolve 2.1.x branch * @param url - of project to clone - * @param versions - list of versions to check against, if none matches, will fallback to master + * @param versions - list of versions to check against, if none matches, will fallback + * to master * @return location of the cloned project */ public File cloneAndGuessBranch(String url, String... versions) { @@ -150,14 +191,13 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { if (log.isDebugEnabled()) { log.debug("Checking versions {} for project [{}]", versions, clonedProject); } - String branchToCheckout = Arrays.stream(versions) - .map(this::branchFromVersion) + String branchToCheckout = Arrays.stream(versions).map(this::branchFromVersion) .map(version -> gitRepo(clonedProject).hasBranch(version) ? version : "") - .filter(StringUtils::hasText) - .findFirst() - .orElse("master"); + .filter(StringUtils::hasText).findFirst().orElse("master"); if ("master".equals(branchToCheckout)) { - log.info("None of the versions {} matches a branch. Assuming that should work with master branch", (Object) versions); + log.info( + "None of the versions {} matches a branch. Assuming that should work with master branch", + (Object) versions); return clonedProject; } log.info("Branch [{}] exists. Will check it out", branchToCheckout); @@ -171,9 +211,10 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { File cloneProject(String url) { try { - File destinationDir = this.properties.getGit().getCloneDestinationDir() != null ? - new File(this.properties.getGit().getCloneDestinationDir()) : - Files.createTempDirectory("releaser").toFile(); + File destinationDir = this.properties.getGit() + .getCloneDestinationDir() != null + ? new File(this.properties.getGit().getCloneDestinationDir()) + : Files.createTempDirectory("releaser").toFile(); return gitRepo(destinationDir).cloneProject(new URIish(url)); } catch (Exception e) { @@ -203,7 +244,8 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { // [Camden] -> [Camden.x] return splitVersion[0]; } - throw new IllegalStateException("Wrong version [" + version + "]. Can't extract semver pieces of it"); + throw new IllegalStateException( + "Wrong version [" + version + "]. Can't extract semver pieces of it"); } @@ -244,4 +286,5 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/gradle/GradleUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/gradle/GradleUpdater.java index c4f3a373..dbc18154 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/gradle/GradleUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/gradle/GradleUpdater.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.gradle; import java.io.File; @@ -18,6 +50,7 @@ import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.ReleaserPropertiesAware; import org.springframework.cloud.release.internal.pom.ProjectVersion; @@ -37,10 +70,10 @@ public class GradleUpdater implements ReleaserPropertiesAware { } /** - * For the given root folder (typically the working directory) performs the whole - * flow of updating {@code gradle.properties} with values from BOM project. - * Remember to pass the mapping from a property name inside {@code gradle.properties} to - * the project name via {@link ReleaserProperties.Gradle#getGradlePropsSubstitution} + * For the given root folder (typically the working directory) performs the whole flow + * of updating {@code gradle.properties} with values from BOM project. Remember to + * pass the mapping from a property name inside {@code gradle.properties} to the + * project name via {@link ReleaserProperties.Gradle#getGradlePropsSubstitution} * @param projectRoot - root folder with project to update * @param projects - versions of projects used to update poms * @param versionFromBom - version for the project from Spring Cloud Release @@ -54,35 +87,42 @@ public class GradleUpdater implements ReleaserPropertiesAware { private void processAllGradleProps(File projectRoot, Projects projects, ProjectVersion versionFromScRelease, boolean assertVersions) { try { - Files.walkFileTree(projectRoot.toPath(), - new GradlePropertiesWalker(this.properties, projects, versionFromScRelease, assertVersions)); + Files.walkFileTree(projectRoot.toPath(), new GradlePropertiesWalker( + this.properties, projects, versionFromScRelease, assertVersions)); } catch (IOException e) { throw new IllegalStateException(e); } } - @Override public void setReleaserProperties(ReleaserProperties properties) { + @Override + public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; } - private class GradlePropertiesWalker extends SimpleFileVisitor { + private final class GradlePropertiesWalker extends SimpleFileVisitor { private static final String GRADLE_PROPERTIES = "gradle.properties"; private final ReleaserProperties properties; + private final Projects projects; + private final boolean skipVersionAssert; + private final boolean assertVersions; + private final List unacceptableVersionPatterns; private GradlePropertiesWalker(ReleaserProperties properties, Projects projects, ProjectVersion versionFromScRelease, boolean assertVersions) { this.properties = properties; this.projects = projects; - List unacceptableVersionPatterns = versionFromScRelease.unacceptableVersionPatterns(); + List unacceptableVersionPatterns = versionFromScRelease + .unacceptableVersionPatterns(); this.unacceptableVersionPatterns = unacceptableVersionPatterns; - this.skipVersionAssert = !assertVersions || unacceptableVersionPatterns.isEmpty(); + this.skipVersionAssert = !assertVersions + || unacceptableVersionPatterns.isEmpty(); this.assertVersions = assertVersions; } @@ -91,12 +131,16 @@ public class GradleUpdater implements ReleaserPropertiesAware { File file = path.toFile(); if (GRADLE_PROPERTIES.equals(file.getName())) { if (pathIgnored(file)) { - log.debug("Ignoring file [{}] since it's on a list of patterns to ignore", file); + log.debug( + "Ignoring file [{}] since it's on a list of patterns to ignore", + file); return FileVisitResult.CONTINUE; } - log.info("Will process the file [{}] and update its gradle properties", file); + log.info("Will process the file [{}] and update its gradle properties", + file); final String fileContents = asString(path); - final AtomicReference changedString = new AtomicReference<>(fileContents); + final AtomicReference changedString = new AtomicReference<>( + fileContents); Properties props = loadProps(file); final Map substitution = this.properties.getGradle() .getGradlePropsSubstitution(); @@ -104,12 +148,14 @@ public class GradleUpdater implements ReleaserPropertiesAware { if (substitution.containsKey(key)) { String projectName = substitution.get(key); if (!this.projects.containsProject(projectName)) { - log.warn("Should update project with name [{}] but it wasn't found in the list of projects [{}]", projectName, this.projects - .asList()); + log.warn( + "Should update project with name [{}] but it wasn't found in the list of projects [{}]", + projectName, this.projects.asList()); return; } ProjectVersion value = this.projects.forName(projectName); - log.info("Replacing [{}->{}] with [{}->{}]", key, value1, key, value); + log.info("Replacing [{}->{}] with [{}->{}]", key, value1, key, + value); changedString.set(changedString.get().replace(key + "=" + value1, key + "=" + value)); } @@ -122,9 +168,10 @@ public class GradleUpdater implements ReleaserPropertiesAware { private void assertNoSnapshotsArePresent(Path path) { if (this.assertVersions && !this.skipVersionAssert) { - log.debug("Update should check if no wrong versions remained in the gradle prop. List of wrong patterns: {}", - this.unacceptableVersionPatterns.stream().map(Pattern::pattern).collect(Collectors - .toList())); + log.debug( + "Update should check if no wrong versions remained in the gradle prop. List of wrong patterns: {}", + this.unacceptableVersionPatterns.stream().map(Pattern::pattern) + .collect(Collectors.toList())); Scanner scanner = new Scanner(asString(path)); int lineNumber = 0; while (scanner.hasNextLine()) { @@ -134,7 +181,10 @@ public class GradleUpdater implements ReleaserPropertiesAware { .filter(pattern -> pattern.matcher(line).matches()) .findFirst().orElse(null); if (matchingPattern != null) { - throw new IllegalStateException("The file [" + path + "] matches the [ " + matchingPattern.pattern() + "] pattern in line number [" + lineNumber + "]\n\n" + line); + throw new IllegalStateException("The file [" + path + + "] matches the [ " + matchingPattern.pattern() + + "] pattern in line number [" + lineNumber + "]\n\n" + + line); } } log.info("No invalid versions remained in the gradle properties"); @@ -154,8 +204,8 @@ public class GradleUpdater implements ReleaserPropertiesAware { private boolean pathIgnored(File file) { String path = file.getPath(); - return this.assertVersions && - this.properties.getGradle().getIgnoredGradleRegex().stream().anyMatch(path::matches); + return this.assertVersions && this.properties.getGradle() + .getIgnoredGradleRegex().stream().anyMatch(path::matches); } private String asString(Path path) { @@ -175,5 +225,7 @@ public class GradleUpdater implements ReleaserPropertiesAware { throw new IllegalStateException(e); } } + } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java index 9a2b0f90..d5275ce9 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java @@ -1,18 +1,35 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -31,8 +48,10 @@ import org.slf4j.LoggerFactory; import org.springframework.cloud.release.internal.ReleaserProperties; +import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID; + /** - * Parses the poms for a given project and populates versions from a release train + * Parses the poms for a given project and populates versions from a release train. * * @author Marcin Grzejszczak */ @@ -41,12 +60,16 @@ class BomParser { private static final Logger log = LoggerFactory.getLogger(BomParser.class); private final File thisProjectRoot; - private final String pomWithBootStarterParent; - private final String thisTrainBom; - private final PomReader pomReader = new PomReader(); - private final Pattern versionPattern; - private final ReleaserProperties properties; + private final String pomWithBootStarterParent; + + private final String thisTrainBom; + + private final PomReader pomReader = new PomReader(); + + private final Pattern versionPattern; + + private final ReleaserProperties properties; BomParser(ReleaserProperties properties, File thisProjectRoot) { this.thisProjectRoot = thisProjectRoot; @@ -59,7 +82,8 @@ class BomParser { Versions allVersions() { Versions boot = bootVersion(); Versions cloud = versionsFromBom(); - return new Versions(boot.bootVersion, cloud.scBuildVersion, allProjects(boot, cloud)); + return new Versions(boot.bootVersion, cloud.scBuildVersion, + allProjects(boot, cloud)); } private Set allProjects(Versions boot, Versions cloud) { @@ -76,8 +100,10 @@ class BomParser { } String bootArtifactId = model.getParent().getArtifactId(); log.debug("Boot artifact id is equal to [{}]", bootArtifactId); - if (!SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID.equals(bootArtifactId)) { - throw new IllegalStateException("The pom doesn't have a [" + SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID + if (!SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID + .equals(bootArtifactId)) { + throw new IllegalStateException("The pom doesn't have a [" + + SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id"); } String bootVersion = model.getParent().getVersion(); @@ -96,27 +122,29 @@ class BomParser { return this.pomReader.readPom(pomFile); } - // the BOM contains all versions of projects and its parent MUST be Spring Cloud Dependencies Parent + // the BOM contains all versions of projects and its parent MUST be Spring Cloud + // Dependencies Parent Versions versionsFromBom() { Model model = pom(this.thisTrainBom); if (model == null) { return Versions.EMPTY_VERSION; } String buildArtifact = model.getParent().getArtifactId(); - log.debug("[{}] artifact id is equal to [{}]", SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact); - if (!SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) { - throw new IllegalStateException("The pom doesn't have a [" + SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID - + "] artifact id"); + log.debug("[{}] artifact id is equal to [{}]", + CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact); + if (!CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) { + throw new IllegalStateException("The pom doesn't have a [" + + CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID + "] artifact id"); } String buildVersion = model.getParent().getVersion(); log.debug("Spring Cloud Build version is equal to [{}]", buildVersion); - Set projects = model.getProperties().entrySet() - .stream() - .filter(propertyMatchesSCPattern()) - .map(toProject()) + Set projects = model.getProperties().entrySet().stream() + .filter(propertyMatchesSCPattern()).map(toProject()) .collect(Collectors.toSet()); String releaseTrainProjectVersion = model.getVersion(); - projects.add(new Project(this.properties.getMetaRelease().getReleaseTrainProjectName(), releaseTrainProjectVersion)); + projects.add( + new Project(this.properties.getMetaRelease().getReleaseTrainProjectName(), + releaseTrainProjectVersion)); return new Versions(buildVersion, projects); } @@ -133,5 +161,5 @@ class BomParser { return new Project(name, entry.getValue().toString()); }; } -} +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomReader.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomReader.java index e9654e8c..2f32fe37 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomReader.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomReader.java @@ -1,18 +1,35 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -31,18 +48,18 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; class PomReader { /** - * Returns a parsed POM + * Returns a parsed POM. */ Model readPom(File file) { File pom = file; if (file.isDirectory()) { - pom = new File(file,"pom.xml"); + pom = new File(file, "pom.xml"); } if (!pom.exists()) { return null; } String fileText = ""; - try(Reader reader = new FileReader(pom)) { + try (Reader reader = new FileReader(pom)) { if (file.isFile()) { fileText = new String(Files.readAllBytes(file.toPath())); } @@ -51,9 +68,12 @@ class PomReader { } catch (XmlPullParserException | IOException e) { if (file.isFile() && fileText.length() == 0) { - throw new IllegalStateException("File [" + pom.getAbsolutePath() + "] is empty", e); + throw new IllegalStateException( + "File [" + pom.getAbsolutePath() + "] is empty", e); } - throw new IllegalStateException("Failed to read file: " + pom.getAbsolutePath(), e); + throw new IllegalStateException( + "Failed to read file: " + pom.getAbsolutePath(), e); } } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomUpdater.java index f51b9540..6b2d34d6 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomUpdater.java @@ -1,18 +1,35 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.BufferedWriter; @@ -21,6 +38,7 @@ import java.io.FileWriter; import java.util.ArrayList; import java.util.List; import java.util.Properties; + import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -37,6 +55,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.stax2.XMLInputFactory2; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.util.StringUtils; import static org.springframework.util.StringUtils.hasText; @@ -50,12 +69,12 @@ class PomUpdater { private static final Logger log = LoggerFactory.getLogger(PomUpdater.class); private final PomReader pomReader = new PomReader(); + private final PomWriter pomWriter = new PomWriter(); /** - * Basing on the contents of the root pom and the versions will decide whether - * the project should be updated or not. - * + * Basing on the contents of the root pom and the versions will decide whether the + * project should be updated or not. * @param rootFolder - root folder of the project * @param versions - list of dependencies to be updated * @return {@code true} if the project is on the list of projects to be updated @@ -70,18 +89,20 @@ class PomUpdater { log.info("Failed to read the model"); return false; } - String artifactId = artifactId(model); + String artifactId = artifactId(model); if (!versions.shouldBeUpdated(artifactId)) { - log.info("Skipping project [{}] since it's not on the list of projects to update", model.getArtifactId()); + log.info( + "Skipping project [{}] since it's not on the list of projects to update", + model.getArtifactId()); return false; } - log.info("Project [{}] will have its dependencies updated", model.getArtifactId()); + log.info("Project [{}] will have its dependencies updated", + model.getArtifactId()); return true; } boolean hasSkipDeployment(Model model) { - String property = model.getProperties() - .getProperty("maven.deploy.skip"); + String property = model.getProperties().getProperty("maven.deploy.skip"); boolean hasSkipDeploymentProperty = Boolean.parseBoolean(property); if (hasSkipDeploymentProperty) { return true; @@ -89,28 +110,20 @@ class PomUpdater { if (model.getBuild() == null) { return false; } - boolean plugins = model.getBuild() - .getPlugins() - .stream() - .filter(plugin -> "maven-deploy-plugin".equalsIgnoreCase(plugin.getArtifactId())) - .map(this::skipFromConfiguration) - .findFirst() - .orElse(false); + boolean plugins = model.getBuild().getPlugins().stream() + .filter(plugin -> "maven-deploy-plugin" + .equalsIgnoreCase(plugin.getArtifactId())) + .map(this::skipFromConfiguration).findFirst().orElse(false); if (plugins) { return true; } - if (model.getBuild() - .getPluginManagement() == null) { + if (model.getBuild().getPluginManagement() == null) { return false; } - return model.getBuild() - .getPluginManagement() - .getPlugins() - .stream() - .filter(plugin -> "maven-deploy-plugin".equalsIgnoreCase(plugin.getArtifactId())) - .map(this::skipFromConfiguration) - .findFirst() - .orElse(false); + return model.getBuild().getPluginManagement().getPlugins().stream() + .filter(plugin -> "maven-deploy-plugin" + .equalsIgnoreCase(plugin.getArtifactId())) + .map(this::skipFromConfiguration).findFirst().orElse(false); } private Boolean skipFromConfiguration(Plugin plugin) { @@ -134,16 +147,16 @@ class PomUpdater { if (!parent) { return model.getArtifactId(); } - return model.getArtifactId().substring(0, model.getArtifactId().indexOf("-parent")); + return model.getArtifactId().substring(0, + model.getArtifactId().indexOf("-parent")); } ModelWrapper readModel(File pom) { return new ModelWrapper(this.pomReader.readPom(pom)); } - /**q - * Updates the root / child module model - * + /** + * Updates the root / child module model. * @param rootPom - root project model * @param pom - file with the pom * @param versions - versions to update @@ -158,9 +171,8 @@ class PomUpdater { } /** - * Overwrites the pom.xml with data from {@link ModelWrapper} only if there were - * any changes in the model. - * + * Overwrites the pom.xml with data from {@link ModelWrapper} only if there were any + * changes in the model. * @return - the pom file */ File overwritePomIfDirty(ModelWrapper updatedPomModel, Versions versions, File pom) { @@ -172,8 +184,8 @@ class PomUpdater { return pom; } - private List updateParentIfPossible(ModelWrapper wrapper, Versions versions, - Model model, List sourceChanges) { + private List updateParentIfPossible(ModelWrapper wrapper, + Versions versions, Model model, List sourceChanges) { String rootProjectName = wrapper.projectName(); List changes = new ArrayList<>(sourceChanges); if (model.getParent() == null || isEmpty(model.getParent().getVersion())) { @@ -182,39 +194,48 @@ class PomUpdater { } String parentGroupId = model.getParent().getGroupId(); String parentArtifactId = model.getParent().getArtifactId(); - log.debug("Searching for a version of parent [{}:{}]", parentGroupId, parentArtifactId); + log.debug("Searching for a version of parent [{}:{}]", parentGroupId, + parentArtifactId); String oldVersion = model.getParent().getVersion(); String version = versions.versionForProject(parentArtifactId); log.debug("Found version is [{}]", version); if (isEmpty(version)) { if (hasText(model.getParent().getRelativePath())) { version = versions.versionForProject(rootProjectName); - } else { - log.warn("There is no info on the [{}:{}] version", parentGroupId, parentArtifactId); + } + else { + log.warn("There is no info on the [{}:{}] version", parentGroupId, + parentArtifactId); return changes; } } if (oldVersion.equals(version)) { - log.debug("Won't update the version of parent [{}:{}] since you're already using the proper one", parentGroupId, parentArtifactId); + log.debug( + "Won't update the version of parent [{}:{}] since you're already using the proper one", + parentGroupId, parentArtifactId); return changes; } - log.info("Setting version of parent [{}] to [{}] for module [{}]", parentArtifactId, - version, model.getArtifactId()); + log.info("Setting version of parent [{}] to [{}] for module [{}]", + parentArtifactId, version, model.getArtifactId()); if (hasText(version)) { - changes.add(new VersionChange(parentGroupId, parentArtifactId, oldVersion, version)); + changes.add(new VersionChange(parentGroupId, parentArtifactId, oldVersion, + version)); } return changes; } - private List updateVersionIfPossible(ModelWrapper wrapper, Versions versions, - Model model, List sourceChanges) { + private List updateVersionIfPossible(ModelWrapper wrapper, + Versions versions, Model model, List sourceChanges) { String rootProjectName = wrapper.projectName(); String rootProjectGroupId = wrapper.groupId(); List changes = new ArrayList<>(sourceChanges); String groupId = groupId(model); String artifactId = model.getArtifactId(); - if (model.getGroupId() != null && !model.getGroupId().equals(rootProjectGroupId)) { - log.info("Will not update project [{}] since its group id [{}] is not equal the parent group id [{}]", model.getArtifactId(), model.getGroupId(), rootProjectGroupId); + if (model.getGroupId() != null + && !model.getGroupId().equals(rootProjectGroupId)) { + log.info( + "Will not update project [{}] since its group id [{}] is not equal the parent group id [{}]", + model.getArtifactId(), model.getGroupId(), rootProjectGroupId); return changes; } log.debug("Searching for a version [{}:{}]", groupId, artifactId); @@ -222,11 +243,15 @@ class PomUpdater { String version = versions.versionForProject(rootProjectName); log.debug("Found version is [{}]", version); if (isEmpty(version) || isEmpty(model.getVersion())) { - log.debug("There was no version set for project [{}], skipping version setting for module [{}]", rootProjectName, model.getArtifactId()); + log.debug( + "There was no version set for project [{}], skipping version setting for module [{}]", + rootProjectName, model.getArtifactId()); return changes; } if (oldVersion.equals(version)) { - log.debug("Won't update the version of module [{}]:[{}] since you're already using the proper one", groupId, artifactId); + log.debug( + "Won't update the version of module [{}]:[{}] since you're already using the proper one", + groupId, artifactId); return changes; } log.info("Setting [{}] version to [{}]", artifactId, version); @@ -243,11 +268,15 @@ class PomUpdater { } return ""; } + } class ModelWrapper { + final Model model; + final Versions versions; + final List sourceChanges = new ArrayList<>(); ModelWrapper(Model model, List sourceChanges, Versions versions) { @@ -269,13 +298,14 @@ class ModelWrapper { if (this.model.getGroupId() != null) { return this.model.getGroupId(); } - return this.model.getParent() != null ? - this.model.getParent().getGroupId() : ""; + return this.model.getParent() != null ? this.model.getParent().getGroupId() : ""; } boolean isDirty() { - return !this.sourceChanges.isEmpty() || this.versions.shouldSetProperty(this.model.getProperties()); + return !this.sourceChanges.isEmpty() + || this.versions.shouldSetProperty(this.model.getProperties()); } + } class PomWriter { @@ -291,9 +321,11 @@ class PomWriter { LoggerToMavenLog loggerToMavenLog = new LoggerToMavenLog(PomWriter.log); versionChangerFactory.setLog(loggerToMavenLog); versionChangerFactory.setModel(wrapper.model); - log.info("Applying version / parent / plugin / project changes to the pom [{}]", pom); - VersionChanger changer = versionChangerFactory.newVersionChanger( true, - true, true, true); + log.info( + "Applying version / parent / plugin / project changes to the pom [{}]", + pom); + VersionChanger changer = versionChangerFactory.newVersionChanger(true, true, + true, true); for (VersionChange versionChange : wrapper.sourceChanges) { changer.apply(versionChange); } @@ -304,14 +336,15 @@ class PomWriter { bw.write(input.toString()); } log.debug("Flushed changes to the pom file [{}]", pom); - } catch (Exception e) { + } + catch (Exception e) { log.error("Exception occurred while trying to apply changes to the POM", e); } } /** - * Creates a {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader} from a StringBuilder. - * + * Creates a {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader} + * from a StringBuilder. * @param input The XML to read and modify. * @return The {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader}. */ @@ -327,48 +360,52 @@ class PomWriter { } return newPom; } + } class PropertyVersionChanger extends AbstractVersionChanger { private final Versions versions; + private final PropertyStorer propertyStorer; - PropertyVersionChanger(ModelWrapper wrapper, Versions versions, ModifiedPomXMLEventReader pom, Log log) { + PropertyVersionChanger(ModelWrapper wrapper, Versions versions, + ModifiedPomXMLEventReader pom, Log log) { super(wrapper.model, pom, log); this.versions = versions; this.propertyStorer = new PropertyStorer(log, pom); } - PropertyVersionChanger(ModelWrapper wrapper, Versions versions, ModifiedPomXMLEventReader pom, Log log, PropertyStorer propertyStorer) { + PropertyVersionChanger(ModelWrapper wrapper, Versions versions, + ModifiedPomXMLEventReader pom, Log log, PropertyStorer propertyStorer) { super(wrapper.model, pom, log); this.versions = versions; this.propertyStorer = propertyStorer; } - @Override public void apply(final VersionChange versionChange) { - this.versions.projects - .stream() - .filter(project -> { - Properties properties = getModel().getProperties(); - String projectVersionKey = propertyName(project); - if (!properties.containsKey(projectVersionKey)) { - return false; - } - String version = properties.getProperty(projectVersionKey); - return !version.equals(project.version); - }) - .forEach(this.propertyStorer::setPropertyVersionIfApplicable); + @Override + public void apply(final VersionChange versionChange) { + this.versions.projects.stream().filter(project -> { + Properties properties = getModel().getProperties(); + String projectVersionKey = propertyName(project); + if (!properties.containsKey(projectVersionKey)) { + return false; + } + String version = properties.getProperty(projectVersionKey); + return !version.equals(project.version); + }).forEach(this.propertyStorer::setPropertyVersionIfApplicable); } private String propertyName(Project project) { return project.name + ".version"; } + } class PropertyStorer { private final Log log; + private final ModifiedPomXMLEventReader pom; PropertyStorer(Log log, ModifiedPomXMLEventReader pom) { @@ -379,7 +416,8 @@ class PropertyStorer { void setPropertyVersionIfApplicable(Project project) { String propertyName = propertyName(project); if (setPropertyVersion(propertyName, project.version)) { - this.log.info("Updating property [" + propertyName + "] to version [" + project.version + "]"); + this.log.info("Updating property [" + propertyName + "] to version [" + + project.version + "]"); } } @@ -390,7 +428,8 @@ class PropertyStorer { private boolean setPropertyVersion(String propertyName, String version) { try { if (StringUtils.isEmpty(version)) { - this.log.warn("Version for [" + propertyName + "] is empty. Will not set it"); + this.log.warn( + "Version for [" + propertyName + "] is empty. Will not set it"); return false; } return PomHelper.setPropertyVersion(this.pom, null, propertyName, version); @@ -400,6 +439,7 @@ class PropertyStorer { return false; } } + } class LoggerToMavenLog implements Log { @@ -410,67 +450,84 @@ class LoggerToMavenLog implements Log { this.logger = logger; } - @Override public boolean isDebugEnabled() { + @Override + public boolean isDebugEnabled() { return this.logger.isDebugEnabled(); } - @Override public void debug(CharSequence content) { + @Override + public void debug(CharSequence content) { this.logger.debug(content.toString()); } - @Override public void debug(CharSequence content, Throwable error) { + @Override + public void debug(CharSequence content, Throwable error) { this.logger.debug(content.toString(), error); } - @Override public void debug(Throwable error) { + @Override + public void debug(Throwable error) { this.debug("Exception occurred", error); } - @Override public boolean isInfoEnabled() { + @Override + public boolean isInfoEnabled() { return this.logger.isInfoEnabled(); } - @Override public void info(CharSequence content) { + @Override + public void info(CharSequence content) { this.logger.info(content.toString()); } - @Override public void info(CharSequence content, Throwable error) { + @Override + public void info(CharSequence content, Throwable error) { this.logger.info(content.toString(), error); } - @Override public void info(Throwable error) { + @Override + public void info(Throwable error) { this.info("Exception occurred", error); } - @Override public boolean isWarnEnabled() { + @Override + public boolean isWarnEnabled() { return this.logger.isWarnEnabled(); } - @Override public void warn(CharSequence content) { + @Override + public void warn(CharSequence content) { this.logger.warn(content.toString()); } - @Override public void warn(CharSequence content, Throwable error) { + @Override + public void warn(CharSequence content, Throwable error) { this.logger.warn(content.toString(), error); } - @Override public void warn(Throwable error) { + @Override + public void warn(Throwable error) { this.warn("Exception occurred", error); } - @Override public boolean isErrorEnabled() { + @Override + public boolean isErrorEnabled() { return this.logger.isErrorEnabled(); } - @Override public void error(CharSequence content) { + @Override + public void error(CharSequence content) { this.logger.error(content.toString()); } - @Override public void error(CharSequence content, Throwable error) { + @Override + public void error(CharSequence content, Throwable error) { this.logger.error(content.toString(), error); } - @Override public void error(Throwable error) { + @Override + public void error(Throwable error) { this.error("Exception occurred", error); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java index 842d389b..13cd2a8b 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java @@ -1,18 +1,35 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -31,6 +48,7 @@ import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.ReleaserPropertiesAware; import org.springframework.cloud.release.internal.git.ProjectGitHandler; @@ -43,15 +61,16 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { private static final List IGNORED_SNAPSHOT_LINE_PATTERNS = Arrays.asList( "^.*replace=.*$", // issue [#80] - "^[\\s]*.*$" - ); + "^[\\s]*.*$"); private static final Logger log = LoggerFactory.getLogger(ProjectPomUpdater.class); - private ReleaserProperties properties; private final ProjectGitHandler gitRepo; + private final PomUpdater pomUpdater = new PomUpdater(); + private ReleaserProperties properties; + public ProjectPomUpdater(ReleaserProperties properties) { this.properties = properties; this.gitRepo = new ProjectGitHandler(properties); @@ -63,15 +82,17 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { } /** - * For the given root folder (typically the working directory) retrieves list of versions - * for a given release version. + * For the given root folder (typically the working directory) retrieves list of + * versions for a given release version. + * @return projects retrieved from the release train bom */ public Projects retrieveVersionsFromReleaseTrainBom() { File clonedScRelease = this.gitRepo.cloneReleaseTrainProject(); this.gitRepo.checkout(clonedScRelease, this.properties.getPom().getBranch()); BomParser sCReleasePomParser = new BomParser(this.properties, clonedScRelease); Versions versions = sCReleasePomParser.allVersions(); - log.info("Will update the following versions manually [{}]", this.properties.getFixedVersions()); + log.info("Will update the following versions manually [{}]", + this.properties.getFixedVersions()); this.properties.getFixedVersions().forEach(versions::setVersion); log.info("Retrieved the following versions\n{}", versions); return versions.toProjectVersions(); @@ -82,8 +103,7 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { */ public Projects fixedVersions() { Set projectVersions = this.properties.getFixedVersions() - .entrySet() - .stream() + .entrySet().stream() .map(entry -> new ProjectVersion(entry.getKey(), entry.getValue())) .collect(Collectors.toSet()); if (log.isDebugEnabled()) { @@ -93,13 +113,13 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { } /** - * For the given root folder (typically the working directory) performs the whole - * flow of updating {@code pom.xml} with values from release train - * (e.g. Spring Cloud Release project.) + * For the given root folder (typically the working directory) performs the whole flow + * of updating {@code pom.xml} with values from release train (e.g. Spring Cloud + * Release project.) * @param projectRoot - root folder with project to update * @param projects - versions of projects used to update poms - * @param versionFromReleaseTrain - version for the built project taken - * from release train (e.g. Spring Cloud Release project) + * @param versionFromReleaseTrain - version for the built project taken from release + * train (e.g. Spring Cloud Release project) * @param assertVersions - should version assertion take place */ public void updateProjectFromReleaseTrain(File projectRoot, Projects projects, @@ -133,20 +153,27 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { } } - @Override public void setReleaserProperties(ReleaserProperties properties) { + @Override + public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; } - private class PomWalker extends SimpleFileVisitor { + private final class PomWalker extends SimpleFileVisitor { private static final String POM_XML = "pom.xml"; private final ModelWrapper rootPom; + private final Versions versions; + private final PomUpdater pomUpdater; + private final ReleaserProperties properties; + private final boolean skipVersionAssert; + private final boolean assertVersions; + private final List unacceptableVersionPatterns; private PomWalker(ModelWrapper rootPom, Projects projects, PomUpdater pomUpdater, @@ -156,9 +183,11 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { this.versions = new Versions(projects, properties); this.pomUpdater = pomUpdater; this.properties = properties; - List unacceptableVersionPatterns = versionFromScRelease.unacceptableVersionPatterns(); + List unacceptableVersionPatterns = versionFromScRelease + .unacceptableVersionPatterns(); this.unacceptableVersionPatterns = unacceptableVersionPatterns; - this.skipVersionAssert = !assertVersions || unacceptableVersionPatterns.isEmpty(); + this.skipVersionAssert = !assertVersions + || unacceptableVersionPatterns.isEmpty(); this.assertVersions = assertVersions; } @@ -167,25 +196,34 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { File file = path.toFile(); if (POM_XML.equals(file.getName())) { if (pathIgnored(file)) { - log.debug("Ignoring file [{}] since it's on a list of patterns to ignore", file); + log.debug( + "Ignoring file [{}] since it's on a list of patterns to ignore", + file); return FileVisitResult.CONTINUE; } - ModelWrapper model = this.pomUpdater.updateModel(this.rootPom, file, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(this.rootPom, file, + this.versions); this.pomUpdater.overwritePomIfDirty(model, this.versions, file); - if (this.assertVersions && !this.skipVersionAssert && !this.pomUpdater.hasSkipDeployment(model.model)) { - log.debug("Update is a non-snapshot one. Checking if no snapshot versions remained in the pom"); + if (this.assertVersions && !this.skipVersionAssert + && !this.pomUpdater.hasSkipDeployment(model.model)) { + log.debug( + "Update is a non-snapshot one. Checking if no snapshot versions remained in the pom"); Scanner scanner = new Scanner(asString(path)); int lineNumber = 0; while (scanner.hasNextLine()) { String line = scanner.nextLine(); lineNumber++; - Pattern matchingPattern = this.unacceptableVersionPatterns.stream() - .filter(pattern -> - IGNORED_SNAPSHOT_LINE_PATTERNS.stream().noneMatch(line::matches) && - pattern.matcher(line).matches()) + Pattern matchingPattern = this.unacceptableVersionPatterns + .stream() + .filter(pattern -> IGNORED_SNAPSHOT_LINE_PATTERNS.stream() + .noneMatch(line::matches) + && pattern.matcher(line).matches()) .findFirst().orElse(null); if (matchingPattern != null) { - throw new IllegalStateException("The file [" + path + "] matches the [ " + matchingPattern.pattern() + "] pattern in line number [" + lineNumber + "]\n\n" + line); + throw new IllegalStateException("The file [" + path + + "] matches the [ " + matchingPattern.pattern() + + "] pattern in line number [" + lineNumber + "]\n\n" + + line); } } log.info("No invalid versions remained in the pom"); @@ -196,8 +234,8 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { private boolean pathIgnored(File file) { String path = file.getPath(); - return this.assertVersions && - this.properties.getPom().getIgnoredPomRegex().stream().anyMatch(path::matches); + return this.assertVersions && this.properties.getPom().getIgnoredPomRegex() + .stream().anyMatch(path::matches); } private String asString(Path path) { @@ -208,7 +246,7 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { throw new IllegalStateException(e); } } + } + } - - diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectVersion.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectVersion.java index 6a2f9177..b555d48f 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectVersion.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectVersion.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -12,18 +44,30 @@ import org.apache.maven.model.Model; import org.springframework.util.StringUtils; /** - * Object representing a root project's version. - * Knows how to provide a minor bumped version; + * Object representing a root project's version. Knows how to provide a minor bumped + * version; * * @author Marcin Grzejszczak */ public class ProjectVersion { - private static final Pattern SNAPSHOT_PATTERN = Pattern.compile("^.*\\.(BUILD-)?SNAPSHOT.*$"); + private static final Pattern SNAPSHOT_PATTERN = Pattern + .compile("^.*\\.(BUILD-)?SNAPSHOT.*$"); + private static final String MILESTONE_REGEX = ".*\\.M[0-9]+"; + private static final String RC_REGEX = "^.*\\.RC.*$"; + + /** + * Name of the project. + */ public final String projectName; + + /** + * Version of the project. + */ public final String version; + private final Model model; public ProjectVersion(String projectName, String version) { @@ -38,7 +82,8 @@ public class ProjectVersion { this.projectName = projectVersion.projectName; this.version = projectVersion.version; this.model = null; - } else { + } + else { PomReader pomReader = new PomReader(); Model model = pomReader.readPom(project); this.projectName = nameWithoutParent(model.getArtifactId()); @@ -71,27 +116,28 @@ public class ProjectVersion { return this.version; } Integer incrementedPatch = Integer.valueOf(splitVersion[2]) + 1; - return String.format("%s.%s.%s.%s", splitVersion[0], splitVersion[1], incrementedPatch, splitVersion[3]); + return String.format("%s.%s.%s.%s", splitVersion[0], splitVersion[1], + incrementedPatch, splitVersion[3]); } - private String[] assertVersion() { if (this.version == null) { throw new IllegalStateException("Version can't be null!"); } // 1.0.0.BUILD-SNAPSHOT String[] splitVersion = this.version.split("\\."); - if (splitVersion.length < 4 && isNumeric(splitVersion[0]) || - splitVersion.length == 1 && !isNumeric(splitVersion[0])) { - throw new IllegalStateException("Version is invalid. Should be of format [1.2.3.A]"); + if (splitVersion.length < 4 && isNumeric(splitVersion[0]) + || splitVersion.length == 1 && !isNumeric(splitVersion[0])) { + throw new IllegalStateException( + "Version is invalid. Should be of format [1.2.3.A]"); } return splitVersion; } /** - * For GA and SR will bump the snapshots - * in the rest of cases will return snapshot of the current version - * @return + * For GA and SR will bump the snapshots in the rest of cases will return snapshot of + * the current version. + * @return the post release snapshot version */ public String postReleaseSnapshotVersion() { String[] strings = assertVersion(); @@ -118,7 +164,8 @@ public class ProjectVersion { if (StringUtils.hasText(this.model.getGroupId())) { return this.model.getGroupId(); } - if (this.model.getParent() != null && StringUtils.hasText(this.model.getParent().getGroupId())) { + if (this.model.getParent() != null + && StringUtils.hasText(this.model.getParent().getGroupId())) { return this.model.getParent().getGroupId(); } return ""; @@ -128,7 +175,8 @@ public class ProjectVersion { try { assertVersion(); return true; - } catch (IllegalStateException e) { + } + catch (IllegalStateException e) { return false; } } @@ -167,8 +215,8 @@ public class ProjectVersion { } String[] splitThis = this.version.split("\\."); String[] splitThat = version.split("\\."); - return splitThis.length == splitThat.length && - splitThis[0].equals(splitThat[0]) && splitThis[1].equals(splitThat[1]); + return splitThis.length == splitThat.length && splitThis[0].equals(splitThat[0]) + && splitThis[1].equals(splitThat[1]); } public boolean isSameReleaseTrainName(String version) { @@ -199,35 +247,44 @@ public class ProjectVersion { return new VersionNumber(thisValue).compareTo(new VersionNumber(thatValue)); } - @Override public String toString() { + @Override + public String toString() { return this.version; } - @Override public boolean equals(Object o) { - if (this == o) + @Override + public boolean equals(Object o) { + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; + } ProjectVersion that = (ProjectVersion) o; return Objects.equals(this.projectName, that.projectName); } - @Override public int hashCode() { + @Override + public int hashCode() { return Objects.hash(this.projectName); } public List unacceptableVersionPatterns() { if (isSnapshot()) { return Collections.emptyList(); - } else if (isMilestone() || isRc()) { + } + else if (isMilestone() || isRc()) { return Collections.singletonList(SNAPSHOT_PATTERN); } // treat like GA - return Arrays.asList(SNAPSHOT_PATTERN, Pattern.compile(MILESTONE_REGEX), Pattern.compile(RC_REGEX)); + return Arrays.asList(SNAPSHOT_PATTERN, Pattern.compile(MILESTONE_REGEX), + Pattern.compile(RC_REGEX)); } + } class VersionNumber implements Comparable { + private final String version; VersionNumber(String version) { @@ -256,4 +313,5 @@ class VersionNumber implements Comparable { Integer thatNumber = Integer.valueOf(thatVersion); return thisNumber.compareTo(thatNumber); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Projects.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Projects.java index 58f5b6fa..d76482be 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Projects.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Projects.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -11,7 +43,7 @@ import java.util.stream.Collectors; import org.springframework.cloud.release.internal.ReleaserProperties; /** - * Abstraction over collection of projects + * Abstraction over collection of projects. * * @author Marcin Grzejszczak */ @@ -23,21 +55,38 @@ public class Projects extends HashSet { @SuppressWarnings("unchecked") public Projects(ProjectVersion... versions) { - addAll(new HashSet<>(Arrays.stream(versions).filter(Objects::nonNull).collect(Collectors.toList()))); + addAll(new HashSet<>(Arrays.stream(versions).filter(Objects::nonNull) + .collect(Collectors.toList()))); } - public static Projects forRollback(Projects projects, ProjectVersion originalVersion) { + public static Projects forRollback(Projects projects, + ProjectVersion originalVersion) { Projects newProjects = new Projects(); - newProjects.add(new ProjectVersion(originalVersion.projectName, originalVersion.bumpedVersion())); - newProjects.addAll(projects.forNameStartingWith(SpringCloudConstants.SPRING_BOOT)); + newProjects.add(new ProjectVersion(originalVersion.projectName, + originalVersion.bumpedVersion())); + newProjects + .addAll(projects.forNameStartingWith(SpringCloudConstants.SPRING_BOOT)); return newProjects; } + private static IllegalStateException exception(Projects projects, + String projectName) { + return new IllegalStateException("Project with name [" + projectName + + "] is not present in the list of projects [" + projects.asList() + + "] . " + additionalErrorMessage(projectName)); + } + + private static String additionalErrorMessage(String projectName) { + return "Either put it in the Spring Cloud Release project or set it via the [--releaser.fixed-versions[" + + projectName + "]=1.0.0.RELEASE] property"; + } + public ProjectVersion releaseTrain(ReleaserProperties properties) { return this.forName(properties.getMetaRelease().getReleaseTrainProjectName()); } - @Override public boolean add(ProjectVersion projectVersion) { + @Override + public boolean add(ProjectVersion projectVersion) { if (projectVersion == null) { return false; } @@ -45,17 +94,15 @@ public class Projects extends HashSet { } public Projects filter(List projectsToSkip) { - return this.stream() - .filter(v -> !projectsToSkip.contains(v.projectName)) + return this.stream().filter(v -> !projectsToSkip.contains(v.projectName)) .collect(Collectors.toCollection(Projects::new)); } public Projects postReleaseSnapshotVersion(List projectsToSkip) { - Projects projects = this.stream() - .filter(v -> projectsToSkip(projectsToSkip, v)) + Projects projects = this.stream().filter(v -> projectsToSkip(projectsToSkip, v)) .collect(Collectors.toCollection(Projects::new)); - Projects bumped = this.stream() - .map(v -> new ProjectVersion(v.projectName, v.postReleaseSnapshotVersion())) + Projects bumped = this.stream().map( + v -> new ProjectVersion(v.projectName, v.postReleaseSnapshotVersion())) .collect(Collectors.toCollection(Projects::new)); Projects merged = new Projects(projects); merged.addAll(bumped); @@ -73,35 +120,26 @@ public class Projects extends HashSet { public ProjectVersion forFile(File projectRoot) { final ProjectVersion thisProject = new ProjectVersion(projectRoot); - return this.stream().filter(projectVersion -> projectVersion.projectName.equals(thisProject.projectName)) - .findFirst() - .orElseThrow(() -> exception(this, thisProject.projectName)); - } - - private static IllegalStateException exception(Projects projects, String projectName) { - return new IllegalStateException( - "Project with name [" + projectName + "] is not present in the list of projects [" + projects.asList() + "] . " - + additionalErrorMessage(projectName)); - } - - private static String additionalErrorMessage(String projectName) { - return "Either put it in the Spring Cloud Release project or set it via the [--releaser.fixed-versions[" - + projectName + "]=1.0.0.RELEASE] property"; + return this.stream() + .filter(projectVersion -> projectVersion.projectName + .equals(thisProject.projectName)) + .findFirst().orElseThrow(() -> exception(this, thisProject.projectName)); } public ProjectVersion forName(String projectName) { - return this.stream().filter(projectVersion -> projectVersion.projectName.equals(projectName)) - .findFirst() - .orElseThrow(() -> exception(this, projectName)); + return this.stream() + .filter(projectVersion -> projectVersion.projectName.equals(projectName)) + .findFirst().orElseThrow(() -> exception(this, projectName)); } public boolean containsProject(String projectName) { - return this.stream() - .anyMatch(projectVersion -> projectVersion.projectName.equals(projectName)); + return this.stream().anyMatch( + projectVersion -> projectVersion.projectName.equals(projectName)); } public List forNameStartingWith(String projectName) { - return this.stream().filter(projectVersion -> projectVersion.projectName.startsWith(projectName)) + return this.stream().filter( + projectVersion -> projectVersion.projectName.startsWith(projectName)) .collect(Collectors.toList()); } @@ -110,6 +148,8 @@ public class Projects extends HashSet { } public String asList() { - return this.stream().map(version -> version.projectName + ":" + version.version).collect(Collectors.joining(",")); + return this.stream().map(version -> version.projectName + ":" + version.version) + .collect(Collectors.joining(",")); } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java index 0fc8e70e..54e367d1 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java @@ -1,17 +1,33 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.springframework.cloud.release.internal.pom; @@ -20,9 +36,11 @@ package org.springframework.cloud.release.internal.pom; * @author Marcin Grzejszczak */ final class SpringCloudConstants { + static final String SPRING_BOOT = "spring-boot"; static final String BOOT_STARTER_ARTIFACT_ID = "spring-boot-starter"; - static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID + "-parent"; + static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID + + "-parent"; static final String BOOT_DEPENDENCIES_ARTIFACT_ID = "spring-boot-dependencies"; static final String CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID = "spring-cloud-dependencies-parent"; static final String BUILD_ARTIFACT_ID = "spring-cloud-build"; diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java index 51ded225..5798e587 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java @@ -1,18 +1,35 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -31,18 +48,22 @@ import static org.springframework.cloud.release.internal.pom.SpringCloudConstant import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID; /** - * Represents versions taken out from Spring Cloud Release pom + * Represents versions taken out from Spring Cloud Release pom. * * @author Marcin Grzejszczak */ class Versions { - private static final String SPRING_BOOT_PROJECT_NAME = "spring-boot"; static final Versions EMPTY_VERSION = new Versions(""); + private static final String SPRING_BOOT_PROJECT_NAME = "spring-boot"; + String bootVersion; + String scBuildVersion; + Set projects = new HashSet<>(); + ReleaserProperties properties; Versions(String bootVersion) { @@ -65,7 +86,8 @@ class Versions { this(new ReleaserProperties(), bootVersion, scBuildVersion, projects); } - Versions(ReleaserProperties properties, String bootVersion, String scBuildVersion, Set projects) { + Versions(ReleaserProperties properties, String bootVersion, String scBuildVersion, + Set projects) { this.properties = properties; this.bootVersion = bootVersion; this.scBuildVersion = scBuildVersion; @@ -79,11 +101,16 @@ class Versions { Versions(Set versions, ReleaserProperties properties) { this.properties = properties; - this.bootVersion = versions.stream().filter(projectVersion -> SPRING_BOOT_PROJECT_NAME.equals(projectVersion.projectName)) - .findFirst().orElse(new ProjectVersion(SPRING_BOOT_PROJECT_NAME, "")).version; - this.scBuildVersion = versions.stream().filter(projectVersion -> BUILD_ARTIFACT_ID.equals(projectVersion.projectName)) + this.bootVersion = versions.stream() + .filter(projectVersion -> SPRING_BOOT_PROJECT_NAME + .equals(projectVersion.projectName)) + .findFirst() + .orElse(new ProjectVersion(SPRING_BOOT_PROJECT_NAME, "")).version; + this.scBuildVersion = versions.stream().filter( + projectVersion -> BUILD_ARTIFACT_ID.equals(projectVersion.projectName)) .findFirst().orElse(new ProjectVersion(BUILD_ARTIFACT_ID, "")).version; - versions.forEach(projectVersion -> setVersion(projectVersion.projectName, projectVersion.version)); + versions.forEach(projectVersion -> setVersion(projectVersion.projectName, + projectVersion.version)); } private String bomProjectName() { @@ -100,11 +127,8 @@ class Versions { } String versionForProject(String projectName) { - return this.projects.stream() - .filter(project -> nameMatches(projectName, project)) - .findFirst() - .orElse(Project.EMPTY_PROJECT) - .version; + return this.projects.stream().filter(project -> nameMatches(projectName, project)) + .findFirst().orElse(Project.EMPTY_PROJECT).version; } boolean shouldBeUpdated(String projectName) { @@ -133,20 +157,23 @@ class Versions { } boolean parent = matchesNameWithSuffix(projectName, "-parent", project); boolean bomArtifactId = comparisonOfBomArtifactAndParent(projectName, project); - return !bomArtifactId && - (parent || matchesNameWithSuffix(projectName, "-dependencies", project)); + return !bomArtifactId && (parent + || matchesNameWithSuffix(projectName, "-dependencies", project)); } - private boolean comparisonOfBomArtifactAndParent(String projectName, Project project) { - return artifactOrParent(projectName, project.name) || artifactOrParent(project.name, projectName); + private boolean comparisonOfBomArtifactAndParent(String projectName, + Project project) { + return artifactOrParent(projectName, project.name) + || artifactOrParent(project.name, projectName); } private boolean artifactOrParent(String projectName, String otherProjectName) { - return projectName.equals(dependenciesArtifactId()) && - otherProjectName.equals(dependenciesParentArtifactId()); + return projectName.equals(dependenciesArtifactId()) + && otherProjectName.equals(dependenciesParentArtifactId()); } - private boolean matchesNameWithSuffix(String projectName, String suffix, Project project) { + private boolean matchesNameWithSuffix(String projectName, String suffix, + Project project) { boolean containsSuffix = projectName.endsWith(suffix); if (!containsSuffix) { return false; @@ -157,29 +184,30 @@ class Versions { Versions setVersion(String projectName, String version) { switch (projectName) { - case SPRING_BOOT_PROJECT_NAME: - case BOOT_STARTER_PARENT_ARTIFACT_ID: - case BOOT_DEPENDENCIES_ARTIFACT_ID: - updateBootVersions(version); - break; - case BUILD_ARTIFACT_ID: - case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID: - updateBuildVersions(version); - break; - default: - if (bomVersionProjectNames().contains(projectName)) { - updateBomVersions(version); - } else { - remove(projectName); - add(projectName, version); - } + case SPRING_BOOT_PROJECT_NAME: + case BOOT_STARTER_PARENT_ARTIFACT_ID: + case BOOT_DEPENDENCIES_ARTIFACT_ID: + updateBootVersions(version); + break; + case BUILD_ARTIFACT_ID: + case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID: + updateBuildVersions(version); + break; + default: + if (bomVersionProjectNames().contains(projectName)) { + updateBomVersions(version); + } + else { + remove(projectName); + add(projectName, version); + } } return this; } private List bomVersionProjectNames() { - List names = new ArrayList<>(this.properties.getMetaRelease() - .getReleaseTrainDependencyNames()); + List names = new ArrayList<>( + this.properties.getMetaRelease().getReleaseTrainDependencyNames()); names.add(this.properties.getMetaRelease().getReleaseTrainProjectName()); return names; } @@ -217,11 +245,14 @@ class Versions { this.projects.removeIf(project -> expectedProjectName.equals(project.name)); } - @Override public String toString() { - return "Spring Boot Version=[" + this.bootVersion + ']' + "\nSpring Cloud Build Version=[" - + this.scBuildVersion + ']' + "\nProjects=\n\t" + this.projects.stream().map(Object::toString).collect( - Collectors.joining("\n\t")); + @Override + public String toString() { + return "Spring Boot Version=[" + this.bootVersion + ']' + + "\nSpring Cloud Build Version=[" + this.scBuildVersion + ']' + + "\nProjects=\n\t" + this.projects.stream().map(Object::toString) + .collect(Collectors.joining("\n\t")); } + } /** @@ -232,6 +263,7 @@ class Project { static Project EMPTY_PROJECT = new Project("", ""); final String name; + final String version; Project(String name, String version) { @@ -239,26 +271,32 @@ class Project { this.version = version; } - @Override public boolean equals(Object o) { - if (this == o) + @Override + public boolean equals(Object o) { + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; + } Project project = (Project) o; - if (this.name != null ? !this.name.equals(project.name) : project.name != null) + if (this.name != null ? !this.name.equals(project.name) : project.name != null) { return false; - return this.version != null ? - this.version.equals(project.version) : - project.version == null; + } + return this.version != null ? this.version.equals(project.version) + : project.version == null; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = this.name != null ? this.name.hashCode() : 0; result = 31 * result + (this.version != null ? this.version.hashCode() : 0); return result; } - @Override public String toString() { + @Override + public String toString() { return "name=[" + this.name + "], version=[" + this.version + ']'; } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/post/PostReleaseActions.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/post/PostReleaseActions.java index bd444dcb..3217e82d 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/post/PostReleaseActions.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/post/PostReleaseActions.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.post; import java.io.Closeable; @@ -35,14 +67,18 @@ public class PostReleaseActions implements Closeable { private static final ExecutorService SERVICE = Executors.newCachedThreadPool(); private final ProjectGitHandler projectGitHandler; + private final ProjectPomUpdater projectPomUpdater; + private final GradleUpdater gradleUpdater; + private final ProjectBuilder projectBuilder; + private final ReleaserProperties properties; public PostReleaseActions(ProjectGitHandler projectGitHandler, - ProjectPomUpdater projectPomUpdater, GradleUpdater gradleUpdater, ProjectBuilder projectBuilder, - ReleaserProperties properties) { + ProjectPomUpdater projectPomUpdater, GradleUpdater gradleUpdater, + ProjectBuilder projectBuilder, ReleaserProperties properties) { this.projectGitHandler = projectGitHandler; this.projectPomUpdater = projectPomUpdater; this.gradleUpdater = gradleUpdater; @@ -51,123 +87,128 @@ public class PostReleaseActions implements Closeable { } /** - * Clones the test project, updates it and runs tests - * + * Clones the test project, updates it and runs tests. * @param projects - set of project with versions to assert against */ public void runUpdatedTests(Projects projects) { - if (!this.properties.getGit().isRunUpdatedSamples() || - !this.properties.getMetaRelease().isEnabled()) { + if (!this.properties.getGit().isRunUpdatedSamples() + || !this.properties.getMetaRelease().isEnabled()) { log.info("Will not update and run test samples, since the switch to do so " + "is off. Set [releaser.git.run-updated-samples] to [true] to change that"); return; } File file = this.projectGitHandler.cloneTestSamplesProject(); ProjectVersion projectVersion = newProjectVersion(file); - String releaseTrainVersion = projects.releaseTrain(this.properties).version; - Projects newProjects = addVersionForTestsProject(projects, projectVersion, releaseTrainVersion); + String releaseTrainVersion = projects.releaseTrain(this.properties).version; + Projects newProjects = addVersionForTestsProject(projects, projectVersion, + releaseTrainVersion); updateWithVersions(file, newProjects); this.projectBuilder.build(projectVersion, file.getAbsolutePath()); } /** * Clones all samples for the given project. For each of them, checks out the proper - * branch, updates all the poms with the new, bumped versions of release train projects, - * commits the changes and pushes them. - * + * branch, updates all the poms with the new, bumped versions of release train + * projects, commits the changes and pushes them. * @param projects - set of project with versions to assert against */ public void updateAllTestSamples(Projects projects) { - if (!this.properties.getGit().isUpdateAllTestSamples() || - !this.properties.getMetaRelease().isEnabled()) { + if (!this.properties.getGit().isUpdateAllTestSamples() + || !this.properties.getMetaRelease().isEnabled()) { log.info("Will not update all test samples, since the switch to do so " + "is off. Set [releaser.git.update-all-test-samples] to [true] to change that"); return; } List projectUrlAndExceptions = this.properties.getGit() - .getAllTestSampleUrls() - .entrySet() - .stream() - .map(e -> updateAllProjects(projects, e)) - .map(this::getResult) - .flatMap(Collection::stream) - .collect(Collectors.toList()); + .getAllTestSampleUrls().entrySet().stream() + .map(e -> updateAllProjects(projects, e)).map(this::getResult) + .flatMap(Collection::stream).collect(Collectors.toList()); log.info("Updated all samples!"); String exceptionMessages = projectUrlAndExceptions.stream() .filter(ProjectUrlAndException::hasException) .map(e -> "Project [" + e.key + "] for url [" + e.url + "] " - + "has exception [\n\n" + Arrays - .stream(NestedExceptionUtils.getMostSpecificCause(e.ex) - .getStackTrace()) - .map(StackTraceElement::toString) - .collect(Collectors.joining("\n")) + "]") + + "has exception [\n\n" + + Arrays.stream(NestedExceptionUtils.getMostSpecificCause(e.ex) + .getStackTrace()).map(StackTraceElement::toString) + .collect(Collectors.joining("\n")) + + "]") .collect(Collectors.joining("\n")); if (StringUtils.hasText(exceptionMessages)) { - throw new IllegalStateException("Exceptions were found while updating samples\n" + exceptionMessages); - } else { + throw new IllegalStateException( + "Exceptions were found while updating samples\n" + exceptionMessages); + } + else { log.info("No exceptions were found while updating the samples"); } } - private Future> updateAllProjects(Projects projects, Map.Entry> e) { + private Future> updateAllProjects(Projects projects, + Map.Entry> e) { return SERVICE.submit(() -> { String key = e.getKey(); List value = e.getValue(); - log.info("Running version update for project [{}] and samples {}", key, value); + log.info("Running version update for project [{}] and samples {}", key, + value); ProjectVersion projectVersionForReleaseTrain = projects.forName(key); Projects postRelease = getPostReleaseProjects(projects); log.info("Versions to update the samples with \n" + postRelease.stream() .map(v -> "[" + v.projectName + " => " + v.version + "]") .collect(Collectors.joining("\n"))); return value.stream() - .map(url -> run(key, url, () -> - commitUpdatedProject(projects, key, projectVersionForReleaseTrain, postRelease, url))) - .map(this::getResult) - .collect(Collectors.toList()); + .map(url -> run(key, url, + () -> commitUpdatedProject(projects, key, + projectVersionForReleaseTrain, postRelease, url))) + .map(this::getResult).collect(Collectors.toList()); }); } Projects getPostReleaseProjects(Projects projects) { - return projects - .postReleaseSnapshotVersion(this.properties.getMetaRelease().getProjectsToSkip()); + return projects.postReleaseSnapshotVersion( + this.properties.getMetaRelease().getProjectsToSkip()); } - private void commitUpdatedProject(Projects projects, String key, ProjectVersion projectVersionForReleaseTrain, Projects postRelease, String url) { - String releaseTrainVersion = projects - .forName(this.properties.getMetaRelease().getReleaseTrainProjectName()).version; + private void commitUpdatedProject(Projects projects, String key, + ProjectVersion projectVersionForReleaseTrain, Projects postRelease, + String url) { + String releaseTrainVersion = projects.forName( + this.properties.getMetaRelease().getReleaseTrainProjectName()).version; String projectVersion = projects.forName(key).version; - log.info("Running version update for project [{}], url [{}], " - + "release train version [{}] and project version [{}]", key, url, - releaseTrainVersion, projectVersion); - File file = this.projectGitHandler - .cloneAndGuessBranch(url, releaseTrainVersion, projectVersion); + log.info( + "Running version update for project [{}], url [{}], " + + "release train version [{}] and project version [{}]", + key, url, releaseTrainVersion, projectVersion); + File file = this.projectGitHandler.cloneAndGuessBranch(url, releaseTrainVersion, + projectVersion); Projects newPostRelease = new Projects(postRelease); ProjectVersion newProjectVersion = newProjectVersion(file); newPostRelease.add(newProjectVersion); updateWithVersions(file, newPostRelease); - this.projectGitHandler - .commit(file, "Updated versions after [" + releaseTrainVersion + "] " - + "release train and [" + projectVersionForReleaseTrain.version + "] [" - + key + "] project release"); + this.projectGitHandler.commit(file, + "Updated versions after [" + releaseTrainVersion + "] " + + "release train and [" + projectVersionForReleaseTrain.version + + "] [" + key + "] project release"); this.projectGitHandler.pushCurrentBranch(file); } private ProjectVersion newProjectVersion(File file) { try { return new ProjectVersion(file); - } catch (Exception ex) { + } + catch (Exception ex) { ProjectVersion projectVersion = ProjectVersion.notMavenProject(file); String name = projectVersion.projectName; String version = projectVersion.version; - log.warn("Exception occurred while trying to read the pom file. Will assume that the project name is [" + name + "] and version [" + version + "]", ex); + log.warn( + "Exception occurred while trying to read the pom file. Will assume that the project name is [" + + name + "] and version [" + version + "]", + ex); return projectVersion; } } private void updateWithVersions(File file, Projects newPostRelease) { - this.projectPomUpdater - .updateProjectFromReleaseTrain(file, newPostRelease, - newProjectVersion(file), false); + this.projectPomUpdater.updateProjectFromReleaseTrain(file, newPostRelease, + newProjectVersion(file), false); this.gradleUpdater.updateProjectFromBom(file, newPostRelease, newProjectVersion(file), false); } @@ -188,7 +229,8 @@ public class PostReleaseActions implements Closeable { return new ProjectUrlAndException(projectAndFuture.key, projectAndFuture.url, e); } - private List getResult(Future> future) { + private List getResult( + Future> future) { try { return future.get(10, TimeUnit.MINUTES); } @@ -198,29 +240,32 @@ public class PostReleaseActions implements Closeable { } /** - * Clones the release train documentation project - * + * Clones the release train documentation project. * @param projects - set of project with versions to assert against */ public void generateReleaseTrainDocumentation(Projects projects) { - if (!this.properties.getGit().isUpdateReleaseTrainDocs() || - !this.properties.getMetaRelease().isEnabled()) { - log.info("Will not update the release train documentation, since the switch to do so " - + "is off. Set [releaser.git.update-release-train-docs] to [true] to change that"); + if (!this.properties.getGit().isUpdateReleaseTrainDocs() + || !this.properties.getMetaRelease().isEnabled()) { + log.info( + "Will not update the release train documentation, since the switch to do so " + + "is off. Set [releaser.git.update-release-train-docs] to [true] to change that"); return; } File file = this.projectGitHandler.cloneReleaseTrainDocumentationProject(); ProjectVersion projectVersion = newProjectVersion(file); - String releaseTrainVersion = projects.releaseTrain(this.properties).version; - Projects newProjects = addVersionForTestsProject(projects, projectVersion, releaseTrainVersion); + String releaseTrainVersion = projects.releaseTrain(this.properties).version; + Projects newProjects = addVersionForTestsProject(projects, projectVersion, + releaseTrainVersion); updateWithVersions(file, newProjects); - this.projectBuilder.generateReleaseTrainDocs(releaseTrainVersion, file.getAbsolutePath()); + this.projectBuilder.generateReleaseTrainDocs(releaseTrainVersion, + file.getAbsolutePath()); } - private Projects addVersionForTestsProject(Projects projects, ProjectVersion projectVersion, - String releaseTrainVersion) { + private Projects addVersionForTestsProject(Projects projects, + ProjectVersion projectVersion, String releaseTrainVersion) { Projects newProjects = new Projects(projects); - newProjects.add(new ProjectVersion(projectVersion.projectName, releaseTrainVersion)); + newProjects + .add(new ProjectVersion(projectVersion.projectName, releaseTrainVersion)); return newProjects; } @@ -228,12 +273,15 @@ public class PostReleaseActions implements Closeable { public void close() { SERVICE.shutdown(); } + } - class ProjectAndFuture { + final String key; + final String url; + final Future future; ProjectAndFuture(String key, String url, Future future) { @@ -241,11 +289,15 @@ class ProjectAndFuture { this.url = url; this.future = future; } + } class ProjectUrlAndException { + final String key; + final String url; + final Exception ex; ProjectUrlAndException(String key, String url, Exception ex) { @@ -257,4 +309,5 @@ class ProjectUrlAndException { boolean hasException() { return this.ex != null; } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/project/ProjectBuilder.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/project/ProjectBuilder.java index 1867f577..35b75669 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/project/ProjectBuilder.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/project/ProjectBuilder.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.project; import java.io.File; @@ -17,8 +49,9 @@ import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.cloud.release.internal.ReleaserPropertiesAware; + import org.springframework.cloud.release.internal.ReleaserProperties; +import org.springframework.cloud.release.internal.ReleaserPropertiesAware; import org.springframework.cloud.release.internal.pom.ProjectVersion; import org.springframework.util.StringUtils; @@ -28,6 +61,7 @@ import org.springframework.util.StringUtils; public class ProjectBuilder implements ReleaserPropertiesAware { private static final Logger log = LoggerFactory.getLogger(ProjectBuilder.class); + private static final String VERSION_MUSTACHE = "{{version}}"; private ReleaserProperties properties; @@ -42,34 +76,38 @@ public class ProjectBuilder implements ReleaserPropertiesAware { public void build(ProjectVersion versionFromReleaseTrain, String projectRoot) { try { - String[] commands = commandWithSystemProps(this.properties.getMaven().getBuildCommand(), - versionFromReleaseTrain).split(" "); + String[] commands = commandWithSystemProps( + this.properties.getMaven().getBuildCommand(), versionFromReleaseTrain) + .split(" "); runCommand(projectRoot, commands); assertNoHtmlFilesInDocsContainUnresolvedTags(projectRoot); log.info("No HTML files from docs contain unresolved tags"); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } public void generateReleaseTrainDocs(String version, String projectRoot) { try { - String updatedCommand = - this.properties.getMaven().getGenerateReleaseTrainDocsCommand().replace(VERSION_MUSTACHE, version); + String updatedCommand = this.properties.getMaven() + .getGenerateReleaseTrainDocsCommand() + .replace(VERSION_MUSTACHE, version); runCommand(projectRoot, updatedCommand.split(" ")); assertNoHtmlFilesInDocsContainUnresolvedTags(this.properties.getWorkingDir()); log.info("No HTML files from docs contain unresolved tags"); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } - private String commandWithSystemProps(String command, - ProjectVersion version) { + private String commandWithSystemProps(String command, ProjectVersion version) { if (command.contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) { return appendProfile(command, version); } - return appendProfile(command, version) + " " + ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER; + return appendProfile(command, version) + " " + + ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER; } private String appendProfile(String command, ProjectVersion version) { @@ -77,10 +115,12 @@ public class ProjectBuilder implements ReleaserPropertiesAware { if (version.isMilestone() || version.isRc()) { log.info("Adding the milestone profile to the Maven build"); return trimmedCommand + " -Pmilestone"; - } else if (version.isRelease() || version.isServiceRelease()) { + } + else if (version.isRelease() || version.isServiceRelease()) { log.info("Adding the central profile to the Maven build"); return trimmedCommand + " -Pcentral"; - } else { + } + else { log.info("The build is a snapshot one - will not add any profiles"); } return trimmedCommand; @@ -101,11 +141,12 @@ public class ProjectBuilder implements ReleaserPropertiesAware { public void deploy(ProjectVersion version) { try { - String[] commands = commandWithSystemProps(this.properties.getMaven().getDeployCommand(), - version).split(" "); + String[] commands = commandWithSystemProps( + this.properties.getMaven().getDeployCommand(), version).split(" "); runCommand(commands); log.info("The project has successfully been deployed"); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } @@ -132,29 +173,31 @@ public class ProjectBuilder implements ReleaserPropertiesAware { runCommand(commands); } log.info("The docs got published successfully"); - } catch (Exception e) { + } + catch (Exception e) { throw new IllegalStateException(e); } } /** - * We need to insert the system properties as a list of -Dkey=value entries - * instead of just pasting the String that contains these values + * We need to insert the system properties as a list of -Dkey=value entries instead of + * just pasting the String that contains these values. */ private String[] substituteSystemProps(String... commands) { - boolean containsSystemProps = this.properties.getMaven().getSystemProperties().contains("-D"); - String[] splitSystemProps = StringUtils.delimitedListToStringArray(this.properties.getMaven() - .getSystemProperties(), "-D"); + boolean containsSystemProps = this.properties.getMaven().getSystemProperties() + .contains("-D"); + String[] splitSystemProps = StringUtils.delimitedListToStringArray( + this.properties.getMaven().getSystemProperties(), "-D"); // first element might be empty even though the second one contains values if (splitSystemProps.length > 1) { - splitSystemProps = StringUtils.isEmpty(splitSystemProps[0]) ? - Arrays.copyOfRange(splitSystemProps, 1, splitSystemProps.length) : - splitSystemProps; + splitSystemProps = StringUtils.isEmpty(splitSystemProps[0]) + ? Arrays.copyOfRange(splitSystemProps, 1, splitSystemProps.length) + : splitSystemProps; } - String[] systemPropsWithPrefix = containsSystemProps ? Arrays.stream(splitSystemProps) - .map(s -> "-D" + s.trim()) - .collect(Collectors.toList()) - .toArray(new String[splitSystemProps.length]) : splitSystemProps; + String[] systemPropsWithPrefix = containsSystemProps ? Arrays + .stream(splitSystemProps).map(s -> "-D" + s.trim()) + .collect(Collectors.toList()).toArray(new String[splitSystemProps.length]) + : splitSystemProps; final AtomicInteger index = new AtomicInteger(-1); for (int i = 0; i < commands.length; i++) { if (commands[i].contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) { @@ -168,8 +211,10 @@ public class ProjectBuilder implements ReleaserPropertiesAware { commandsList.remove(index.get()); if (index.get() >= commandsList.size()) { commandsList.addAll(systemPropsList); - } else { - // we need to reverse to set the objects in the same order as passed in the prop + } + else { + // we need to reverse to set the objects in the same order as passed in + // the prop List reversedSystemProps = new ArrayList<>(systemPropsList); Collections.reverse(reversedSystemProps); reversedSystemProps.forEach(s -> commandsList.add(index.get(), s)); @@ -178,12 +223,15 @@ public class ProjectBuilder implements ReleaserPropertiesAware { return commandsList.toArray(new String[commandsList.size()]); } - @Override public void setReleaserProperties(ReleaserProperties properties) { + @Override + public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; } + } class ProcessExecutor implements ReleaserPropertiesAware { + private static final Logger log = LoggerFactory.getLogger(ProcessExecutor.class); private String workingDir; @@ -195,18 +243,22 @@ class ProcessExecutor implements ReleaserPropertiesAware { void runCommand(String[] commands, long waitTimeInMinutes) { try { String workingDir = this.workingDir; - log.debug("Will run the command from [{}] via {} and wait for result for [{}] minutes", + log.debug( + "Will run the command from [{}] via {} and wait for result for [{}] minutes", workingDir, commands, waitTimeInMinutes); ProcessBuilder builder = builder(commands, workingDir); Process process = startProcess(builder); boolean finished = process.waitFor(waitTimeInMinutes, TimeUnit.MINUTES); if (!finished) { - log.error("The command hasn't managed to finish in [{}] minutes", waitTimeInMinutes); + log.error("The command hasn't managed to finish in [{}] minutes", + waitTimeInMinutes); process.destroyForcibly(); - throw new IllegalStateException("Process waiting time of [" + waitTimeInMinutes + "] minutes exceeded"); + throw new IllegalStateException("Process waiting time of [" + + waitTimeInMinutes + "] minutes exceeded"); } if (process.exitValue() != 0) { - throw new IllegalStateException("The process has exited with exit code [" + process.exitValue() + "]"); + throw new IllegalStateException("The process has exited with exit code [" + + process.exitValue() + "]"); } } catch (InterruptedException | IOException e) { @@ -219,24 +271,27 @@ class ProcessExecutor implements ReleaserPropertiesAware { } ProcessBuilder builder(String[] commands, String workingDir) { - return new ProcessBuilder(commands) - .directory(new File(workingDir)) - .inheritIO(); + return new ProcessBuilder(commands).directory(new File(workingDir)).inheritIO(); } - @Override public void setReleaserProperties(ReleaserProperties properties) { + @Override + public void setReleaserProperties(ReleaserProperties properties) { this.workingDir = properties.getWorkingDir(); } + } class HtmlFileWalker extends SimpleFileVisitor { private static final String HTML_EXTENSION = ".html"; - @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attr) { + @Override + public FileVisitResult visitFile(Path path, BasicFileAttributes attr) { File file = path.toFile(); - if (file.getName().endsWith(HTML_EXTENSION) && asString(file).contains("Unresolved")) { - throw new IllegalStateException("File [" + file + "] contains a tag that wasn't resolved properly"); + if (file.getName().endsWith(HTML_EXTENSION) + && asString(file).contains("Unresolved")) { + throw new IllegalStateException( + "File [" + file + "] contains a tag that wasn't resolved properly"); } return FileVisitResult.CONTINUE; } @@ -249,4 +304,5 @@ class HtmlFileWalker extends SimpleFileVisitor { throw new IllegalStateException(e); } } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Project.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Project.java index a6eb5157..47edfd21 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Project.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Project.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import java.util.ArrayList; @@ -8,23 +40,41 @@ import com.fasterxml.jackson.annotation.JsonInclude; /** * @author Marcin Grzejszczak */ -@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Project { + public String id = ""; + public String name = ""; + public String repoUrl = ""; + public String siteUrl = ""; + public String category = ""; + public String stackOverflowTags; + public List projectReleases = new ArrayList<>(); + public List stackOverflowTagList = new ArrayList<>(); + public Boolean aggregator; - @Override public String toString() { - return "Project{" + "id='" + this.id + '\'' + ", name='" + this.name + '\'' + ", repoUrl='" - + this.repoUrl + '\'' + ", siteUrl='" + this.siteUrl + '\'' + ", category='" - + this.category + '\'' + ", stackOverflowTags='" + this.stackOverflowTags + '\'' - + ", projectReleases=" + this.projectReleases + ", stackOverflowTagList=" - + this.stackOverflowTagList + ", aggregator=" + this.aggregator + '}'; + public String rawBootConfig; + + public String rawOverview; + + @Override + public String toString() { + return "Project{" + "id='" + this.id + '\'' + ", name='" + this.name + '\'' + + ", repoUrl='" + this.repoUrl + '\'' + ", siteUrl='" + this.siteUrl + + '\'' + ", category='" + this.category + '\'' + ", stackOverflowTags='" + + this.stackOverflowTags + '\'' + ", projectReleases=" + + this.projectReleases + ", stackOverflowTagList=" + + this.stackOverflowTagList + ", aggregator=" + this.aggregator + + ", rawBootConfig='" + this.rawBootConfig + '\'' + ", rawOverview='" + + this.rawOverview + '\'' + '}'; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Release.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Release.java index 6711226b..93d5ced6 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Release.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Release.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import com.fasterxml.jackson.annotation.JsonInclude; @@ -5,28 +37,43 @@ import com.fasterxml.jackson.annotation.JsonInclude; /** * @author Marcin Grzejszczak */ -@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Release { + public String releaseStatus = ""; + public String refDocUrl = ""; + public String apiDocUrl = ""; + public String groupId = ""; + public String artifactId = ""; + public Repository repository; + public String version = ""; + public boolean current; + public boolean generalAvailability; + public boolean preRelease; + public String versionDisplayName = ""; + public boolean snapshot; - @Override public String toString() { - return "Release{" + "releaseStatus='" + this.releaseStatus + '\'' + ", refDocUrl='" - + this.refDocUrl + '\'' + ", apiDocUrl='" + this.apiDocUrl + '\'' + ", groupId='" - + this.groupId + '\'' + ", artifactId='" + this.artifactId + '\'' + ", repository=" - + this.repository + ", version='" + this.version + '\'' + ", current=" + this.current - + ", generalAvailability=" + this.generalAvailability + ", preRelease=" - + this.preRelease + ", versionDisplayName='" + this.versionDisplayName + '\'' - + ", snapshot=" + this.snapshot + '}'; + @Override + public String toString() { + return "Release{" + "releaseStatus='" + this.releaseStatus + '\'' + + ", refDocUrl='" + this.refDocUrl + '\'' + ", apiDocUrl='" + + this.apiDocUrl + '\'' + ", groupId='" + this.groupId + '\'' + + ", artifactId='" + this.artifactId + '\'' + ", repository=" + + this.repository + ", version='" + this.version + '\'' + ", current=" + + this.current + ", generalAvailability=" + this.generalAvailability + + ", preRelease=" + this.preRelease + ", versionDisplayName='" + + this.versionDisplayName + '\'' + ", snapshot=" + this.snapshot + '}'; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/ReleaseUpdate.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/ReleaseUpdate.java index 35ca3401..2e71a31d 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/ReleaseUpdate.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/ReleaseUpdate.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import com.fasterxml.jackson.annotation.JsonInclude; @@ -5,21 +37,32 @@ import com.fasterxml.jackson.annotation.JsonInclude; /** * @author Marcin Grzejszczak */ -@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class ReleaseUpdate { + public String groupId = ""; + public String artifactId = ""; + public String version = ""; + public String releaseStatus = ""; + public String refDocUrl = ""; + public String apiDocUrl = ""; + public Boolean current; + public Repository repository; - @Override public String toString() { + @Override + public String toString() { return "ReleaseUpdate{" + "groupId='" + this.groupId + '\'' + ", artifactId='" - + this.artifactId + '\'' + ", version='" + this.version + '\'' + ", releaseStatus='" - + this.releaseStatus + '\'' + ", refDocUrl='" + this.refDocUrl + '\'' - + ", apiDocUrl='" + this.apiDocUrl + '\'' + ", repository=" + this.repository + '}'; + + this.artifactId + '\'' + ", version='" + this.version + '\'' + + ", releaseStatus='" + this.releaseStatus + '\'' + ", refDocUrl='" + + this.refDocUrl + '\'' + ", apiDocUrl='" + this.apiDocUrl + '\'' + + ", repository=" + this.repository + '}'; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Repository.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Repository.java index 984d5e46..3394f983 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Repository.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Repository.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import com.fasterxml.jackson.annotation.JsonInclude; @@ -5,15 +37,22 @@ import com.fasterxml.jackson.annotation.JsonInclude; /** * @author Marcin Grzejszczak */ -@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class Repository { + public String id; + public String name; + public String url; + public Boolean snapshotsEnabled; - @Override public String toString() { - return "Repository{" + "id='" + this.id + '\'' + ", name='" + this.name + '\'' + ", url='" - + this.url + '\'' + ", snapshotsEnabled=" + this.snapshotsEnabled + '}'; + @Override + public String toString() { + return "Repository{" + "id='" + this.id + '\'' + ", name='" + this.name + '\'' + + ", url='" + this.url + '\'' + ", snapshotsEnabled=" + + this.snapshotsEnabled + '}'; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClient.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClient.java index 8ab8c156..7c3475eb 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClient.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClient.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import java.net.URI; @@ -5,6 +37,7 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -19,9 +52,11 @@ import org.springframework.web.client.RestTemplate; */ class RestTemplateSaganClient implements SaganClient { - private static final Logger log = LoggerFactory.getLogger(RestTemplateSaganClient.class); + private static final Logger log = LoggerFactory + .getLogger(RestTemplateSaganClient.class); private final RestTemplate restTemplate; + private final String baseUrl; RestTemplateSaganClient(RestTemplate restTemplate, ReleaserProperties properties) { @@ -29,17 +64,28 @@ class RestTemplateSaganClient implements SaganClient { this.baseUrl = properties.getSagan().getBaseUrl(); } - @Override public Project getProject(String projectName) { - return this.restTemplate.getForObject(this.baseUrl + "/project_metadata/{projectName}", Project.class, projectName); + @Override + public Project getProject(String projectName) { + return this.restTemplate.getForObject( + this.baseUrl + "/project_metadata/{projectName}", Project.class, + projectName); } - @Override public Release getRelease(String projectName, String releaseVersion) { - return this.restTemplate.getForObject(this.baseUrl + "/project_metadata/{projectName}/releases/{releaseVersion}", Release.class, projectName, releaseVersion); + @Override + public Release getRelease(String projectName, String releaseVersion) { + return this.restTemplate.getForObject( + this.baseUrl + + "/project_metadata/{projectName}/releases/{releaseVersion}", + Release.class, projectName, releaseVersion); } - @Override public Release deleteRelease(String projectName, String releaseVersion) { - ResponseEntity entity = this.restTemplate.exchange(this.baseUrl + "/project_metadata/{projectName}/releases/{releaseVersion}", - HttpMethod.DELETE, new HttpEntity<>(""), Release.class, projectName, releaseVersion); + @Override + public Release deleteRelease(String projectName, String releaseVersion) { + ResponseEntity entity = this.restTemplate.exchange( + this.baseUrl + + "/project_metadata/{projectName}/releases/{releaseVersion}", + HttpMethod.DELETE, new HttpEntity<>(""), Release.class, projectName, + releaseVersion); Release release = entity.getBody(); log.info("Response from Sagan\n\n[{}] \n with body [{}]", entity, release); return release; @@ -48,13 +94,28 @@ class RestTemplateSaganClient implements SaganClient { @Override public Project updateRelease(String projectName, List releaseUpdates) { RequestEntity> request = RequestEntity - .put(URI.create(this.baseUrl +"/project_metadata/" + projectName + "/releases")) + .put(URI.create( + this.baseUrl + "/project_metadata/" + projectName + "/releases")) .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE) .body(releaseUpdates); - ResponseEntity entity = this.restTemplate - .exchange(request, Project.class); + ResponseEntity entity = this.restTemplate.exchange(request, + Project.class); Project project = entity.getBody(); log.info("Response from Sagan\n\n[{}] \n with body [{}]", entity, project); return project; } + + @Override + public void patchProject(Project project) { + RequestEntity request = RequestEntity + .patch(URI + .create(this.baseUrl + "/project_metadata/" + project.name + "/")) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE) + .body(project); + ResponseEntity entity = this.restTemplate.exchange(request, + Project.class); + Project updatedProject = entity.getBody(); + log.info("Response from Sagan\n\n[{}] \n with body [{}]", entity, updatedProject); + } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganClient.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganClient.java index 8af74e42..bf71decf 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganClient.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganClient.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import java.util.List; @@ -6,6 +38,7 @@ import java.util.List; * @author Marcin Grzejszczak */ public interface SaganClient { + Project getProject(String projectName); Release getRelease(String projectName, String releaseVersion); @@ -13,4 +46,7 @@ public interface SaganClient { Release deleteRelease(String projectName, String releaseVersion); Project updateRelease(String projectName, List releaseUpdate); + + void patchProject(Project project); + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java index c2d80dec..f67a7074 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import java.util.stream.Collectors; @@ -17,6 +49,7 @@ public class SaganUpdater { private static final Logger log = LoggerFactory.getLogger(SaganUpdater.class); private final SaganClient saganClient; + private final ReleaserProperties releaserProperties; public SaganUpdater(SaganClient saganClient, ReleaserProperties releaserProperties) { @@ -24,7 +57,8 @@ public class SaganUpdater { this.releaserProperties = releaserProperties; } - public void updateSagan(String branch, ProjectVersion originalVersion, ProjectVersion version) { + public void updateSagan(String branch, ProjectVersion originalVersion, + ProjectVersion version) { if (!this.releaserProperties.getSagan().isUpdateSagan()) { log.info("Will not update sagan, since the switch to do so " + "is off. Set [releaser.sagan.update-sagan] to [true] to change that"); @@ -33,13 +67,16 @@ public class SaganUpdater { ReleaseUpdate update = releaseUpdate(branch, originalVersion, version); updateSaganForNonSnapshot(branch, originalVersion, version); log.info("Updating Sagan with \n\n{}", update); - this.saganClient.updateRelease(version.projectName, Collections.singletonList(update)); + this.saganClient.updateRelease(version.projectName, + Collections.singletonList(update)); } private void updateSaganForNonSnapshot(String branch, ProjectVersion originalVersion, ProjectVersion version) { if (!version.isSnapshot()) { - log.info("Version is non snapshot [{}]. Will remove all older versions and mark this as current", version); + log.info( + "Version is non snapshot [{}]. Will remove all older versions and mark this as current", + version); Project project = this.saganClient.getProject(version.projectName); if (project != null) { removeAllSameMinorVersions(version, project); @@ -48,10 +85,11 @@ public class SaganUpdater { removeVersionFromSagan(version, snapshot); if (version.isRelease() || version.isServiceRelease()) { String bumpedSnapshot = toSnapshot(version.bumpedVersion()); - ReleaseUpdate snapshotUpdate = - releaseUpdate(branch, originalVersion, new ProjectVersion(version.projectName, bumpedSnapshot)); + ReleaseUpdate snapshotUpdate = releaseUpdate(branch, originalVersion, + new ProjectVersion(version.projectName, bumpedSnapshot)); log.info("Updating Sagan with bumped snapshot \n\n[{}]", snapshotUpdate); - this.saganClient.updateRelease(version.projectName, Collections.singletonList(snapshotUpdate)); + this.saganClient.updateRelease(version.projectName, + Collections.singletonList(snapshotUpdate)); } } } @@ -67,8 +105,10 @@ public class SaganUpdater { log.info("Removing [{}/{}] from Sagan", version.projectName, snapshot); try { this.saganClient.deleteRelease(version.projectName, snapshot); - } catch (Exception e) { - log.error("Failed to remove [" + version.projectName + "/" + snapshot + "] from Sagan", e); + } + catch (Exception e) { + log.error("Failed to remove [" + version.projectName + "/" + snapshot + + "] from Sagan", e); } } @@ -88,7 +128,8 @@ public class SaganUpdater { private String toSnapshot(String version) { if (version.contains("RELEASE")) { return version.replace("RELEASE", "BUILD-SNAPSHOT"); - } else if (version.matches(".*SR[0-9]+")) { + } + else if (version.matches(".*SR[0-9]+")) { return version.substring(0, version.lastIndexOf(".")) + ".BUILD-SNAPSHOT"; } return version; @@ -97,9 +138,11 @@ public class SaganUpdater { private String version(ProjectVersion version) { if (version.isSnapshot()) { return "SNAPSHOT"; - } else if (version.isMilestone() || version.isRc()) { + } + else if (version.isMilestone() || version.isRc()) { return "PRERELEASE"; - } else if (version.isRelease() || version.isServiceRelease()) { + } + else if (version.isRelease() || version.isServiceRelease()) { return "GENERAL_AVAILABILITY"; } return ""; @@ -108,13 +151,16 @@ public class SaganUpdater { private String referenceUrl(String branch, ProjectVersion version) { if (!version.isSnapshot()) { // static/sleuth/{version}/ - return "http://cloud.spring.io/spring-cloud-static/" + version.projectName + "/{version}/"; + return "http://cloud.spring.io/spring-cloud-static/" + version.projectName + + "/{version}/"; } if (branch.toLowerCase().contains("master")) { // sleuth/ - return "http://cloud.spring.io/" + version.projectName + "/" + version.projectName + ".html"; + return "http://cloud.spring.io/" + version.projectName + "/" + + version.projectName + ".html"; } // sleuth/1.1.x/ return "http://cloud.spring.io/" + version.projectName + "/" + branch + "/"; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/HandlebarsHelper.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/HandlebarsHelper.java index 6e29af25..0a365381 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/HandlebarsHelper.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/HandlebarsHelper.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.tech; import java.io.IOException; @@ -12,10 +44,14 @@ import com.github.jknack.handlebars.io.ClassPathTemplateLoader; */ public final class HandlebarsHelper { + private HandlebarsHelper() { + throw new IllegalStateException("Can't instantiate a utility class"); + } + public static Template template(String templateSubFolder, String templateName) { try { - Handlebars handlebars = new Handlebars(new ClassPathTemplateLoader("/templates/" + - templateSubFolder)); + Handlebars handlebars = new Handlebars( + new ClassPathTemplateLoader("/templates/" + templateSubFolder)); handlebars.registerHelper("replace", StringHelpers.replace); handlebars.registerHelper("capitalizeFirst", StringHelpers.capitalizeFirst); return handlebars.compile(templateName); @@ -24,4 +60,5 @@ public final class HandlebarsHelper { throw new IllegalStateException(e); } } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/MakeBuildUnstableException.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/MakeBuildUnstableException.java index 4be3d2df..029baad8 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/MakeBuildUnstableException.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/MakeBuildUnstableException.java @@ -5,7 +5,23 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -20,12 +36,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Exception to be thrown if one wants to continue with the build - * and throw this exception at the end of the release + * Exception to be thrown if one wants to continue with the build and throw this exception + * at the end of the release. + * + * @author Marcin Grzejszczak */ public class MakeBuildUnstableException extends RuntimeException { - private static final Logger log = LoggerFactory.getLogger(MakeBuildUnstableException.class); + private static final Logger log = LoggerFactory + .getLogger(MakeBuildUnstableException.class); public MakeBuildUnstableException(Throwable cause) { super(cause); @@ -41,4 +60,5 @@ public class MakeBuildUnstableException extends RuntimeException { super(message, cause); log.error("\n\n[BUILD UNSTABLE] WARNING! " + message, cause); } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/BlogTemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/BlogTemplateGenerator.java index b420c2e1..2bc4b78c 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/BlogTemplateGenerator.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/BlogTemplateGenerator.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.template; import java.io.File; @@ -19,16 +51,23 @@ import org.springframework.cloud.release.internal.pom.Projects; */ class BlogTemplateGenerator { - private static final Logger log = LoggerFactory.getLogger(BlogTemplateGenerator.class); + private static final Logger log = LoggerFactory + .getLogger(BlogTemplateGenerator.class); private static final Pattern RC_PATTERN = Pattern.compile("(.*)(RC)([0-9]+)"); + private static final Pattern MILESTONE_PATTERN = Pattern.compile("(.*)(M)([0-9]+)"); + private static final Pattern SR_PATTERN = Pattern.compile("(.*)(SR)([0-9]+)"); private final Template template; + private final String releaseVersion; + private final File blogOutput; + private final Projects projects; + private final NotesGenerator notesGenerator; BlogTemplateGenerator(Template template, String releaseVersion, File blogOutput, @@ -42,31 +81,33 @@ class BlogTemplateGenerator { File blog() { try { - // availability - General Availability (RELEASE) / Service Release 1 (SR1) / Milestone 1 (M1) + // availability - General Availability (RELEASE) / Service Release 1 (SR1) / + // Milestone 1 (M1) // releaseName - Dalston // releaseLink - // - [Maven Central](http://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/Dalston.RELEASE/) + // - [Maven Central](http://repo1.maven.org/maven2/org/ + // springframework/cloud/spring-cloud-dependencies/Dalston.RELEASE/) // - [Spring Milestone](https://repo.spring.io/milestone/) repository // releaseVersion '- Dalston.RELEASE boolean release = this.releaseVersion.contains("RELEASE"); - boolean nonRelease = !(release || SR_PATTERN.matcher(this.releaseVersion).matches()); + boolean nonRelease = !(release + || SR_PATTERN.matcher(this.releaseVersion).matches()); String availability = availability(release); String releaseName = parsedReleaseName(this.releaseVersion); String releaseLink = link(nonRelease); Map map = ImmutableMap.builder() - .put("availability", availability) - .put("releaseName", releaseName) + .put("availability", availability).put("releaseName", releaseName) .put("releaseLink", releaseLink) .put("releaseVersion", this.releaseVersion) .put("projects", this.notesGenerator.fromProjects(this.projects)) - .put("nonRelease", nonRelease) - .build(); + .put("nonRelease", nonRelease).build(); String blog = this.template.apply(map); Files.write(this.blogOutput.toPath(), blog.getBytes()); return this.blogOutput; } catch (Exception e) { - throw new IllegalStateException("Exception occurred while trying to create a blog entry", e); + throw new IllegalStateException( + "Exception occurred while trying to create a blog entry", e); } } @@ -80,15 +121,20 @@ class BlogTemplateGenerator { Matcher milestone = MILESTONE_PATTERN.matcher(this.releaseVersion); if (release) { return "General Availability (RELEASE)"; - } else if (sr.matches()) { + } + else if (sr.matches()) { return availabilityText(sr, "Service Release", "SR"); - } else if (rc.matches()) { + } + else if (rc.matches()) { return availabilityText(rc, "Release Candidate", "RC"); - } else if (milestone.matches()) { + } + else if (milestone.matches()) { return milestone(milestone); } if (log.isWarnEnabled()) { - log.warn("Unrecognized release [{}] . Hopefully, you know what you're doing. Will treat it as milestone", this.releaseVersion); + log.warn("Unrecognized release [{}] . " + + "Hopefully, you know what you're doing. Will treat it as milestone", + this.releaseVersion); } return milestone(milestone); } @@ -106,6 +152,9 @@ class BlogTemplateGenerator { if (nonRelease) { return "[Spring Milestone](https://repo.spring.io/milestone/) repository"; } - return "[Maven Central](http://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/" + this.releaseVersion + "/)"; + return "[Maven Central](http://repo1.maven.org/maven2/" + + "org/springframework/cloud/spring-cloud-dependencies/" + + this.releaseVersion + "/)"; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/EmailTemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/EmailTemplateGenerator.java index b22738a2..b36c840c 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/EmailTemplateGenerator.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/EmailTemplateGenerator.java @@ -1,22 +1,56 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.template; import java.io.File; import java.nio.file.Files; +import com.github.jknack.handlebars.Template; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.github.jknack.handlebars.Template; - /** * @author Marcin Grzejszczak */ class EmailTemplateGenerator { - private static final Logger log = LoggerFactory.getLogger(EmailTemplateGenerator.class); + private static final Logger log = LoggerFactory + .getLogger(EmailTemplateGenerator.class); private final Template template; + private final String releaseVersion; + private final File emailOutput; EmailTemplateGenerator(Template template, String releaseVersion, File emailOutput) { @@ -32,7 +66,9 @@ class EmailTemplateGenerator { return this.emailOutput; } catch (Exception e) { - throw new IllegalStateException("Exception occurred while trying to generate an email template", e); + throw new IllegalStateException( + "Exception occurred while trying to generate an email template", e); } } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/NotesGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/NotesGenerator.java index cdde234f..e950a3e5 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/NotesGenerator.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/NotesGenerator.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.template; import java.util.Arrays; @@ -20,22 +52,26 @@ class NotesGenerator { } Set fromProjects(Projects projects) { - return projects.stream().filter(projectVersion -> - !projectVersion.projectName.toLowerCase().contains("boot") - ).map(projectVersion -> { - String name = projectVersion.projectName; - String version = projectVersion.version; - String closedMilestoneUrl = this.handler.milestoneUrl(projectVersion); - String convertedName = Arrays.stream(name.split("-")) - .map(StringUtils::capitalize).collect(Collectors.joining(" ")); - return new Notes(convertedName, version, closedMilestoneUrl); - }).collect(Collectors.toSet()); + return projects.stream().filter(projectVersion -> !projectVersion.projectName + .toLowerCase().contains("boot")).map(projectVersion -> { + String name = projectVersion.projectName; + String version = projectVersion.version; + String closedMilestoneUrl = this.handler.milestoneUrl(projectVersion); + String convertedName = Arrays.stream(name.split("-")) + .map(StringUtils::capitalize) + .collect(Collectors.joining(" ")); + return new Notes(convertedName, version, closedMilestoneUrl); + }).collect(Collectors.toSet()); } + } class Notes { + private final String name; + private final String version; + private final String closedMilestoneUrl; Notes(String name, String version, String closedMilestoneUrl) { @@ -57,22 +93,27 @@ class Notes { return this.closedMilestoneUrl; } - @Override public boolean equals(Object o) { - if (this == o) + @Override + public boolean equals(Object o) { + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || getClass() != o.getClass()) { return false; + } Notes notes = (Notes) o; - if (this.name != null ? !this.name.equals(notes.name) : notes.name != null) + if (this.name != null ? !this.name.equals(notes.name) : notes.name != null) { return false; - return this.version != null ? - this.version.equals(notes.version) : - notes.version == null; + } + return this.version != null ? this.version.equals(notes.version) + : notes.version == null; } - @Override public int hashCode() { + @Override + public int hashCode() { int result = this.name != null ? this.name.hashCode() : 0; result = 31 * result + (this.version != null ? this.version.hashCode() : 0); return result; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/ReleaseNotesTemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/ReleaseNotesTemplateGenerator.java index 5e3b8168..63bc7d22 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/ReleaseNotesTemplateGenerator.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/ReleaseNotesTemplateGenerator.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.template; import java.io.File; @@ -20,12 +52,17 @@ import org.springframework.cloud.release.internal.pom.Projects; */ class ReleaseNotesTemplateGenerator { - private static final Logger log = LoggerFactory.getLogger(ReleaseNotesTemplateGenerator.class); + private static final Logger log = LoggerFactory + .getLogger(ReleaseNotesTemplateGenerator.class); private final Template template; + private final String releaseVersion; + private final File blogOutput; + private final Projects projects; + private final NotesGenerator notesGenerator; ReleaseNotesTemplateGenerator(Template template, String releaseVersion, @@ -49,7 +86,9 @@ class ReleaseNotesTemplateGenerator { return this.blogOutput; } catch (IOException e) { - throw new IllegalStateException("Exception occurred while trying to generate release notes", e); + throw new IllegalStateException( + "Exception occurred while trying to generate release notes", e); } } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TemplateGenerator.java index f7f50d49..28d39470 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TemplateGenerator.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TemplateGenerator.java @@ -1,32 +1,73 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.template; import java.io.File; import java.io.IOException; +import com.github.jknack.handlebars.Template; + import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.ReleaserPropertiesAware; import org.springframework.cloud.release.internal.git.ProjectGitHandler; import org.springframework.cloud.release.internal.pom.Projects; import org.springframework.cloud.release.internal.tech.HandlebarsHelper; -import com.github.jknack.handlebars.Template; - /** * @author Marcin Grzejszczak */ public class TemplateGenerator implements ReleaserPropertiesAware { private static final String EMAIL_TEMPLATE = "email"; + private static final String BLOG_TEMPLATE = "blog"; + private static final String TWITTER_TEMPLATE = "tweet"; + private static final String RELEASE_NOTES_TEMPLATE = "notes"; + private final File emailOutput; + private final File blogOutput; + private final File tweetOutput; + private final File releaseNotesOutput; - private ReleaserProperties props; + private final ProjectGitHandler handler; + private ReleaserProperties props; + public TemplateGenerator(ReleaserProperties props, ProjectGitHandler handler) { this.props = props; this.handler = handler; @@ -63,7 +104,8 @@ public class TemplateGenerator implements ReleaserPropertiesAware { throw new IllegalStateException("Couldn't create a file [" + file + "]"); } return file; - } catch (IOException e) { + } + catch (IOException e) { throw new IllegalStateException(e); } } @@ -72,7 +114,8 @@ public class TemplateGenerator implements ReleaserPropertiesAware { File blogOutput = file(this.blogOutput); String releaseVersion = parsedVersion(projects); Template template = template(BLOG_TEMPLATE); - return new BlogTemplateGenerator(template, releaseVersion, blogOutput, projects, this.handler).blog(); + return new BlogTemplateGenerator(template, releaseVersion, blogOutput, projects, + this.handler).blog(); } public File tweet(Projects projects) { @@ -86,8 +129,8 @@ public class TemplateGenerator implements ReleaserPropertiesAware { File output = file(this.releaseNotesOutput); String releaseVersion = parsedVersion(projects); Template template = template(RELEASE_NOTES_TEMPLATE); - return new ReleaseNotesTemplateGenerator(template, releaseVersion, - output, projects, this.handler).releaseNotes(); + return new ReleaseNotesTemplateGenerator(template, releaseVersion, output, + projects, this.handler).releaseNotes(); } private String parsedVersion(Projects projects) { @@ -102,10 +145,13 @@ public class TemplateGenerator implements ReleaserPropertiesAware { } private Template template(String template) { - return HandlebarsHelper.template(this.props.getTemplate().getTemplateFolder(), template); + return HandlebarsHelper.template(this.props.getTemplate().getTemplateFolder(), + template); } - @Override public void setReleaserProperties(ReleaserProperties properties) { + @Override + public void setReleaserProperties(ReleaserProperties properties) { this.props = properties; } + } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TwitterTemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TwitterTemplateGenerator.java index 4921f17a..4b6ff0fe 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TwitterTemplateGenerator.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TwitterTemplateGenerator.java @@ -1,21 +1,56 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.template; import java.io.File; import java.nio.file.Files; +import com.github.jknack.handlebars.Template; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.github.jknack.handlebars.Template; - /** * @author Marcin Grzejszczak */ class TwitterTemplateGenerator { - private static final Logger log = LoggerFactory.getLogger(TwitterTemplateGenerator.class); + + private static final Logger log = LoggerFactory + .getLogger(TwitterTemplateGenerator.class); private final Template template; + private final String releaseVersion; + private final File output; TwitterTemplateGenerator(Template template, String releaseVersion, File output) { @@ -31,7 +66,9 @@ class TwitterTemplateGenerator { return this.output; } catch (Exception e) { - throw new IllegalStateException("Exception occurred while trying to generate a twitter template", e); + throw new IllegalStateException( + "Exception occurred while trying to generate a twitter template", e); } } + } diff --git a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/email.hbs b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/email.hbs index 31a9a8d7..5b75dfd5 100644 --- a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/email.hbs +++ b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/email.hbs @@ -9,4 +9,4 @@ On behalf of the team and the community, I'm excited to announce Spring Cloud {{ link to blog post link to twitter -Cheers, \ No newline at end of file +Cheers, diff --git a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/notes.hbs b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/notes.hbs index 88000e3a..1b21b9c1 100644 --- a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/notes.hbs +++ b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/notes.hbs @@ -3,4 +3,4 @@ {{ date }} {{#each projects}} - {{name}} `{{version}}` {{#if closedMilestoneUrl}}([issues]({{{ closedMilestoneUrl }}})){{/if}} -{{/each}} \ No newline at end of file +{{/each}} diff --git a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/spring-project.hbs b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/spring-project.hbs index aa92b0a5..d133e52c 100644 --- a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/spring-project.hbs +++ b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/spring-project.hbs @@ -356,4 +356,4 @@ Spring dependency management plugin. {% endcapture %} {% include project_page.html %} - \ No newline at end of file + diff --git a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/tweet.hbs b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/tweet.hbs index 3d1e1480..1769382b 100644 --- a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/tweet.hbs +++ b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/tweet.hbs @@ -1 +1 @@ -The {{ this }} version of @springcloud has been released! \ No newline at end of file +The {{ this }} version of @springcloud has been released! diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/PomUpdateAcceptanceTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/PomUpdateAcceptanceTests.java index 74633de1..d69b2065 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/PomUpdateAcceptanceTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/PomUpdateAcceptanceTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal; import java.io.File; @@ -11,6 +27,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; + import org.springframework.cloud.release.internal.pom.ProjectPomUpdater; import org.springframework.cloud.release.internal.pom.ProjectVersion; import org.springframework.cloud.release.internal.pom.Projects; @@ -25,8 +42,11 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class PomUpdateAcceptanceTests { + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + TestPomReader testPomReader = new TestPomReader(); - @Rule public TemporaryFolder tmp = new TemporaryFolder(); + File temporaryFolder; @Before @@ -44,21 +64,25 @@ public class PomUpdateAcceptanceTests { Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); File project = new File(this.temporaryFolder, "/spring-cloud-sleuth"); - projectPomUpdater - .updateProjectFromReleaseTrain(project, projects, projects.forFile(project), true); + projectPomUpdater.updateProjectFromReleaseTrain(project, projects, + projects.forFile(project), true); then(this.temporaryFolder).exists(); - Model rootPom = this.testPomReader.readPom(tmpFile("/spring-cloud-sleuth/pom.xml")); - Model depsPom = this.testPomReader.readPom(tmpFile("/spring-cloud-sleuth/spring-cloud-sleuth-dependencies/pom.xml")); - Model corePom = this.testPomReader.readPom(tmpFile("/spring-cloud-sleuth/spring-cloud-sleuth-core/pom.xml")); - Model zipkinStreamPom = this.testPomReader.readPom(tmpFile("/spring-cloud-sleuth/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml")); + Model rootPom = this.testPomReader + .readPom(tmpFile("/spring-cloud-sleuth/pom.xml")); + Model depsPom = this.testPomReader.readPom( + tmpFile("/spring-cloud-sleuth/spring-cloud-sleuth-dependencies/pom.xml")); + Model corePom = this.testPomReader.readPom( + tmpFile("/spring-cloud-sleuth/spring-cloud-sleuth-core/pom.xml")); + Model zipkinStreamPom = this.testPomReader.readPom(tmpFile( + "/spring-cloud-sleuth/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml")); then(rootPom.getVersion()).isEqualTo("1.2.0.BUILD-SNAPSHOT"); then(rootPom.getProperties()) - .containsEntry("spring-cloud-build.version","1.3.1.BUILD-SNAPSHOT") - .containsEntry("spring-cloud-commons.version","1.2.0.BUILD-SNAPSHOT") - .containsEntry("spring-cloud-stream.version","Chelsea.BUILD-SNAPSHOT") - .containsEntry("spring-cloud-netflix.version","1.3.0.BUILD-SNAPSHOT") - .containsEntry("checkstyle.version","100.0.0.RELEASE"); + .containsEntry("spring-cloud-build.version", "1.3.1.BUILD-SNAPSHOT") + .containsEntry("spring-cloud-commons.version", "1.2.0.BUILD-SNAPSHOT") + .containsEntry("spring-cloud-stream.version", "Chelsea.BUILD-SNAPSHOT") + .containsEntry("spring-cloud-netflix.version", "1.3.0.BUILD-SNAPSHOT") + .containsEntry("checkstyle.version", "100.0.0.RELEASE"); then(depsPom.getVersion()).isEqualTo("1.2.0.BUILD-SNAPSHOT"); then(depsPom.getParent().getVersion()).isEqualTo("1.3.1.BUILD-SNAPSHOT"); then(corePom.getParent().getVersion()).isEqualTo("1.2.0.BUILD-SNAPSHOT"); @@ -66,50 +90,58 @@ public class PomUpdateAcceptanceTests { } @Test - public void should_not_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version() throws Exception { + public void should_not_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version() + throws Exception { ReleaserProperties releaserProperties = branchReleaserProperties(); ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); projects.add(new ProjectVersion("spring-cloud-sleuth-samples", "0.0.5.RELEASE")); - File project = new File(this.temporaryFolder, "/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples"); + File project = new File(this.temporaryFolder, + "/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples"); addBuildSnapshotToChildPom(project); - projectPomUpdater - .updateProjectFromReleaseTrain(project, projects, projects.forFile(project), true); + projectPomUpdater.updateProjectFromReleaseTrain(project, projects, + projects.forFile(project), true); } private void addBuildSnapshotToChildPom(File project) throws IOException { File childPom = new File(project, "pom.xml"); String text = new String(Files.readAllBytes(childPom.toPath())); - Files.write(childPom.toPath(), text.replaceAll("1.19.2", "1.19.2.BUILD-SNAPSHOT").getBytes()); + Files.write(childPom.toPath(), + text.replaceAll("1.19.2", "1.19.2.BUILD-SNAPSHOT").getBytes()); } @Test - public void should_not_fail_update_when_after_updating_a_release_version_there_still_is_a_snapshot_version_in_a_non_deployable_module() throws Exception { + public void should_not_fail_update_when_after_updating_a_release_version_there_still_is_a_snapshot_version_in_a_non_deployable_module() + throws Exception { ReleaserProperties releaserProperties = branchReleaserProperties(); ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); - File project = new File(this.temporaryFolder, "/spring-cloud-sleuth-with-unmatched-property"); + File project = new File(this.temporaryFolder, + "/spring-cloud-sleuth-with-unmatched-property"); - BDDAssertions.thenThrownBy(() -> - projectPomUpdater - .updateProjectFromReleaseTrain(project, projects, projects.forFile(project), true) - ).hasMessageContaining("0.6.0.BUILD-SNAPSHOT"); + BDDAssertions + .thenThrownBy(() -> projectPomUpdater.updateProjectFromReleaseTrain( + project, projects, projects.forFile(project), true)) + .hasMessageContaining( + "0.6.0.BUILD-SNAPSHOT"); } @Test - public void should_update_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version_for_boot_snapshot_version() throws Exception { + public void should_update_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version_for_boot_snapshot_version() + throws Exception { ReleaserProperties releaserProperties = branchReleaserProperties(); ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); - projects.removeIf(projectVersion -> projectVersion.projectName.contains("spring-cloud-build")); + projects.removeIf(projectVersion -> projectVersion.projectName + .contains("spring-cloud-build")); projects.add(new ProjectVersion("spring-cloud-build", "1.4.2.BUILD-SNAPSHOT")); File project = new File(this.temporaryFolder, "/spring-cloud-sleuth"); - BDDAssertions.thenThrownBy(() -> - projectPomUpdater - .updateProjectFromReleaseTrain(project, projects, projects.forFile(project), true) - ).hasMessageContaining("1.4.2.BUILD-SNAPSHOT"); + BDDAssertions + .thenThrownBy(() -> projectPomUpdater.updateProjectFromReleaseTrain( + project, projects, projects.forFile(project), true)) + .hasMessageContaining("1.4.2.BUILD-SNAPSHOT"); } @Test @@ -130,7 +162,8 @@ public class PomUpdateAcceptanceTests { private ReleaserProperties releaserProperties() throws URISyntaxException { ReleaserProperties releaserProperties = new ReleaserProperties(); - releaserProperties.getGit().setReleaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString()); + releaserProperties.getGit().setReleaseTrainBomUrl( + file("/projects/spring-cloud-release/").toURI().toString()); return releaserProperties; } @@ -149,10 +182,14 @@ public class PomUpdateAcceptanceTests { } private File pom(String relativePath) throws URISyntaxException { - return new File(new File(PomUpdateAcceptanceTests.class.getResource(relativePath).toURI()), "pom.xml"); + return new File( + new File( + PomUpdateAcceptanceTests.class.getResource(relativePath).toURI()), + "pom.xml"); } private String asString(File file) throws IOException { return new String(Files.readAllBytes(file.toPath())); } + } diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/ReleaserPropertiesTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/ReleaserPropertiesTests.java index bbd9e209..d23729bd 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/ReleaserPropertiesTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/ReleaserPropertiesTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal; import java.util.Arrays; @@ -13,6 +29,7 @@ import static org.assertj.core.api.BDDAssertions.then; * @author Marcin Grzejszczak */ public class ReleaserPropertiesTests { + @Test public void should_return_provided_working_dir_when_it_was_set() { String workingDir = "foo"; @@ -52,22 +69,17 @@ public class ReleaserPropertiesTests { copy.getPom().setIgnoredPomRegex(Arrays.asList("bar8", "bar9")); copy.getSagan().setBaseUrl("bar10"); - BDDAssertions.then(properties.getWorkingDir()) - .isEqualTo("foo"); - BDDAssertions.then(properties.getFixedVersions()) - .isEqualTo(map()); - BDDAssertions.then(properties.getMaven().getBuildCommand()) - .isEqualTo("foo2"); + BDDAssertions.then(properties.getWorkingDir()).isEqualTo("foo"); + BDDAssertions.then(properties.getFixedVersions()).isEqualTo(map()); + BDDAssertions.then(properties.getMaven().getBuildCommand()).isEqualTo("foo2"); BDDAssertions.then(properties.getGradle().getIgnoredGradleRegex()) .isEqualTo(Arrays.asList("foo3", "foo4")); BDDAssertions.then(properties.getMetaRelease().getProjectsToSkip()) .isEqualTo(Arrays.asList("foo5", "foo6")); - BDDAssertions.then(properties.getGit().getPassword()) - .isEqualTo("foo7"); + BDDAssertions.then(properties.getGit().getPassword()).isEqualTo("foo7"); BDDAssertions.then(properties.getPom().getIgnoredPomRegex()) .isEqualTo(Arrays.asList("foo8", "foo9")); - BDDAssertions.then(properties.getSagan().getBaseUrl()) - .isEqualTo("foo10"); + BDDAssertions.then(properties.getSagan().getBaseUrl()).isEqualTo("foo10"); } private Map map() { @@ -81,4 +93,5 @@ public class ReleaserPropertiesTests { map.put("bar", "foo"); return map; } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/ReleaserTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/ReleaserTests.java index d93d61c0..81c6ad28 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/ReleaserTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/ReleaserTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal; import java.io.File; @@ -13,6 +29,7 @@ import org.junit.runner.RunWith; import org.mockito.BDDMockito; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; + import org.springframework.boot.test.rule.OutputCapture; import org.springframework.cloud.release.internal.docs.DocumentationUpdater; import org.springframework.cloud.release.internal.git.ProjectGitHandler; @@ -25,8 +42,8 @@ import org.springframework.cloud.release.internal.project.ProjectBuilder; import org.springframework.cloud.release.internal.sagan.SaganUpdater; import org.springframework.cloud.release.internal.template.TemplateGenerator; -import static org.mockito.BDDMockito.then; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; /** @@ -35,15 +52,33 @@ import static org.mockito.Mockito.never; @RunWith(MockitoJUnitRunner.class) public class ReleaserTests { - @Mock ProjectPomUpdater projectPomUpdater; - @Mock ProjectBuilder projectBuilder; - @Mock ProjectGitHandler projectGitHandler; - @Mock TemplateGenerator templateGenerator; - @Mock GradleUpdater gradleUpdater; - @Mock SaganUpdater saganUpdater; - @Mock DocumentationUpdater documentationUpdater; - @Mock PostReleaseActions postReleaseActions; - @Rule public OutputCapture outputCapture = new OutputCapture(); + @Rule + public OutputCapture outputCapture = new OutputCapture(); + + @Mock + ProjectPomUpdater projectPomUpdater; + + @Mock + ProjectBuilder projectBuilder; + + @Mock + ProjectGitHandler projectGitHandler; + + @Mock + TemplateGenerator templateGenerator; + + @Mock + GradleUpdater gradleUpdater; + + @Mock + SaganUpdater saganUpdater; + + @Mock + DocumentationUpdater documentationUpdater; + + @Mock + PostReleaseActions postReleaseActions; + File pom; @Before @@ -56,7 +91,8 @@ public class ReleaserTests { return new Releaser(this.projectPomUpdater, this.projectBuilder, this.projectGitHandler, this.templateGenerator, this.gradleUpdater, this.saganUpdater, this.documentationUpdater, this.postReleaseActions) { - @Override ProjectVersion originalVersion(File project) { + @Override + ProjectVersion originalVersion(File project) { return originalVersionSupplier.get(); } }; @@ -72,50 +108,58 @@ public class ReleaserTests { public void should_not_bump_versions_for_original_release_project() { releaser(() -> new ProjectVersion("original", "1.0.0.RELEASE")) .rollbackReleaseVersion(this.pom, - new Projects(new ProjectVersion("changed", "1.0.0.RELEASE")), + new Projects(new ProjectVersion("changed", "1.0.0.RELEASE")), new ProjectVersion("changed", "1.0.0.RELEASE")); - BDDAssertions.then(this.outputCapture.toString()).contains("Successfully reverted the commit and came back to snapshot versions"); - then(this.projectGitHandler).should(never()).commitAfterBumpingVersions(any(File.class), any(ProjectVersion.class)); + BDDAssertions.then(this.outputCapture.toString()).contains( + "Successfully reverted the commit and came back to snapshot versions"); + then(this.projectGitHandler).should(never()) + .commitAfterBumpingVersions(any(File.class), any(ProjectVersion.class)); } @Test public void should_not_bump_versions_for_original_snapshot_project_and_current_snapshot() { releaser(() -> new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")) .rollbackReleaseVersion(this.pom, - new Projects(new ProjectVersion("changed", "1.0.0.BUILD-SNAPSHOT")), + new Projects( + new ProjectVersion("changed", "1.0.0.BUILD-SNAPSHOT")), new ProjectVersion("changed", "1.0.0.BUILD-SNAPSHOT")); - BDDAssertions.then(this.outputCapture.toString()).contains("Won't rollback a snapshot version"); - then(this.projectGitHandler).should(never()).commitAfterBumpingVersions(any(File.class), any(ProjectVersion.class)); + BDDAssertions.then(this.outputCapture.toString()) + .contains("Won't rollback a snapshot version"); + then(this.projectGitHandler).should(never()) + .commitAfterBumpingVersions(any(File.class), any(ProjectVersion.class)); } @Test public void should_bump_versions_for_original_snapshot_project() { ProjectVersion scReleaseVersion = new ProjectVersion("changed", "1.0.0.RELEASE"); releaser(() -> new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")) - .rollbackReleaseVersion(this.pom, - new Projects(new ProjectVersion("changed", "1.0.0.RELEASE"), - new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"), - new ProjectVersion("spring-boot-starter", "3.0.0.RELEASE")), + .rollbackReleaseVersion(this.pom, new Projects( + new ProjectVersion("changed", "1.0.0.RELEASE"), + new ProjectVersion("spring-cloud-build", "2.0.0.RELEASE"), + new ProjectVersion("spring-boot-starter", "3.0.0.RELEASE")), scReleaseVersion); BDDAssertions.then(this.outputCapture.toString()) - .contains("Project was successfully updated") - .contains("Successfully reverted the commit and bumped snapshot versions"); + .contains("Project was successfully updated").contains( + "Successfully reverted the commit and bumped snapshot versions"); } @Test public void should_not_generate_email_for_snapshot_version() { - releaser().createEmail(new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT"), projects()); + releaser().createEmail(new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT"), + projects()); then(this.templateGenerator).should(never()).email(any(Projects.class)); } @Test public void should_generate_email_for_release_version() { - BDDMockito.given(this.templateGenerator.email(projects())).willReturn(new File(".")); - releaser().createEmail(new ProjectVersion("original", "1.0.0.RELEASE"), projects()); + BDDMockito.given(this.templateGenerator.email(projects())) + .willReturn(new File(".")); + releaser().createEmail(new ProjectVersion("original", "1.0.0.RELEASE"), + projects()); then(this.templateGenerator).should().email(any(Projects.class)); } @@ -124,21 +168,24 @@ public class ReleaserTests { public void should_not_close_milestone_for_snapshots() { releaser().closeMilestone(new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")); - then(this.projectGitHandler).should(never()).closeMilestone(any(ProjectVersion.class)); + then(this.projectGitHandler).should(never()) + .closeMilestone(any(ProjectVersion.class)); } @Test public void should_not_rollback_for_snapshots() { releaser(() -> new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")) .rollbackReleaseVersion(null, - new Projects(new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")), + new Projects( + new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")), new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")); - then(this.projectGitHandler).should(never()).revertChangesIfApplicable(any(File.class), any(ProjectVersion.class)); + then(this.projectGitHandler).should(never()) + .revertChangesIfApplicable(any(File.class), any(ProjectVersion.class)); } Projects projects() { return new Projects(new ProjectVersion("foo", "1.0.0.RELEASE")); } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdaterTests.java index 072fe943..94524f4d 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdaterTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdaterTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.io.File; @@ -11,6 +27,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.mockito.BDDMockito; + import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.git.ProjectGitHandler; import org.springframework.cloud.release.internal.pom.ProjectVersion; @@ -24,21 +41,28 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class ProjectDocumentationUpdaterTests { - @Rule public TemporaryFolder tmp = new TemporaryFolder(); + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + File project; + File tmpFolder; + ProjectGitHandler handler; + File clonedDocProject; + ReleaserProperties properties = new ReleaserProperties(); @Before public void setup() throws IOException, URISyntaxException { this.tmpFolder = this.tmp.newFolder(); - this.project = new File( - ProjectDocumentationUpdaterTests.class.getResource("/projects/spring-cloud-static").toURI()); + this.project = new File(ProjectDocumentationUpdaterTests.class + .getResource("/projects/spring-cloud-static").toURI()); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects"), this.tmpFolder); - this.properties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString()); + this.properties.getGit().setDocumentationUrl( + file("/projects/spring-cloud-static/").toURI().toString()); this.handler = new ProjectGitHandler(this.properties); this.clonedDocProject = this.handler.cloneDocumentationProject(); } @@ -46,42 +70,50 @@ public class ProjectDocumentationUpdaterTests { @Test public void should_throw_exception_if_index_html_not_found() throws URISyntaxException { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "1.3.4.SR10"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "1.3.4.SR10"); ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationBranch("master"); - properties.getGit().setDocumentationUrl(file("/projects/spring-cloud-release/").toURI().toString()); + properties.getGit().setDocumentationUrl( + file("/projects/spring-cloud-release/").toURI().toString()); - BDDAssertions.thenThrownBy(() -> - new ProjectDocumentationUpdater(properties, new ProjectGitHandler(properties)) - .updateDocsRepo(releaseTrainVersion, "vAngel.SR33")) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("index.html is not present"); + BDDAssertions + .thenThrownBy(() -> new ProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)) + .updateDocsRepo(releaseTrainVersion, "vAngel.SR33")) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("index.html is not present"); } @Test public void should_throw_exception_if_index_found_but_doc_repo_url_missing() throws URISyntaxException { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "1.3.4.SR10"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "1.3.4.SR10"); ReleaserProperties properties = new ReleaserProperties(); - properties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString()); + properties.getGit().setDocumentationUrl( + file("/projects/spring-cloud-static/").toURI().toString()); - BDDAssertions.thenThrownBy(() -> - new ProjectDocumentationUpdater(properties, new ProjectGitHandler(properties)) { - @Override String readIndexHtmlContents(File indexHtml) { - return ""; - } - }.updateDocsRepo(releaseTrainVersion, "vAngel.SR33")) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("The URL to the documentation repo not found"); + BDDAssertions.thenThrownBy(() -> new ProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)) { + @Override + String readIndexHtmlContents(File indexHtml) { + return ""; + } + }.updateDocsRepo(releaseTrainVersion, "vAngel.SR33")) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("The URL to the documentation repo not found"); } @Test public void should_not_update_current_version_in_the_docs_if_current_release_is_not_ga_or_sr() { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "2.0.0.BUILD-SNAPSHOT"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "2.0.0.BUILD-SNAPSHOT"); ReleaserProperties properties = new ReleaserProperties(); - File updatedDocs = new ProjectDocumentationUpdater(properties, new ProjectGitHandler(properties)) - .updateDocsRepo(releaseTrainVersion, "vAngel.M7"); + File updatedDocs = new ProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, + "vAngel.M7"); then(updatedDocs).isNull(); } @@ -89,22 +121,26 @@ public class ProjectDocumentationUpdaterTests { @Test public void should_not_update_current_version_in_the_docs_if_current_release_starts_with_v_and_then_lower_letter_than_the_stored_release() throws URISyntaxException, IOException { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "1.3.4.SR10"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "1.3.4.SR10"); ReleaserProperties properties = new ReleaserProperties(); - properties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString()); + properties.getGit().setDocumentationUrl( + file("/projects/spring-cloud-static/").toURI().toString()); - File updatedDocs = new ProjectDocumentationUpdater(properties, new ProjectGitHandler(properties)) - .updateDocsRepo(releaseTrainVersion, "vAngel.SR33"); + File updatedDocs = new ProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, + "vAngel.SR33"); - String indexHtmlContent = new String(Files.readAllBytes( - new File(updatedDocs, "current/index.html").toPath())); + String indexHtmlContent = new String( + Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath())); then(indexHtmlContent) .doesNotContain("http://cloud.spring.io/spring-cloud-static/Angel.SR33/"); } @Test public void should_not_commit_if_the_same_version_is_already_there() { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "1.3.4.SR10"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "1.3.4.SR10"); ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties)); @@ -119,15 +155,17 @@ public class ProjectDocumentationUpdaterTests { @Test public void should_not_update_current_version_in_the_docs_if_current_release_starts_with_lower_letter_than_the_stored_release() throws IOException { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "1.3.4.SR10"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "1.3.4.SR10"); ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); - File updatedDocs = new ProjectDocumentationUpdater(properties, new ProjectGitHandler(properties)) - .updateDocsRepo(releaseTrainVersion, "Angel.SR33"); + File updatedDocs = new ProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, + "Angel.SR33"); - String indexHtmlContent = new String(Files.readAllBytes( - new File(updatedDocs, "current/index.html").toPath())); + String indexHtmlContent = new String( + Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath())); then(indexHtmlContent) .doesNotContain("http://cloud.spring.io/spring-cloud-static/Angel.SR33/"); } @@ -135,15 +173,17 @@ public class ProjectDocumentationUpdaterTests { @Test public void should_update_current_version_in_the_docs_if_current_release_starts_with_v_and_then_higher_letter_than_the_stored_release() throws IOException { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "2.0.0.SR33"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "2.0.0.SR33"); ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); - File updatedDocs = new ProjectDocumentationUpdater(properties, new ProjectGitHandler(properties)) - .updateDocsRepo(releaseTrainVersion, "vFinchley.SR33"); + File updatedDocs = new ProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, + "vFinchley.SR33"); - String indexHtmlContent = new String(Files.readAllBytes( - new File(updatedDocs, "current/index.html").toPath())); + String indexHtmlContent = new String( + Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath())); then(indexHtmlContent) .contains("http://cloud.spring.io/spring-cloud-static/Finchley.SR33/"); } @@ -151,33 +191,39 @@ public class ProjectDocumentationUpdaterTests { @Test public void should_update_current_version_in_the_docs_if_current_release_starts_with_higher_letter_than_the_stored_release() throws IOException { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "2.0.0.SR33"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "2.0.0.SR33"); ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); - File updatedDocs = new ProjectDocumentationUpdater(properties, new ProjectGitHandler(properties)) - .updateDocsRepo(releaseTrainVersion, "Finchley.SR33"); + File updatedDocs = new ProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, + "Finchley.SR33"); - String indexHtmlContent = new String(Files.readAllBytes( - new File(updatedDocs, "current/index.html").toPath())); + String indexHtmlContent = new String( + Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath())); then(indexHtmlContent) .contains("http://cloud.spring.io/spring-cloud-static/Finchley.SR33/"); } @Test public void should_not_update_current_version_in_the_docs_if_switch_is_off() { - ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", "2.0.0.SR33"); + ProjectVersion releaseTrainVersion = new ProjectVersion("spring-cloud-sleuth", + "2.0.0.SR33"); ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); properties.getGit().setUpdateDocumentationRepo(false); - File updatedDocs = new ProjectDocumentationUpdater(properties, new ProjectGitHandler(properties)) - .updateDocsRepo(releaseTrainVersion, "Finchley.SR33"); + File updatedDocs = new ProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, + "Finchley.SR33"); then(updatedDocs).isNull(); } private File file(String relativePath) throws URISyntaxException { - return new File(ProjectDocumentationUpdaterTests.class.getResource(relativePath).toURI()); + return new File( + ProjectDocumentationUpdaterTests.class.getResource(relativePath).toURI()); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsGeneratorTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsGeneratorTests.java index 794d947a..23c5366a 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsGeneratorTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsGeneratorTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.util.Arrays; @@ -17,85 +33,113 @@ public class ReleaseTrainContentsGeneratorTests { @Test public void should_return_empty_contents_if_there_versions_are_lower_than_current_ones() { - ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator(new ReleaserProperties()); + ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator( + new ReleaserProperties()); - String contents = generator - .releaseTrainContents(contents(), olderReleaseTrain()); + String contents = generator.releaseTrainContents(contents(), olderReleaseTrain()); BDDAssertions.then(contents).isEmpty(); } @Test public void should_return_empty_contents_if_there_are_no_changes_in_the_versions() { - ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator(new ReleaserProperties()); + ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator( + new ReleaserProperties()); - String contents = generator - .releaseTrainContents(contents(), sameProjectsForCurrentGa()); + String contents = generator.releaseTrainContents(contents(), + sameProjectsForCurrentGa()); BDDAssertions.then(contents).isEmpty(); } @Test public void should_return_contents_with_updated_current_release_train() { - ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator(new ReleaserProperties()); + ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator( + new ReleaserProperties()); - String contents = generator - .releaseTrainContents(contents(), newerProjectsForNewGa()); + String contents = generator.releaseTrainContents(contents(), + newerProjectsForNewGa()); - BDDAssertions.then(contents).contains("|Edgware.SR5|Finchley.SR2|Finchley.BUILD-SNAPSHOT|"); - BDDAssertions.then(contents).contains(" |spring-cloud-cli|1.4.1.RELEASE|3.0.0.RELEASE|2.0.1.BUILD-SNAPSHOT|"); + BDDAssertions.then(contents) + .contains("|Edgware.SR5|Finchley.SR2|Finchley.BUILD-SNAPSHOT|"); + BDDAssertions.then(contents).contains( + " |spring-cloud-cli|1.4.1.RELEASE|3.0.0.RELEASE|2.0.1.BUILD-SNAPSHOT|"); } @Test public void should_return_contents_with_updated_previous_release_train() { - ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator(new ReleaserProperties()); + ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator( + new ReleaserProperties()); - String contents = generator - .releaseTrainContents(contents(), newerProjectsForOldGa()); + String contents = generator.releaseTrainContents(contents(), + newerProjectsForOldGa()); - BDDAssertions.then(contents).contains("|Edgware.SR6|Finchley.SR1|Finchley.BUILD-SNAPSHOT|"); - BDDAssertions.then(contents).contains(" |spring-cloud-cli|3.0.0.RELEASE|2.0.0.RELEASE|2.0.1.BUILD-SNAPSHOT|"); + BDDAssertions.then(contents) + .contains("|Edgware.SR6|Finchley.SR1|Finchley.BUILD-SNAPSHOT|"); + BDDAssertions.then(contents).contains( + " |spring-cloud-cli|3.0.0.RELEASE|2.0.0.RELEASE|2.0.1.BUILD-SNAPSHOT|"); } @Test public void should_return_contents_with_updated_current_snapshot_train() { - ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator(new ReleaserProperties()); + ReleaseTrainContentsGenerator generator = new ReleaseTrainContentsGenerator( + new ReleaserProperties()); - String contents = generator - .releaseTrainContents(contents(), newerProjectsForCurrentSnapshot()); + String contents = generator.releaseTrainContents(contents(), + newerProjectsForCurrentSnapshot()); - BDDAssertions.then(contents).contains("|Edgware.SR5|Finchley.SR1|Finchley.BUILD-SNAPSHOT|"); - BDDAssertions.then(contents).contains(" |spring-cloud-cli|1.4.1.RELEASE|2.0.0.RELEASE|3.0.0.BUILD-SNAPSHOT|"); + BDDAssertions.then(contents) + .contains("|Edgware.SR5|Finchley.SR1|Finchley.BUILD-SNAPSHOT|"); + BDDAssertions.then(contents).contains( + " |spring-cloud-cli|1.4.1.RELEASE|2.0.0.RELEASE|3.0.0.BUILD-SNAPSHOT|"); } ReleaseTrainContents contents() { Title title = new Title("Edgware.SR5", "Finchley.SR1", "Finchley.BUILD-SNAPSHOT"); List rows = Arrays.asList( - new Row("spring-cloud-aws", "1.2.3.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-bus", "1.3.3.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-cli", "1.4.1.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-commons", "1.3.5.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-contract", "1.2.6.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-config", "1.4.5.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-netflix", "1.4.6.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-security", "1.2.3.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-cloudfoundry", "1.1.2.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-consul", "1.3.5.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-sleuth", "1.3.5.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-stream", "Ditmars.SR4", "Elmhurst.SR1", "Elmhurst.BUILD-SNAPSHOT"), - new Row("spring-cloud-zookeeper", "1.2.2.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-boot", "1.5.16.RELEASE", "2.0.4.RELEASE", "2.0.4.BUILD-SNAPSHOT"), - new Row("spring-cloud-task", "1.2.3.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-vault", "1.1.2.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-gateway", "1.0.2.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-openfeign", "", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-function", "1.0.1.RELEASE", "1.0.0.RELEASE", "1.0.1.BUILD-SNAPSHOT")); + new Row("spring-cloud-aws", "1.2.3.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-bus", "1.3.3.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-cli", "1.4.1.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-commons", "1.3.5.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-contract", "1.2.6.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-config", "1.4.5.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-netflix", "1.4.6.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-security", "1.2.3.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-cloudfoundry", "1.1.2.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-consul", "1.3.5.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-sleuth", "1.3.5.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-stream", "Ditmars.SR4", "Elmhurst.SR1", + "Elmhurst.BUILD-SNAPSHOT"), + new Row("spring-cloud-zookeeper", "1.2.2.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-boot", "1.5.16.RELEASE", "2.0.4.RELEASE", + "2.0.4.BUILD-SNAPSHOT"), + new Row("spring-cloud-task", "1.2.3.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-vault", "1.1.2.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-gateway", "1.0.2.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-openfeign", "", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-function", "1.0.1.RELEASE", "1.0.0.RELEASE", + "1.0.1.BUILD-SNAPSHOT")); return new ReleaseTrainContents(title, rows); } Projects olderReleaseTrain() { - return new Projects( - new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), + return new Projects(new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-bus", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-cli", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-commons", "2.0.1.RELEASE"), @@ -118,8 +162,7 @@ public class ReleaseTrainContentsGeneratorTests { } Projects sameProjectsForCurrentGa() { - return new Projects( - new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), + return new Projects(new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-bus", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-cli", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-commons", "2.0.1.RELEASE"), @@ -142,8 +185,7 @@ public class ReleaseTrainContentsGeneratorTests { } Projects newerProjectsForNewGa() { - return new Projects( - new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), + return new Projects(new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-bus", "3.0.0.RELEASE"), new ProjectVersion("spring-cloud-cli", "3.0.0.RELEASE"), new ProjectVersion("spring-cloud-commons", "3.0.1.RELEASE"), @@ -166,8 +208,7 @@ public class ReleaseTrainContentsGeneratorTests { } Projects newerProjectsForOldGa() { - return new Projects( - new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), + return new Projects(new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-bus", "3.0.0.RELEASE"), new ProjectVersion("spring-cloud-cli", "3.0.0.RELEASE"), new ProjectVersion("spring-cloud-commons", "3.0.1.RELEASE"), @@ -212,4 +253,5 @@ public class ReleaseTrainContentsGeneratorTests { new ProjectVersion("spring-cloud-openfeign", "3.0.1.BUILD-SNAPSHOT"), new ProjectVersion("spring-cloud-function", "1.0.0.BUILD-SNAPSHOT")); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsParserTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsParserTests.java index 4048222b..9bd4858a 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsParserTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsParserTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.io.File; @@ -11,10 +27,10 @@ import org.junit.Test; */ public class ReleaseTrainContentsParserTests { - File finchley = new File( - ReleaseTrainContentsParserTests.class - .getResource("/projects/spring-cloud-wiki/Spring-Cloud-Finchley-Release-Notes.md") - .toURI()); + File finchley = new File(ReleaseTrainContentsParserTests.class + .getResource( + "/projects/spring-cloud-wiki/Spring-Cloud-Finchley-Release-Notes.md") + .toURI()); public ReleaseTrainContentsParserTests() throws URISyntaxException { } @@ -26,4 +42,5 @@ public class ReleaseTrainContentsParserTests { BDDAssertions.then(releaseTrain).isEqualTo("Finchley.SR2"); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdaterTests.java index a7a453a7..15939b41 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdaterTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdaterTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.io.File; @@ -26,19 +42,28 @@ import org.springframework.util.FileSystemUtils; */ public class ReleaseTrainContentsUpdaterTests { + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + ReleaserProperties properties = new ReleaserProperties(); + ProjectGitHandler projectGitHandler = new ProjectGitHandler(this.properties) { @Override public String milestoneUrl(ProjectVersion releaseVersion) { return "http://foo.com"; } }; - TemplateGenerator templateGenerator = new TemplateGenerator(this.properties, this.projectGitHandler); + + TemplateGenerator templateGenerator = new TemplateGenerator(this.properties, + this.projectGitHandler); + ReleaseTrainContentsUpdater updater = new ReleaseTrainContentsUpdater(this.properties, this.projectGitHandler, this.templateGenerator); + File springCloudRepo; + File wikiRepo; - @Rule public TemporaryFolder tmp = new TemporaryFolder(); + File temporaryFolder; @Before @@ -51,7 +76,8 @@ public class ReleaseTrainContentsUpdaterTests { } private File file(String relativePath) throws URISyntaxException { - return new File(ReleaseTrainContentsUpdaterTests.class.getResource(relativePath).toURI()); + return new File( + ReleaseTrainContentsUpdaterTests.class.getResource(relativePath).toURI()); } @Test @@ -64,24 +90,32 @@ public class ReleaseTrainContentsUpdaterTests { } @Test - public void should_not_update_the_contents_of_spring_project_repo_when_release_train_smaller() throws GitAPIException { - this.properties.getGit().setSpringProjectUrl(this.springCloudRepo.getAbsolutePath() + "/"); + public void should_not_update_the_contents_of_spring_project_repo_when_release_train_smaller() + throws GitAPIException { + this.properties.getGit() + .setSpringProjectUrl(this.springCloudRepo.getAbsolutePath() + "/"); File file = this.updater.updateProjectRepo(oldReleaseTrain()); BDDAssertions.then(file).isNotNull(); - BDDAssertions.then(GitTestUtils.openGitProject(file).log().call().iterator().next().getShortMessage()) + BDDAssertions + .then(GitTestUtils.openGitProject(file).log().call().iterator().next() + .getShortMessage()) .doesNotContain("Updating project page to release train"); } @Test - public void should_update_the_contents_of_spring_project_repo_when_release_train_greater() throws GitAPIException { - this.properties.getGit().setSpringProjectUrl(this.springCloudRepo.getAbsolutePath() + "/"); + public void should_update_the_contents_of_spring_project_repo_when_release_train_greater() + throws GitAPIException { + this.properties.getGit() + .setSpringProjectUrl(this.springCloudRepo.getAbsolutePath() + "/"); File file = this.updater.updateProjectRepo(newReleaseTrain()); BDDAssertions.then(file).isNotNull(); - BDDAssertions.then(GitTestUtils.openGitProject(file).log().call().iterator().next().getShortMessage()) + BDDAssertions + .then(GitTestUtils.openGitProject(file).log().call().iterator().next() + .getShortMessage()) .contains("Updating project page to release train [Edgware.SR7]"); } @@ -105,47 +139,59 @@ public class ReleaseTrainContentsUpdaterTests { } @Test - public void should_not_update_the_contents_of_wiki_repo_when_release_train_smaller() throws GitAPIException, IOException { + public void should_not_update_the_contents_of_wiki_repo_when_release_train_smaller() + throws GitAPIException, IOException { this.properties.getMetaRelease().setEnabled(true); - this.properties.getGit().setReleaseTrainWikiUrl(this.wikiRepo.getAbsolutePath() + "/"); + this.properties.getGit() + .setReleaseTrainWikiUrl(this.wikiRepo.getAbsolutePath() + "/"); File file = this.updater.updateReleaseTrainWiki(oldReleaseTrain()); BDDAssertions.then(file).isNotNull(); - BDDAssertions.then(edgwareWikiEntryContent(file)) - .doesNotContain("# Edgware.SR7") - .doesNotContain("Spring Cloud Consul `2.0.1.RELEASE` ([issues](http://foo.com))"); - BDDAssertions.then(GitTestUtils.openGitProject(file).log().call().iterator().next().getShortMessage()) + BDDAssertions.then(edgwareWikiEntryContent(file)).doesNotContain("# Edgware.SR7") + .doesNotContain( + "Spring Cloud Consul `2.0.1.RELEASE` ([issues](http://foo.com))"); + BDDAssertions + .then(GitTestUtils.openGitProject(file).log().call().iterator().next() + .getShortMessage()) .doesNotContain("Updating project page to release train"); } @Test - public void should_update_the_contents_of_wiki_when_release_train_greater() throws GitAPIException, IOException { + public void should_update_the_contents_of_wiki_when_release_train_greater() + throws GitAPIException, IOException { this.properties.getMetaRelease().setEnabled(true); - this.properties.getGit().setReleaseTrainWikiUrl(this.wikiRepo.getAbsolutePath() + "/"); + this.properties.getGit() + .setReleaseTrainWikiUrl(this.wikiRepo.getAbsolutePath() + "/"); File file = this.updater.updateReleaseTrainWiki(newReleaseTrain()); BDDAssertions.then(file).isNotNull(); - BDDAssertions.then(edgwareWikiEntryContent(file)) - .contains("# Edgware.SR7") - .contains("Spring Cloud Consul `2.0.1.RELEASE` ([issues](http://foo.com))"); - BDDAssertions.then(GitTestUtils.openGitProject(file).log().call().iterator().next().getShortMessage()) + BDDAssertions.then(edgwareWikiEntryContent(file)).contains("# Edgware.SR7") + .contains( + "Spring Cloud Consul `2.0.1.RELEASE` ([issues](http://foo.com))"); + BDDAssertions + .then(GitTestUtils.openGitProject(file).log().call().iterator().next() + .getShortMessage()) .contains("Updating project page to release train [Edgware.SR7]"); } @Test - public void should_generate_the_contents_of_wiki_when_release_train_missing() throws GitAPIException, IOException { + public void should_generate_the_contents_of_wiki_when_release_train_missing() + throws GitAPIException, IOException { this.properties.getMetaRelease().setEnabled(true); - this.properties.getGit().setReleaseTrainWikiUrl(this.wikiRepo.getAbsolutePath() + "/"); + this.properties.getGit() + .setReleaseTrainWikiUrl(this.wikiRepo.getAbsolutePath() + "/"); File file = this.updater.updateReleaseTrainWiki(freshNewReleaseTrain()); BDDAssertions.then(file).isNotNull(); BDDAssertions.then(greenwichWikiEntryContent(file)) - .contains("# Greenwich.RELEASE") - .contains("Spring Cloud Consul `2.0.1.RELEASE` ([issues](http://foo.com))"); - BDDAssertions.then(GitTestUtils.openGitProject(file).log().call().iterator().next().getShortMessage()) + .contains("# Greenwich.RELEASE").contains( + "Spring Cloud Consul `2.0.1.RELEASE` ([issues](http://foo.com))"); + BDDAssertions + .then(GitTestUtils.openGitProject(file).log().call().iterator().next() + .getShortMessage()) .contains("Updating project page to release train [Greenwich.RELEASE]"); } @@ -162,8 +208,7 @@ public class ReleaseTrainContentsUpdaterTests { } Projects oldReleaseTrain() { - return new Projects( - new ProjectVersion("spring-cloud-aws", "3.0.0.RELEASE"), + return new Projects(new ProjectVersion("spring-cloud-aws", "3.0.0.RELEASE"), new ProjectVersion("spring-cloud-bus", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-cli", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-commons", "2.0.1.RELEASE"), @@ -187,8 +232,7 @@ public class ReleaseTrainContentsUpdaterTests { } Projects newReleaseTrain() { - return new Projects( - new ProjectVersion("spring-cloud-aws", "3.0.0.RELEASE"), + return new Projects(new ProjectVersion("spring-cloud-aws", "3.0.0.RELEASE"), new ProjectVersion("spring-cloud-bus", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-cli", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-commons", "2.0.1.RELEASE"), @@ -212,8 +256,7 @@ public class ReleaseTrainContentsUpdaterTests { } Projects freshNewReleaseTrain() { - return new Projects( - new ProjectVersion("spring-cloud-aws", "3.0.0.RELEASE"), + return new Projects(new ProjectVersion("spring-cloud-aws", "3.0.0.RELEASE"), new ProjectVersion("spring-cloud-bus", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-cli", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-commons", "2.0.1.RELEASE"), @@ -235,4 +278,5 @@ public class ReleaseTrainContentsUpdaterTests { new ProjectVersion("spring-cloud-openfeign", "2.0.1.RELEASE"), new ProjectVersion("spring-cloud-function", "1.0.0.RELEASE")); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/RowTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/RowTests.java index 169c78f1..cc1277ba 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/RowTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/RowTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.util.List; @@ -17,8 +33,7 @@ public class RowTests { public void should_convert_projects_to_rows_for_last_ga() { Projects projects = new Projects( new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"), - new ProjectVersion("sc-release", "2.0.1.RELEASE") - ); + new ProjectVersion("sc-release", "2.0.1.RELEASE")); List rows = Row.fromProjects(projects, true); @@ -38,8 +53,7 @@ public class RowTests { public void should_convert_projects_to_rows_for_current_ga() { Projects projects = new Projects( new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"), - new ProjectVersion("sc-release", "2.0.1.RELEASE") - ); + new ProjectVersion("sc-release", "2.0.1.RELEASE")); List rows = Row.fromProjects(projects, false); @@ -54,4 +68,5 @@ public class RowTests { BDDAssertions.then(foo.currentGaVersion).isEmpty(); BDDAssertions.then(foo.currentSnapshotVersion).isEqualTo("1.0.0.BUILD-SNAPSHOT"); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/SpringCloudGhPagesParserTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/SpringCloudGhPagesParserTests.java index d5759d2c..6dfe714f 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/SpringCloudGhPagesParserTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/SpringCloudGhPagesParserTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.io.File; @@ -16,12 +32,12 @@ public class SpringCloudGhPagesParserTests { @Rule public OutputCapture capture = new OutputCapture(); - File rawHtml = new File(SpringCloudGhPagesParserTests.class.getResource( - "/raw/spring-cloud-gh-pages-index.html" - ).toURI()); - File wrongHtml = new File(SpringCloudGhPagesParserTests.class.getResource( - "/raw/some-file.html" - ).toURI()); + + File rawHtml = new File(SpringCloudGhPagesParserTests.class + .getResource("/raw/spring-cloud-gh-pages-index.html").toURI()); + + File wrongHtml = new File(SpringCloudGhPagesParserTests.class + .getResource("/raw/some-file.html").toURI()); public SpringCloudGhPagesParserTests() throws URISyntaxException { } @@ -33,28 +49,46 @@ public class SpringCloudGhPagesParserTests { BDDAssertions.then(contents).isNotNull(); BDDAssertions.then(contents.title).isEqualTo( - new Title("Edgware.SR5", "Finchley.SR1", "Finchley.BUILD-SNAPSHOT") - ); + new Title("Edgware.SR5", "Finchley.SR1", "Finchley.BUILD-SNAPSHOT")); BDDAssertions.then(contents.rows).contains( - new Row("spring-cloud-aws", "1.2.3.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-bus", "1.3.3.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-cli", "1.4.1.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-commons", "1.3.5.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-contract", "1.2.6.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-config", "1.4.5.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-netflix", "1.4.6.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-security", "1.2.3.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-cloudfoundry", "1.1.2.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-consul", "1.3.5.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-sleuth", "1.3.5.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-stream", "Ditmars.SR4", "Elmhurst.SR1", "Elmhurst.BUILD-SNAPSHOT"), - new Row("spring-cloud-zookeeper", "1.2.2.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-boot", "1.5.16.RELEASE", "2.0.4.RELEASE", "2.0.4.BUILD-SNAPSHOT"), - new Row("spring-cloud-task", "1.2.3.RELEASE", "2.0.0.RELEASE", "2.0.1.BUILD-SNAPSHOT"), - new Row("spring-cloud-vault", "1.1.2.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-gateway", "1.0.2.RELEASE", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-openfeign", "", "2.0.1.RELEASE", "2.0.2.BUILD-SNAPSHOT"), - new Row("spring-cloud-function", "1.0.1.RELEASE", "1.0.0.RELEASE", "1.0.1.BUILD-SNAPSHOT")); + new Row("spring-cloud-aws", "1.2.3.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-bus", "1.3.3.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-cli", "1.4.1.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-commons", "1.3.5.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-contract", "1.2.6.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-config", "1.4.5.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-netflix", "1.4.6.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-security", "1.2.3.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-cloudfoundry", "1.1.2.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-consul", "1.3.5.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-sleuth", "1.3.5.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-stream", "Ditmars.SR4", "Elmhurst.SR1", + "Elmhurst.BUILD-SNAPSHOT"), + new Row("spring-cloud-zookeeper", "1.2.2.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-boot", "1.5.16.RELEASE", "2.0.4.RELEASE", + "2.0.4.BUILD-SNAPSHOT"), + new Row("spring-cloud-task", "1.2.3.RELEASE", "2.0.0.RELEASE", + "2.0.1.BUILD-SNAPSHOT"), + new Row("spring-cloud-vault", "1.1.2.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-gateway", "1.0.2.RELEASE", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-openfeign", "", "2.0.1.RELEASE", + "2.0.2.BUILD-SNAPSHOT"), + new Row("spring-cloud-function", "1.0.1.RELEASE", "1.0.0.RELEASE", + "1.0.1.BUILD-SNAPSHOT")); } @Test @@ -66,4 +100,5 @@ public class SpringCloudGhPagesParserTests { BDDAssertions.then(this.capture.toString()) .contains("The page is missing the components table markers"); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GitRepoTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GitRepoTests.java index 6a1bf647..2164d528 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GitRepoTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GitRepoTests.java @@ -1,10 +1,20 @@ -package org.springframework.cloud.release.internal.git; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.assertj.core.api.Assertions.fail; -import static org.assertj.core.api.BDDAssertions.then; -import static org.assertj.core.api.BDDAssertions.thenThrownBy; -import static org.springframework.cloud.release.internal.git.GitTestUtils.clonedProject; -import static org.springframework.cloud.release.internal.git.GitTestUtils.setOriginOnProjectToTmp; +package org.springframework.cloud.release.internal.git; import java.io.File; import java.io.FileOutputStream; @@ -25,22 +35,34 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; + import org.springframework.cloud.release.internal.pom.TestUtils; +import static org.assertj.core.api.Assertions.fail; +import static org.assertj.core.api.BDDAssertions.then; +import static org.assertj.core.api.BDDAssertions.thenThrownBy; +import static org.springframework.cloud.release.internal.git.GitTestUtils.clonedProject; +import static org.springframework.cloud.release.internal.git.GitTestUtils.setOriginOnProjectToTmp; + /** * @author Marcin Grzejszczak */ public class GitRepoTests { - @Rule public TemporaryFolder tmp = new TemporaryFolder(); + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + File springCloudReleaseProject; + File tmpFolder; + GitRepo gitRepo; @Before public void setup() throws IOException, URISyntaxException { this.tmpFolder = this.tmp.newFolder(); - this.springCloudReleaseProject = new File(GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI()); + this.springCloudReleaseProject = new File( + GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI()); TestUtils.prepareLocalRepo(); this.gitRepo = new GitRepo(this.tmpFolder); } @@ -55,43 +77,44 @@ public class GitRepoTests { @Test public void should_throw_exception_when_there_is_no_repo() { - thenThrownBy(() -> this.gitRepo - .cloneProject(new URIish(GitRepoTests.class.getResource("/projects/").toURI().toURL()))) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("Exception occurred while cloning repo"); + thenThrownBy(() -> this.gitRepo.cloneProject( + new URIish(GitRepoTests.class.getResource("/projects/").toURI().toURL()))) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("Exception occurred while cloning repo"); } @Test public void should_throw_an_exception_when_failed_to_initialize_the_repo() { - thenThrownBy(() -> new GitRepo(this.tmpFolder, - new ExceptionThrowingJGitFactory()).cloneProject(new URIish(this.springCloudReleaseProject.toURI().toURL()))) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("Exception occurred while cloning repo") - .hasCauseInstanceOf(CustomException.class); + thenThrownBy(() -> new GitRepo(this.tmpFolder, new ExceptionThrowingJGitFactory()) + .cloneProject(new URIish(this.springCloudReleaseProject.toURI().toURL()))) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("Exception occurred while cloning repo") + .hasCauseInstanceOf(CustomException.class); } @Test public void should_check_out_a_branch_on_cloned_repo() throws IOException { URIish uri = new URIish(this.springCloudReleaseProject.toURI().toURL()); - File project = this.gitRepo - .cloneProject(uri); + File project = this.gitRepo.cloneProject(uri); new GitRepo(project).checkout("vCamden.SR3"); File pom = new File(new File(this.tmpFolder, uri.getHumanishName()), "pom.xml"); then(pom).exists(); - then(Files.lines(pom.toPath()).anyMatch(s -> s.contains("Camden.SR3"))).isTrue(); + then(Files.lines(pom.toPath()) + .anyMatch(s -> s.contains("Camden.SR3"))).isTrue(); } @Test public void should_check_out_a_branch_on_cloned_repo2() throws IOException { URIish uri = new URIish(this.springCloudReleaseProject.toURI().toURL()); - File project = this.gitRepo - .cloneProject(uri); + File project = this.gitRepo.cloneProject(uri); new GitRepo(project).checkout("Camden.x"); File pom = new File(new File(this.tmpFolder, uri.getHumanishName()), "pom.xml"); then(pom).exists(); - then(Files.lines(pom.toPath()).anyMatch(s -> s.contains("Camden.BUILD-SNAPSHOT"))).isTrue(); + then(Files.lines(pom.toPath()) + .anyMatch(s -> s.contains("Camden.BUILD-SNAPSHOT"))) + .isTrue(); } @Test @@ -111,13 +134,15 @@ public class GitRepoTests { } @Test - public void should_throw_an_exception_when_checking_out_nonexisting_branch() throws IOException { + public void should_throw_an_exception_when_checking_out_nonexisting_branch() + throws IOException { File project = new GitRepo(this.tmpFolder) .cloneProject(new URIish(this.springCloudReleaseProject.toURI().toURL())); try { new GitRepo(project).checkout("nonExistingBranch"); fail("should throw an exception"); - } catch (IllegalStateException e) { + } + catch (IllegalStateException e) { then(e).hasMessageContaining("Ref nonExistingBranch can not be resolved"); } } @@ -130,7 +155,7 @@ public class GitRepoTests { new GitRepo(project).commit("some message"); - try(Git git = openGitProject(project)) { + try (Git git = openGitProject(project)) { RevCommit revCommit = git.log().call().iterator().next(); then(revCommit.getShortMessage()).isEqualTo("some message"); } @@ -145,7 +170,7 @@ public class GitRepoTests { new GitRepo(project).commit("empty commit"); - try(Git git = openGitProject(project)) { + try (Git git = openGitProject(project)) { RevCommit revCommit = git.log().call().iterator().next(); then(revCommit.getShortMessage()).isNotEqualTo("empty commit"); } @@ -160,7 +185,7 @@ public class GitRepoTests { new GitRepo(project).tag("v1.0.0"); - try(Git git = openGitProject(project)) { + try (Git git = openGitProject(project)) { tagIsPresent(git, "v1.0.0"); } } @@ -168,7 +193,8 @@ public class GitRepoTests { private void tagIsPresent(Git git, String tag) throws GitAPIException { List refs = git.tagList().call(); System.out.println("All tags" + refs); - then(refs.stream().anyMatch(ref -> ref.getName().startsWith("refs/tags/" + tag))).isTrue(); + then(refs.stream().anyMatch(ref -> ref.getName().startsWith("refs/tags/" + tag))) + .isTrue(); } @Test @@ -182,7 +208,7 @@ public class GitRepoTests { new GitRepo(project).pushBranch("master"); - try(Git git = openGitProject(origin)) { + try (Git git = openGitProject(origin)) { RevCommit revCommit = git.log().call().iterator().next(); then(revCommit.getShortMessage()).isEqualTo("some message"); } @@ -199,7 +225,7 @@ public class GitRepoTests { new GitRepo(project).pushCurrentBranch(); - try(Git git = openGitProject(origin)) { + try (Git git = openGitProject(origin)) { RevCommit revCommit = git.log().call().iterator().next(); then(revCommit.getShortMessage()).isEqualTo("some message"); } @@ -230,7 +256,7 @@ public class GitRepoTests { new GitRepo(project).pushTag("v5.6.7.RELEASE"); - try(Git git = openGitProject(origin)) { + try (Git git = openGitProject(origin)) { tagIsPresent(git, "v5.6.7"); git.checkout().setName("v5.6.7.RELEASE").call(); RevCommit revCommit = git.log().call().iterator().next(); @@ -238,7 +264,6 @@ public class GitRepoTests { } } - private Git openGitProject(File project) { return new GitRepo.JGitFactory().open(project); } @@ -249,7 +274,7 @@ public class GitRepoTests { try (PrintStream out = new PrintStream(new FileOutputStream(newFile))) { out.print("foo"); } - try(Git git = openGitProject(project)) { + try (Git git = openGitProject(project)) { git.add().addFilepattern("newFile").call(); } } @@ -264,32 +289,37 @@ public class GitRepoTests { new GitRepo(project).revert("Reverting the commit"); - try(Git git = openGitProject(project)) { + try (Git git = openGitProject(project)) { RevCommit revCommit = git.log().call().iterator().next(); then(revCommit.getShortMessage()).isEqualTo("Reverting the commit"); } } @Test - public void should_not_revert_changes_when_commit_message_is_not_related_to_updating_snapshots() throws Exception { + public void should_not_revert_changes_when_commit_message_is_not_related_to_updating_snapshots() + throws Exception { File project = new GitRepo(this.tmpFolder) .cloneProject(new URIish(this.springCloudReleaseProject.toURI().toURL())); - BDDAssertions.thenThrownBy( - () -> new GitRepo(project).revert("some message")) - .hasMessageContaining("Won't revert the commit with id"); + BDDAssertions.thenThrownBy(() -> new GitRepo(project).revert("some message")) + .hasMessageContaining("Won't revert the commit with id"); } } class ExceptionThrowingJGitFactory extends GitRepo.JGitFactory { - @Override CloneCommand getCloneCommandByCloneRepository() { + + @Override + CloneCommand getCloneCommandByCloneRepository() { throw new CustomException("foo"); } + } class CustomException extends RuntimeException { - public CustomException(String message) { + + CustomException(String message) { super(message); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GitTestUtils.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GitTestUtils.java index 6ff8351a..06fbd1b7 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GitTestUtils.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GitTestUtils.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.File; @@ -17,7 +33,7 @@ public class GitTestUtils { public static void setOriginOnProjectToTmp(File origin, File project) throws GitAPIException, MalformedURLException { - try(Git git = openGitProject(project)) { + try (Git git = openGitProject(project)) { RemoteRemoveCommand remove = git.remoteRemove(); remove.setName("origin"); remove.call(); @@ -33,8 +49,10 @@ public class GitTestUtils { return new GitRepo.JGitFactory().open(project); } - public static File clonedProject(File baseDir, File projectToClone) throws IOException { + public static File clonedProject(File baseDir, File projectToClone) + throws IOException { GitRepo projectRepo = new GitRepo(baseDir); return projectRepo.cloneProject(new URIish(projectToClone.toURI().toURL())); } + } diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GithubIssuesTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GithubIssuesTests.java index 13457547..81beb234 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GithubIssuesTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GithubIssuesTests.java @@ -1,8 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.IOException; -import java.net.URISyntaxException; import java.util.Collections; + import javax.json.Json; import com.jcabi.github.Coordinates; @@ -29,13 +45,18 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; */ public class GithubIssuesTests { + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + + @Rule + public OutputCapture capture = new OutputCapture(); + MkGithub github; + Repo repo; - @Rule public TemporaryFolder folder = new TemporaryFolder(); - @Rule public OutputCapture capture = new OutputCapture(); @Before - public void setup() throws IOException { + public void setup() throws IOException { this.github = new MkGithub("spring-guides"); this.repo = createGettingStartedGuides(this.github); } @@ -45,9 +66,8 @@ public class GithubIssuesTests { Github github = BDDMockito.mock(Github.class); GithubIssues issues = new GithubIssues(github, withToken()); - issues.fileIssue(new Projects( - new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT") - ), new ProjectVersion("sc-release", "Edgware.BUILD-SNAPSHOT")); + issues.fileIssue(new Projects(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")), + new ProjectVersion("sc-release", "Edgware.BUILD-SNAPSHOT")); BDDMockito.then(github).shouldHaveZeroInteractions(); } @@ -59,11 +79,11 @@ public class GithubIssuesTests { properties.getGit().setUpdateSpringGuides(false); GithubIssues issues = new GithubIssues(github, properties); - issues.fileIssue(new Projects( - new ProjectVersion("foo", "1.0.0.RELEASE"), - new ProjectVersion("bar", "2.0.0.RELEASE"), - new ProjectVersion("baz", "3.0.0.RELEASE") - ), new ProjectVersion("sc-release", "Edgware.RELEASE")); + issues.fileIssue( + new Projects(new ProjectVersion("foo", "1.0.0.RELEASE"), + new ProjectVersion("bar", "2.0.0.RELEASE"), + new ProjectVersion("baz", "3.0.0.RELEASE")), + new ProjectVersion("sc-release", "Edgware.RELEASE")); BDDMockito.then(github).shouldHaveZeroInteractions(); } @@ -72,23 +92,23 @@ public class GithubIssuesTests { public void should_file_an_issue_for_release_version() throws IOException { GithubIssues issues = new GithubIssues(this.github, withToken()); - issues.fileIssue(new Projects( - new ProjectVersion("foo", "1.0.0.RELEASE"), - new ProjectVersion("bar", "2.0.0.RELEASE"), - new ProjectVersion("baz", "3.0.0.RELEASE") - ), new ProjectVersion("sc-release", "Edgware.RELEASE")); + issues.fileIssue( + new Projects(new ProjectVersion("foo", "1.0.0.RELEASE"), + new ProjectVersion("bar", "2.0.0.RELEASE"), + new ProjectVersion("baz", "3.0.0.RELEASE")), + new ProjectVersion("sc-release", "Edgware.RELEASE")); - then(this.capture.toString()).doesNotContain("Guide issue creation will occur only"); + then(this.capture.toString()) + .doesNotContain("Guide issue creation will occur only"); Issue issue = this.github.repos() .get(new Coordinates.Simple("spring-guides", "getting-started-guides")) .issues().get(1); then(issue.exists()).isTrue(); Issue.Smart smartIssue = new Issue.Smart(issue); - then(smartIssue.title()).isEqualTo("Edgware.RELEASE Spring Cloud Release took place"); - then(smartIssue.body()) - .contains("Spring Cloud [Edgware.RELEASE]") - .contains("foo : `1.0.0.RELEASE`") - .contains("bar : `2.0.0.RELEASE`") + then(smartIssue.title()) + .isEqualTo("Edgware.RELEASE Spring Cloud Release took place"); + then(smartIssue.body()).contains("Spring Cloud [Edgware.RELEASE]") + .contains("foo : `1.0.0.RELEASE`").contains("bar : `2.0.0.RELEASE`") .contains("baz : `3.0.0.RELEASE`"); } @@ -97,18 +117,14 @@ public class GithubIssuesTests { GithubIssues issues = new GithubIssues(new ReleaserProperties()); thenThrownBy(() -> issues.fileIssue(new Projects(Collections.emptySet()), - nonGaSleuthProject())) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("You have to pass Github OAuth token for milestone closing to be operational"); + nonGaSleuthProject())).isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining( + "You have to pass Github OAuth token for milestone closing to be operational"); } private Repo createGettingStartedGuides(MkGithub github) throws IOException { return github.repos().create( - Json.createObjectBuilder().add( - "name", - "getting-started-guides" - ).build() - ); + Json.createObjectBuilder().add("name", "getting-started-guides").build()); } private ProjectVersion nonGaSleuthProject() { @@ -121,4 +137,5 @@ public class GithubIssuesTests { properties.getPom().setBranch("vEdgware.RELEASE"); return properties; } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GithubMilestonesTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GithubMilestonesTests.java index 7ea88550..f8d481dc 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GithubMilestonesTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/GithubMilestonesTests.java @@ -1,7 +1,22 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.IOException; -import java.net.URISyntaxException; import java.net.URL; import javax.json.Json; @@ -26,13 +41,18 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; */ public class GithubMilestonesTests { + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + + @Rule + public OutputCapture capture = new OutputCapture(); + MkGithub github; + Repo repo; - @Rule public TemporaryFolder folder = new TemporaryFolder(); - @Rule public OutputCapture capture = new OutputCapture(); @Before - public void setup() throws IOException { + public void setup() throws IOException { this.github = new MkGithub(); this.repo = createSleuthRepo(this.github); } @@ -40,11 +60,13 @@ public class GithubMilestonesTests { @Test public void should_close_milestone_if_there_is_one() throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { - @Override String org() { + @Override + String org() { return GithubMilestonesTests.this.repo.coordinates().user(); } - @Override String milestoneTitle(Milestone.Smart milestone) { + @Override + String milestoneTitle(Milestone.Smart milestone) { return "0.2.0.BUILD-SNAPSHOT"; } }; @@ -56,13 +78,16 @@ public class GithubMilestonesTests { } @Test - public void should_close_milestone_when_the_milestone_contains_numeric_version_only_and_version_is_ga() throws IOException { + public void should_close_milestone_when_the_milestone_contains_numeric_version_only_and_version_is_ga() + throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { - @Override String org() { + @Override + String org() { return GithubMilestonesTests.this.repo.coordinates().user(); } - @Override String milestoneTitle(Milestone.Smart milestone) { + @Override + String milestoneTitle(Milestone.Smart milestone) { return "0.2.0"; } }; @@ -78,13 +103,16 @@ public class GithubMilestonesTests { } @Test - public void should_not_close_milestone_when_the_milestone_contains_numeric_version_only() throws IOException { + public void should_not_close_milestone_when_the_milestone_contains_numeric_version_only() + throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { - @Override String org() { + @Override + String org() { return GithubMilestonesTests.this.repo.coordinates().user(); } - @Override String milestoneTitle(Milestone.Smart milestone) { + @Override + String milestoneTitle(Milestone.Smart milestone) { return "0.2.0"; } }; @@ -98,49 +126,57 @@ public class GithubMilestonesTests { @Test public void should_fetch_url_of_a_closed_matching_milestone() throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { - @Override String org() { + @Override + String org() { return GithubMilestonesTests.this.repo.coordinates().user(); } - @Override String milestoneTitle(Milestone.Smart milestone) { + @Override + String milestoneTitle(Milestone.Smart milestone) { return "0.2.0.RELEASE"; } - @Override URL foundMilestoneUrl(Milestone.Smart milestone) - throws IOException { - return new URL("https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/milestones/33"); + @Override + URL foundMilestoneUrl(Milestone.Smart milestone) throws IOException { + return new URL( + "https://api.github.com/repos/spring-cloud/spring-cloud-sleuth/milestones/33"); } }; this.repo.milestones().create("0.2.0.RELEASE"); String url = milestones.milestoneUrl(gaSleuthProject()); - then(url).isEqualTo("https://github.com/spring-cloud/spring-cloud-sleuth/milestone/33?closed=1"); + then(url).isEqualTo( + "https://github.com/spring-cloud/spring-cloud-sleuth/milestone/33?closed=1"); } @Test public void should_fetch_url_of_a_closed_matching_milestone_from_cache() { GithubMilestones milestones = new GithubMilestones(this.github, withToken()); - GithubMilestones.MILESTONE_URL_CACHE.put(gaSleuthProject(), "https://github.com/spring-cloud/spring-cloud-sleuth/milestone/33?closed=1"); + GithubMilestones.MILESTONE_URL_CACHE.put(gaSleuthProject(), + "https://github.com/spring-cloud/spring-cloud-sleuth/milestone/33?closed=1"); String url = milestones.milestoneUrl(gaSleuthProject()); - then(url).isEqualTo("https://github.com/spring-cloud/spring-cloud-sleuth/milestone/33?closed=1"); + then(url).isEqualTo( + "https://github.com/spring-cloud/spring-cloud-sleuth/milestone/33?closed=1"); } @Test public void should_return_null_if_no_matching_milestone_was_found() { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { - @Override String org() { + @Override + String org() { return GithubMilestonesTests.this.repo.coordinates().user(); } - @Override String milestoneTitle(Milestone.Smart milestone) { + @Override + String milestoneTitle(Milestone.Smart milestone) { return "0.9.0.RELEASE"; } - @Override URL foundMilestoneUrl(Milestone.Smart milestone) - throws IOException { + @Override + URL foundMilestoneUrl(Milestone.Smart milestone) throws IOException { return new URL("http://foo.com/bar"); } }; @@ -151,13 +187,16 @@ public class GithubMilestonesTests { } @Test - public void should_return_null_if_no_matching_milestone_was_found_within_threshold() throws IOException { + public void should_return_null_if_no_matching_milestone_was_found_within_threshold() + throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withThreshold()) { - @Override String org() { + @Override + String org() { return GithubMilestonesTests.this.repo.coordinates().user(); } - @Override String milestoneTitle(Milestone.Smart milestone) { + @Override + String milestoneTitle(Milestone.Smart milestone) { return "0.2.0"; } }; @@ -165,7 +204,8 @@ public class GithubMilestonesTests { milestones.closeMilestone(gaSleuthProject()); - then(this.capture.toString()).contains("No matching milestones were found within the provided threshold [0]"); + then(this.capture.toString()).contains( + "No matching milestones were found within the provided threshold [0]"); } private ProjectVersion nonGaSleuthProject() { @@ -173,13 +213,16 @@ public class GithubMilestonesTests { } @Test - public void should_throw_exception_when_there_is_no_matching_milestone() throws IOException { + public void should_throw_exception_when_there_is_no_matching_milestone() + throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { - @Override String org() { + @Override + String org() { return GithubMilestonesTests.this.repo.coordinates().user(); } - @Override String milestoneTitle(Milestone.Smart milestone) { + @Override + String milestoneTitle(Milestone.Smart milestone) { return "0.1.0.BUILD-SNAPSHOT"; } }; @@ -190,14 +233,16 @@ public class GithubMilestonesTests { } @Test - public void should_print_that_no_milestones_were_found_when_io_problems_occurred() throws IOException { + public void should_print_that_no_milestones_were_found_when_io_problems_occurred() + throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { - @Override String org() { + @Override + String org() { return GithubMilestonesTests.this.repo.coordinates().user(); } - @Override String milestoneTitle(Milestone.Smart milestone) - throws IOException { + @Override + String milestoneTitle(Milestone.Smart milestone) throws IOException { throw new IOException("foo"); } }; @@ -210,11 +255,7 @@ public class GithubMilestonesTests { private Repo createSleuthRepo(MkGithub github) throws IOException { return github.repos().create( - Json.createObjectBuilder().add( - "name", - "spring-cloud-sleuth" - ).build() - ); + Json.createObjectBuilder().add("name", "spring-cloud-sleuth").build()); } @Test @@ -237,4 +278,5 @@ public class GithubMilestonesTests { properties.getGit().setNumberOfCheckedMilestones(0); return properties; } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/ProjectGitHandlerTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/ProjectGitHandlerTests.java index f677416f..11f79c8e 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/ProjectGitHandlerTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/git/ProjectGitHandlerTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.File; @@ -23,22 +39,29 @@ import static org.mockito.Mockito.never; @RunWith(MockitoJUnitRunner.class) public class ProjectGitHandlerTests { - @Mock GitRepo gitRepo; + @Mock + GitRepo gitRepo; + ReleaserProperties properties = new ReleaserProperties(); + ProjectGitHandler updater = new ProjectGitHandler(this.properties) { - @Override GitRepo gitRepo(File workingDir) { + @Override + GitRepo gitRepo(File workingDir) { return ProjectGitHandlerTests.this.gitRepo; } - @Override File cloneProject(String url) { + @Override + File cloneProject(String url) { return new File("."); } }; + File file = new File(""); @Test public void should_only_commit_without_pushing_changes_when_version_is_snapshot() { - this.updater.commitAndTagIfApplicable(this.file, projectVersion("1.0.0.BUILD-SNAPSHOT")); + this.updater.commitAndTagIfApplicable(this.file, + projectVersion("1.0.0.BUILD-SNAPSHOT")); then(this.gitRepo).should().commit(eq("Bumping versions")); then(this.gitRepo).should(never()).tag(anyString()); @@ -55,15 +78,18 @@ public class ProjectGitHandlerTests { @Test public void should_commit_when_snapshot_version_is_present_with_post_release_msg() { - this.updater.commitAfterBumpingVersions(this.file, projectVersion("1.0.0.BUILD-SNAPSHOT")); + this.updater.commitAfterBumpingVersions(this.file, + projectVersion("1.0.0.BUILD-SNAPSHOT")); - then(this.gitRepo).should().commit(eq("Bumping versions to 1.0.1.BUILD-SNAPSHOT after release")); + then(this.gitRepo).should() + .commit(eq("Bumping versions to 1.0.1.BUILD-SNAPSHOT after release")); then(this.gitRepo).should(never()).tag(anyString()); } @Test public void should_not_commit_when_non_snapshot_version_is_present() { - this.updater.commitAfterBumpingVersions(this.file, projectVersion("1.0.0.RELEASE")); + this.updater.commitAfterBumpingVersions(this.file, + projectVersion("1.0.0.RELEASE")); then(this.gitRepo).should(never()).commit(eq("Bumping versions after release")); then(this.gitRepo).should(never()).tag(anyString()); @@ -71,14 +97,16 @@ public class ProjectGitHandlerTests { @Test public void should_not_revert_changes_for_snapshots() { - this.updater.revertChangesIfApplicable(this.file, projectVersion("1.0.0.BUILD-SNAPSHOT")); + this.updater.revertChangesIfApplicable(this.file, + projectVersion("1.0.0.BUILD-SNAPSHOT")); then(this.gitRepo).should(never()).revert(anyString()); } @Test public void should_revert_changes_when_version_is_not_snapshot() { - this.updater.revertChangesIfApplicable(this.file, projectVersion("1.0.0.RELEASE")); + this.updater.revertChangesIfApplicable(this.file, + projectVersion("1.0.0.RELEASE")); then(this.gitRepo).should().revert(eq("Going back to snapshots")); } @@ -92,10 +120,11 @@ public class ProjectGitHandlerTests { @Test public void should_throw_exception_when_no_fixed_version_passed_for_the_project() { - BDDAssertions.thenThrownBy(() -> this.updater - .cloneProjectFromOrg("spring-cloud-sleuth")) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("You haven't provided a version"); + BDDAssertions + .thenThrownBy( + () -> this.updater.cloneProjectFromOrg("spring-cloud-sleuth")) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("You haven't provided a version"); } @Test @@ -136,7 +165,8 @@ public class ProjectGitHandlerTests { given(this.gitRepo.hasBranch(anyString())).willReturn(true); given(this.gitRepo.hasBranch("2.3.x")).willReturn(false); - this.updater.cloneAndGuessBranch(new File(".").getAbsolutePath(), "2.3.4.RELEASE"); + this.updater.cloneAndGuessBranch(new File(".").getAbsolutePath(), + "2.3.4.RELEASE"); then(this.gitRepo).should(never()).checkout("2.3.x"); } @@ -146,7 +176,8 @@ public class ProjectGitHandlerTests { given(this.gitRepo.hasBranch(anyString())).willReturn(false); given(this.gitRepo.hasBranch("2.3.x")).willReturn(true); - this.updater.cloneAndGuessBranch(new File(".").getAbsolutePath(), "2.3.4.RELEASE"); + this.updater.cloneAndGuessBranch(new File(".").getAbsolutePath(), + "2.3.4.RELEASE"); then(this.gitRepo).should().checkout("2.3.x"); } @@ -156,7 +187,7 @@ public class ProjectGitHandlerTests { given(this.gitRepo.hasBranch(anyString())).willReturn(false); given(this.gitRepo.hasBranch("Finchley")).willReturn(true); - this.updater.cloneAndGuessBranch(new File(".").getAbsolutePath(), "Finchley.SR6"); + this.updater.cloneAndGuessBranch(new File(".").getAbsolutePath(), "Finchley.SR6"); then(this.gitRepo).should().checkout("Finchley"); } @@ -166,7 +197,8 @@ public class ProjectGitHandlerTests { given(this.gitRepo.hasBranch(anyString())).willReturn(false); given(this.gitRepo.hasBranch("Finchley")).willReturn(true); - this.updater.cloneAndGuessBranch(new File(".").getAbsolutePath(), "2.0.0.RELEASE", "Finchley.SR6"); + this.updater.cloneAndGuessBranch(new File(".").getAbsolutePath(), "2.0.0.RELEASE", + "Finchley.SR6"); then(this.gitRepo).should(never()).checkout("2.0.0"); then(this.gitRepo).should().checkout("Finchley"); @@ -175,4 +207,5 @@ public class ProjectGitHandlerTests { private ProjectVersion projectVersion(String version) { return new ProjectVersion("foo", version); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/gradle/GradleUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/gradle/GradleUpdaterTests.java index b5acf760..f3a5276c 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/gradle/GradleUpdaterTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/gradle/GradleUpdaterTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.gradle; import java.io.File; @@ -24,7 +40,10 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; * @author Marcin Grzejszczak */ public class GradleUpdaterTests { - @Rule public TemporaryFolder tmp = new TemporaryFolder(); + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + File temporaryFolder; @Before @@ -37,21 +56,21 @@ public class GradleUpdaterTests { public void should_substitute_values_in_gradle_properties() throws IOException { File projectRoot = tmpFile("gradleproject"); ReleaserProperties properties = new ReleaserProperties(); - Map props = new HashMap() {{ - put("foo", "spring-cloud-contract"); - put("bar", "spring-cloud-sleuth"); - }}; + Map props = new HashMap() { + { + put("foo", "spring-cloud-contract"); + put("bar", "spring-cloud-sleuth"); + } + }; properties.getGradle().setGradlePropsSubstitution(props); Projects projects = new Projects( new ProjectVersion("spring-cloud-contract", "1.0.0"), - new ProjectVersion("spring-cloud-sleuth", "2.0.0") - ); + new ProjectVersion("spring-cloud-sleuth", "2.0.0")); - new GradleUpdater(properties).updateProjectFromBom(projectRoot, - projects, new ProjectVersion("spring-cloud-contract", "1.0.0"), true); + new GradleUpdater(properties).updateProjectFromBom(projectRoot, projects, + new ProjectVersion("spring-cloud-contract", "1.0.0"), true); - then(asString(tmpFile("gradleproject/gradle.properties"))) - .contains("foo=1.0.0"); + then(asString(tmpFile("gradleproject/gradle.properties"))).contains("foo=1.0.0"); then(asString(tmpFile("gradleproject/child/gradle.properties"))) .contains("bar=2.0.0"); } @@ -60,19 +79,21 @@ public class GradleUpdaterTests { public void should_throw_exception_if_snapshots_remain() { File projectRoot = tmpFile("gradleproject"); ReleaserProperties properties = new ReleaserProperties(); - Map props = new HashMap() {{ - put("foo", "spring-cloud-contract"); - put("bar", "spring-cloud-sleuth"); - }}; + Map props = new HashMap() { + { + put("foo", "spring-cloud-contract"); + put("bar", "spring-cloud-sleuth"); + } + }; properties.getGradle().setGradlePropsSubstitution(props); Projects projects = new Projects( new ProjectVersion("spring-cloud-contract", "1.0.0.BUILD-SNAPSHOT"), - new ProjectVersion("spring-cloud-sleuth", "2.0.0") - ); + new ProjectVersion("spring-cloud-sleuth", "2.0.0")); thenThrownBy(() -> new GradleUpdater(properties).updateProjectFromBom(projectRoot, - projects, new ProjectVersion("spring-cloud-contract", "1.0.0.RELEASE"), true)) - .hasMessageContaining("matches the [ ^.*\\.(BUILD-)?SNAPSHOT.*$] pattern in line number [1]"); + projects, new ProjectVersion("spring-cloud-contract", "1.0.0.RELEASE"), + true)).hasMessageContaining( + "matches the [ ^.*\\.(BUILD-)?SNAPSHOT.*$] pattern in line number [1]"); } private File file(String relativePath) throws URISyntaxException { @@ -86,4 +107,5 @@ public class GradleUpdaterTests { private String asString(File file) throws IOException { return new String(Files.readAllBytes(file.toPath())); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/BomParserTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/BomParserTests.java index 1f5d3fd5..8050f720 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/BomParserTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/BomParserTests.java @@ -1,7 +1,22 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; -import java.io.IOException; import java.net.URISyntaxException; import org.junit.Before; @@ -19,19 +34,20 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; public class BomParserTests { File springCloudReleaseProject; + ReleaserProperties properties = new ReleaserProperties(); @Before public void setup() throws URISyntaxException { - this.springCloudReleaseProject = new File(GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI()); + this.springCloudReleaseProject = new File( + GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI()); } @Test public void should_throw_exception_when_boot_pom_is_missing() { BomParser parser = new BomParser(this.properties, new File(".")); - thenThrownBy(parser::bootVersion) - .isInstanceOf(IllegalStateException.class) + thenThrownBy(parser::bootVersion).isInstanceOf(IllegalStateException.class) .hasMessageContaining("Pom is not present"); } @@ -41,8 +57,7 @@ public class BomParserTests { this.properties.getPom().setThisTrainBom(null); BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); - thenThrownBy(parser::bootVersion) - .isInstanceOf(IllegalStateException.class) + thenThrownBy(parser::bootVersion).isInstanceOf(IllegalStateException.class) .hasMessageContaining("Pom is not present"); } @@ -52,16 +67,17 @@ public class BomParserTests { this.properties.getPom().setThisTrainBom(null); BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); - thenThrownBy(parser::bootVersion) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("The pom doesn't have a [spring-boot-starter-parent] artifact id"); + thenThrownBy(parser::bootVersion).isInstanceOf(IllegalStateException.class) + .hasMessageContaining( + "The pom doesn't have a [spring-boot-starter-parent] artifact id"); } @Test public void should_populate_sc_release_version() { BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); - String scReleaseVersion = parser.allVersions().versionForProject("spring-cloud-release"); + String scReleaseVersion = parser.allVersions() + .versionForProject("spring-cloud-release"); then(scReleaseVersion).isEqualTo("Dalston.BUILD-SNAPSHOT"); } @@ -79,8 +95,7 @@ public class BomParserTests { public void should_throw_exception_when_cloud_pom_is_missing() { BomParser parser = new BomParser(this.properties, new File(".")); - thenThrownBy(parser::versionsFromBom) - .isInstanceOf(IllegalStateException.class) + thenThrownBy(parser::versionsFromBom).isInstanceOf(IllegalStateException.class) .hasMessageContaining("Pom is not present"); } @@ -90,8 +105,7 @@ public class BomParserTests { this.properties.getPom().setThisTrainBom(null); BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); - thenThrownBy(parser::versionsFromBom) - .isInstanceOf(IllegalStateException.class) + thenThrownBy(parser::versionsFromBom).isInstanceOf(IllegalStateException.class) .hasMessageContaining("Pom is not present"); } @@ -101,9 +115,9 @@ public class BomParserTests { this.properties.getPom().setThisTrainBom("pom.xml"); BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); - thenThrownBy(parser::versionsFromBom) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("The pom doesn't have a [spring-cloud-dependencies-parent] artifact id"); + thenThrownBy(parser::versionsFromBom).isInstanceOf(IllegalStateException.class) + .hasMessageContaining( + "The pom doesn't have a [spring-cloud-dependencies-parent] artifact id"); } @Test @@ -147,4 +161,5 @@ public class BomParserTests { Project project(String name, String value) { return new Project(name, value); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/LoggerToMavenLogTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/LoggerToMavenLogTests.java index e1b5ae86..10ef905c 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/LoggerToMavenLogTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/LoggerToMavenLogTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import org.junit.Test; @@ -15,104 +31,124 @@ import static org.mockito.BDDMockito.then; @RunWith(MockitoJUnitRunner.class) public class LoggerToMavenLogTests { - @Mock Logger logger; - @InjectMocks LoggerToMavenLog loggerToMavenLog; + @Mock + Logger logger; + + @InjectMocks + LoggerToMavenLog loggerToMavenLog; + RuntimeException exception = new RuntimeException(); - @Test public void isDebugEnabled() { + @Test + public void isDebugEnabled() { this.loggerToMavenLog.isDebugEnabled(); then(this.logger).should().isDebugEnabled(); } - @Test public void debug() { + @Test + public void debug() { this.loggerToMavenLog.debug("foo"); then(this.logger).should().debug("foo"); } - @Test public void debug1() { + @Test + public void debug1() { this.loggerToMavenLog.debug("foo", this.exception); then(this.logger).should().debug("foo", this.exception); } - @Test public void debug2() { + @Test + public void debug2() { this.loggerToMavenLog.debug(this.exception); then(this.logger).should().debug("Exception occurred", this.exception); } - @Test public void isInfoEnabled() { + @Test + public void isInfoEnabled() { this.loggerToMavenLog.isInfoEnabled(); then(this.logger).should().isInfoEnabled(); } - @Test public void info() { + @Test + public void info() { this.loggerToMavenLog.info("foo"); then(this.logger).should().info("foo"); } - @Test public void info1() { + @Test + public void info1() { this.loggerToMavenLog.info("foo", this.exception); then(this.logger).should().info("foo", this.exception); } - @Test public void info2() { + @Test + public void info2() { this.loggerToMavenLog.info(this.exception); then(this.logger).should().info("Exception occurred", this.exception); } - @Test public void isWarnEnabled() { + @Test + public void isWarnEnabled() { this.loggerToMavenLog.isWarnEnabled(); then(this.logger).should().isWarnEnabled(); } - @Test public void warn() { + @Test + public void warn() { this.loggerToMavenLog.warn("foo"); then(this.logger).should().warn("foo"); } - @Test public void warn1() { + @Test + public void warn1() { this.loggerToMavenLog.warn("foo", this.exception); then(this.logger).should().warn("foo", this.exception); } - @Test public void warn2() { + @Test + public void warn2() { this.loggerToMavenLog.warn(this.exception); then(this.logger).should().warn("Exception occurred", this.exception); } - @Test public void isErrorEnabled() { + @Test + public void isErrorEnabled() { this.loggerToMavenLog.isErrorEnabled(); then(this.logger).should().isErrorEnabled(); } - @Test public void error() { + @Test + public void error() { this.loggerToMavenLog.error("foo"); then(this.logger).should().error("foo"); } - @Test public void error1() { + @Test + public void error1() { this.loggerToMavenLog.error("foo", this.exception); then(this.logger).should().error("foo", this.exception); } - @Test public void error2() { + @Test + public void error2() { this.loggerToMavenLog.error(this.exception); then(this.logger).should().error("Exception occurred", this.exception); } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PomReaderTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PomReaderTests.java index aae406e3..59f8ed97 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PomReaderTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PomReaderTests.java @@ -1,17 +1,33 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.springframework.cloud.release.internal.pom; @@ -25,6 +41,7 @@ import org.apache.maven.model.Model; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.junit.Before; import org.junit.Test; + import org.springframework.cloud.release.internal.git.GitRepoTests; import static org.assertj.core.api.BDDAssertions.then; @@ -36,17 +53,23 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; public class PomReaderTests { PomReader pomReader = new PomReader(); + File springCloudReleaseProjectPom; + File springCloudReleaseProject; + File empty; + File licenseFile; @Before public void setup() throws URISyntaxException { - URI scRelease = GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI(); + URI scRelease = GitRepoTests.class.getResource("/projects/spring-cloud-release") + .toURI(); this.springCloudReleaseProject = new File(scRelease); this.springCloudReleaseProjectPom = new File(scRelease.getPath(), "pom.xml"); - this.empty = new File(GitRepoTests.class.getResource("/projects/project/empty.xml").toURI()); + this.empty = new File( + GitRepoTests.class.getResource("/projects/project/empty.xml").toURI()); this.licenseFile = new File(scRelease.getPath(), "LICENSE.txt"); } @@ -81,8 +104,8 @@ public class PomReaderTests { @Test public void should_throw_exception_when_file_is_empty() { thenThrownBy(() -> this.pomReader.readPom(this.empty)) - .hasMessageStartingWith("File [") - .hasMessageContaining("] is empty") + .hasMessageStartingWith("File [").hasMessageContaining("] is empty") .hasCauseInstanceOf(EOFException.class); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PomUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PomUpdaterTests.java index 5b5b56bf..6ad91edf 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PomUpdaterTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PomUpdaterTests.java @@ -1,17 +1,33 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.springframework.cloud.release.internal.pom; @@ -29,6 +45,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; + import org.springframework.boot.test.rule.OutputCapture; import org.springframework.cloud.release.internal.git.GitRepoTests; import org.springframework.util.FileSystemUtils; @@ -38,11 +55,18 @@ import org.springframework.util.FileSystemUtils; */ public class PomUpdaterTests { + @Rule + public OutputCapture capture = new OutputCapture(); + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + Versions versions = new Versions("0.0.1", "0.0.2", projects()); + PomUpdater pomUpdater = new PomUpdater(); + PomReader pomReader = new PomReader(); - @Rule public OutputCapture capture = new OutputCapture(); - @Rule public TemporaryFolder tmp = new TemporaryFolder(); + File temporaryFolder; @Before @@ -52,41 +76,51 @@ public class PomUpdaterTests { } @Test - public void should_not_update_pom_when_project_is_not_on_the_versions_list() throws Exception { + public void should_not_update_pom_when_project_is_not_on_the_versions_list() + throws Exception { File springCloudReleasePom = file("/projects/spring-cloud-release"); - BDDAssertions - .then(this.pomUpdater.shouldProjectBeUpdated(springCloudReleasePom, this.versions)).isFalse(); + BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudReleasePom, + this.versions)).isFalse(); } @Test - public void should_not_update_pom_when_project_with_parent_suffix_is_not_on_the_versions_list() throws Exception { + public void should_not_update_pom_when_project_with_parent_suffix_is_not_on_the_versions_list() + throws Exception { File springCloud = pom("/projects/project", "pom_with_parent_suffix.xml"); - BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloud, this.versions)).isFalse(); + BDDAssertions + .then(this.pomUpdater.shouldProjectBeUpdated(springCloud, this.versions)) + .isFalse(); } @Test - public void should_update_pom_for_project_with_suffix_when_project_is_on_the_versions_list() throws Exception { - File springCloud = pom("/projects/project", "pom_matching_with_parent_suffix.xml"); + public void should_update_pom_for_project_with_suffix_when_project_is_on_the_versions_list() + throws Exception { + File springCloud = pom("/projects/project", + "pom_matching_with_parent_suffix.xml"); - BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloud, this.versions)).isTrue(); + BDDAssertions + .then(this.pomUpdater.shouldProjectBeUpdated(springCloud, this.versions)) + .isTrue(); } @Test - public void should_update_pom_when_project_is_not_on_the_versions_list() throws Exception { + public void should_update_pom_when_project_is_not_on_the_versions_list() + throws Exception { File springCloudSleuthPom = file("/projects/spring-cloud-sleuth"); - BDDAssertions - .then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom, this.versions)).isTrue(); + BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom, + this.versions)).isTrue(); } @Test - public void should_not_update_pom_when_project_is_on_the_versions_list_but_there_is_no_pom() throws Exception { + public void should_not_update_pom_when_project_is_on_the_versions_list_but_there_is_no_pom() + throws Exception { File springCloudSleuthPom = file("/projects/spring-cloud-sleuth/empty-folder"); - BDDAssertions - .then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom, this.versions)).isFalse(); + BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom, + this.versions)).isFalse(); } @Test @@ -94,86 +128,110 @@ public class PomUpdaterTests { File originalPom = pom("/projects/project"); File pomInTemp = tmpFile("/project/pom.xml"); ModelWrapper rootPom = model("foo"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isEqualTo(asString(originalPom)); } @Test - public void should_update_the_pom_if_only_artifact_id_is_matched_in_the_root_pom() throws Exception { + public void should_update_the_pom_if_only_artifact_id_is_matched_in_the_root_pom() + throws Exception { File originalPom = pom("/projects/project", "pom_matching_artifact.xml"); File pomInTemp = tmpFile("/project/pom_matching_artifact.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); } @Test - public void should_update_the_pom_if_parent_is_matched_via_sc_build() throws Exception { + public void should_update_the_pom_if_parent_is_matched_via_sc_build() + throws Exception { File originalPom = pom("/projects/project", "pom_matching_parent_v2.xml"); File pomInTemp = tmpFile("/project/pom_matching_parent_v2.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(originalPom)).isNotEqualTo(asString(storedPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.2"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.2"); } @Test - public void should_update_the_pom_if_parent_is_matched_via_sc_dependencies_parent() throws Exception { + public void should_update_the_pom_if_parent_is_matched_via_sc_dependencies_parent() + throws Exception { File originalPom = pom("/projects/project", "pom_matching_parent.xml"); File pomInTemp = tmpFile("/project/pom_matching_parent.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.2"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.2"); } @Test - public void should_not_update_child_pom_when_project_is_not_on_the_versions_list() throws Exception { + public void should_not_update_child_pom_when_project_is_not_on_the_versions_list() + throws Exception { File springCloudReleasePom = file("/projects/spring-cloud-release"); - BDDAssertions - .then(this.pomUpdater.shouldProjectBeUpdated(springCloudReleasePom, this.versions)).isFalse(); + BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudReleasePom, + this.versions)).isFalse(); } @Test - public void should_update_child_pom_when_project_is_not_on_the_versions_list() throws Exception { + public void should_update_child_pom_when_project_is_not_on_the_versions_list() + throws Exception { File springCloudSleuthPom = file("/projects/spring-cloud-sleuth"); - BDDAssertions - .then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom, this.versions)).isTrue(); + BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom, + this.versions)).isTrue(); } @Test - public void should_update_the_child_pom_if_parent_is_matched_via_sc_build() throws Exception { - File originalPom = pom("/projects/project/children", "pom_matching_parent_v2.xml"); + public void should_update_the_child_pom_if_parent_is_matched_via_sc_build() + throws Exception { + File originalPom = pom("/projects/project/children", + "pom_matching_parent_v2.xml"); File pomInTemp = tmpFile("/project/children/pom_matching_parent_v2.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); // the rest is the same BDDAssertions.then(overriddenPomModel.getProperties()) .containsEntry("spring-cloud-foo.version", "1.3.1.BUILD-SNAPSHOT") @@ -181,122 +239,165 @@ public class PomUpdaterTests { } @Test - public void should_update_the_parent_from_properties_even_if_group_ids_dont_match() throws Exception { - File originalPom = pom("/projects/project/children", "pom_different_group_boot_parent.xml"); + public void should_update_the_parent_from_properties_even_if_group_ids_dont_match() + throws Exception { + File originalPom = pom("/projects/project/children", + "pom_different_group_boot_parent.xml"); File pomInTemp = tmpFile("/project/children/pom_different_group_boot_parent.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.1"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.1"); BDDAssertions.then(overriddenPomModel.getProperties()) .containsEntry("spring-cloud-sleuth.version", "0.0.3.BUILD-SNAPSHOT"); } @Test - public void should_only_update_the_properties_section_when_group_ids_dont_match_and_there_is_no_skip_deployment() throws Exception { + public void should_only_update_the_properties_section_when_group_ids_dont_match_and_there_is_no_skip_deployment() + throws Exception { File originalPom = pom("/projects/project/children", "pom_different_group.xml"); File pomInTemp = tmpFile("/project/children/pom_different_group.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("1.2.2.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("1.5.8.RELEASE"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("1.2.2.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("1.5.8.RELEASE"); // the rest is the same BDDAssertions.then(overriddenPomModel.getProperties()) .containsEntry("spring-cloud-sleuth.version", "0.0.3.BUILD-SNAPSHOT"); } @Test - public void should_update_everything_when_group_ids_dont_match_and_there_is_skip_deployment_property() throws Exception { - File originalPom = pom("/projects/project/children", "pom_different_group_skip_deployment_prop.xml"); - File pomInTemp = tmpFile("/project/children/pom_different_group_skip_deployment_prop.xml"); + public void should_update_everything_when_group_ids_dont_match_and_there_is_skip_deployment_property() + throws Exception { + File originalPom = pom("/projects/project/children", + "pom_different_group_skip_deployment_prop.xml"); + File pomInTemp = tmpFile( + "/project/children/pom_different_group_skip_deployment_prop.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("1.2.2.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.1"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("1.2.2.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.1"); // the rest is the same BDDAssertions.then(overriddenPomModel.getProperties()) .containsEntry("spring-cloud-sleuth.version", "0.0.3.BUILD-SNAPSHOT"); } @Test - public void should_update_everything_when_group_ids_dont_match_and_there_is_skip_in_deployment_plugin() throws Exception { - File originalPom = pom("/projects/project/children", "pom_different_group_skip_deployment_plugin.xml"); - File pomInTemp = tmpFile("/project/children/pom_different_group_skip_deployment_plugin.xml"); + public void should_update_everything_when_group_ids_dont_match_and_there_is_skip_in_deployment_plugin() + throws Exception { + File originalPom = pom("/projects/project/children", + "pom_different_group_skip_deployment_plugin.xml"); + File pomInTemp = tmpFile( + "/project/children/pom_different_group_skip_deployment_plugin.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("1.2.2.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.1"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("1.2.2.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.1"); // the rest is the same BDDAssertions.then(overriddenPomModel.getProperties()) .containsEntry("spring-cloud-sleuth.version", "0.0.3.BUILD-SNAPSHOT"); } @Test - public void should_update_everything_when_group_ids_dont_match_and_there_is_skip_in_deployment_plugin_management() throws Exception { - File originalPom = pom("/projects/project/children", "pom_different_group_skip_deployment_plugin_mngmnt.xml"); - File pomInTemp = tmpFile("/project/children/pom_different_group_skip_deployment_plugin_mngmnt.xml"); + public void should_update_everything_when_group_ids_dont_match_and_there_is_skip_in_deployment_plugin_management() + throws Exception { + File originalPom = pom("/projects/project/children", + "pom_different_group_skip_deployment_plugin_mngmnt.xml"); + File pomInTemp = tmpFile( + "/project/children/pom_different_group_skip_deployment_plugin_mngmnt.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("1.2.2.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.1"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("1.2.2.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.1"); // the rest is the same BDDAssertions.then(overriddenPomModel.getProperties()) .containsEntry("spring-cloud-sleuth.version", "0.0.3.BUILD-SNAPSHOT"); } @Test - public void should_update_boot_parent_even_if_the_project_group_doesnt_match() throws Exception { - File originalPom = pom("/projects/project/children", "pom_case_from_contract.xml"); + public void should_update_boot_parent_even_if_the_project_group_doesnt_match() + throws Exception { + File originalPom = pom("/projects/project/children", + "pom_case_from_contract.xml"); File pomInTemp = tmpFile("/project/children/pom_case_from_contract.xml"); - ModelWrapper rootPom = model("spring-cloud-contract", "org.springframework.cloud"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper rootPom = model("spring-cloud-contract", + "org.springframework.cloud"); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.1"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.1"); } @Test - public void should_update_the_child_pom_if_parent_is_matched_via_sc_dependencies_parent() throws Exception { + public void should_update_the_child_pom_if_parent_is_matched_via_sc_dependencies_parent() + throws Exception { File originalPom = pom("/projects/project/children", "pom_matching_parent.xml"); File pomInTemp = tmpFile("/project/children/pom_matching_parent.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); // the rest is the same BDDAssertions.then(overriddenPomModel.getProperties()) .containsEntry("spring-cloud-foo.version", "1.3.1.BUILD-SNAPSHOT") @@ -305,29 +406,38 @@ public class PomUpdaterTests { @Test public void should_update_the_child_pom_if_properties_are_matched() throws Exception { - File originalPom = pom("/projects/project/children", "pom_matching_properties.xml"); + File originalPom = pom("/projects/project/children", + "pom_matching_properties.xml"); File pomInTemp = tmpFile("/project/children/pom_matching_properties.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.3.BUILD-SNAPSHOT"); BDDAssertions.then(overriddenPomModel.getProperties()) .containsEntry("spring-cloud-sleuth.version", "0.0.3.BUILD-SNAPSHOT") .containsEntry("spring-cloud-vault.version", "0.0.4.BUILD-SNAPSHOT"); } @Test - public void should_override_a_pom_when_there_was_a_change_in_the_model() throws Exception { - File beforeProcessing = pom("/projects/project/children", "pom_matching_properties.xml"); + public void should_override_a_pom_when_there_was_a_change_in_the_model() + throws Exception { + File beforeProcessing = pom("/projects/project/children", + "pom_matching_properties.xml"); File afterProcessing = tmpFile("/project/children/pom_matching_properties.xml"); - ModelWrapper model = this.pomUpdater.updateModel(model("spring-cloud-sleuth"), afterProcessing, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(model("spring-cloud-sleuth"), + afterProcessing, this.versions); - File processedPom = this.pomUpdater.overwritePomIfDirty(model, Versions.EMPTY_VERSION, afterProcessing); + File processedPom = this.pomUpdater.overwritePomIfDirty(model, + Versions.EMPTY_VERSION, afterProcessing); String processedPomText = asString(processedPom); String beforeProcessingText = asString(beforeProcessing); @@ -335,39 +445,51 @@ public class PomUpdaterTests { } @Test - public void should_not_override_a_pom_when_there_was_no_change_in_the_model() throws Exception { + public void should_not_override_a_pom_when_there_was_no_change_in_the_model() + throws Exception { File beforeProcessing = pom("/projects/project/"); File afterProcessing = tmpFile("/project/pom.xml"); - ModelWrapper model = this.pomUpdater.updateModel(model("foo"), afterProcessing, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(model("foo"), afterProcessing, + this.versions); - File processedPom = this.pomUpdater.overwritePomIfDirty(model, Versions.EMPTY_VERSION, afterProcessing); + File processedPom = this.pomUpdater.overwritePomIfDirty(model, + Versions.EMPTY_VERSION, afterProcessing); BDDAssertions.then(asString(processedPom)).isEqualTo(asString(beforeProcessing)); } @Test - public void should_update_the_model_when_root_project_has_parent_suffix() throws Exception { + public void should_update_the_model_when_root_project_has_parent_suffix() + throws Exception { File originalPom = pom("/projects/spring-cloud-contract"); File pomInTemp = tmpFile("/spring-cloud-contract/pom.xml"); ModelWrapper rootPom = model("spring-cloud-contract-parent"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom)); Model overriddenPomModel = this.pomReader.readPom(storedPom); - BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("0.0.2.BUILD-SNAPSHOT"); - BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("0.0.2"); + BDDAssertions.then(overriddenPomModel.getVersion()) + .isEqualTo("0.0.2.BUILD-SNAPSHOT"); + BDDAssertions.then(overriddenPomModel.getParent().getVersion()) + .isEqualTo("0.0.2"); } @Test - public void should_not_update_the_model_when_project_uses_same_version_for_artifact() throws Exception { - File originalPom = pom("/projects/project/", "pom_matching_artifact_same_version.xml"); + public void should_not_update_the_model_when_project_uses_same_version_for_artifact() + throws Exception { + File originalPom = pom("/projects/project/", + "pom_matching_artifact_same_version.xml"); File pomInTemp = tmpFile("/project/pom_matching_artifact_same_version.xml"); ModelWrapper rootPom = model("spring-cloud-sleuth"); - ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions); + ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, + this.versions); - File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp); + File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, + pomInTemp); BDDAssertions.then(asString(storedPom)).isEqualTo(asString(originalPom)); } @@ -406,11 +528,12 @@ public class PomUpdaterTests { } private File pom(String relativePath, String pomName) throws URISyntaxException { - return new File(new File(GitRepoTests.class.getResource(relativePath).toURI()), pomName); + return new File(new File(GitRepoTests.class.getResource(relativePath).toURI()), + pomName); } private String asString(File file) throws IOException { return new String(Files.readAllBytes(file.toPath())); } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdaterTests.java index 94c05269..02a3b179 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdaterTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdaterTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -16,39 +32,45 @@ import org.springframework.cloud.release.internal.git.ProjectGitHandler; */ public class ProjectPomUpdaterTests { - @Test public void should_convert_fixed_versions_to_updated_fixed_versions() { + @Test + public void should_convert_fixed_versions_to_updated_fixed_versions() { ReleaserProperties properties = new ReleaserProperties(); properties.getFixedVersions().put("spring-cloud-task", "2.0.0.RELEASE"); - properties.getFixedVersions().put("spring-cloud-openfeign", "2.0.1.BUILD-SNAPSHOT"); + properties.getFixedVersions().put("spring-cloud-openfeign", + "2.0.1.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-consul", "2.0.1.BUILD-SNAPSHOT"); - properties.getFixedVersions().put("spring-cloud-zookeeper", "2.0.1.BUILD-SNAPSHOT"); + properties.getFixedVersions().put("spring-cloud-zookeeper", + "2.0.1.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-stream", "Elmhurst.RELEASE"); properties.getFixedVersions().put("spring-cloud-config", "2.0.1.BUILD-SNAPSHOT"); - properties.getFixedVersions().put("spring-cloud-cloudfoundry", "2.0.1.BUILD-SNAPSHOT"); + properties.getFixedVersions().put("spring-cloud-cloudfoundry", + "2.0.1.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-netflix", "2.0.1.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-vault", "2.0.1.BUILD-SNAPSHOT"); - properties.getFixedVersions().put("spring-cloud-security", "2.0.1.BUILD-SNAPSHOT"); + properties.getFixedVersions().put("spring-cloud-security", + "2.0.1.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-commons", "2.0.1.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-sleuth", "2.0.1.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-aws", "2.0.1.BUILD-SNAPSHOT"); - properties.getFixedVersions().put("spring-cloud-contract", "2.0.1.BUILD-SNAPSHOT"); - properties.getFixedVersions().put("spring-cloud-release", "Finchley.BUILD-SNAPSHOT"); + properties.getFixedVersions().put("spring-cloud-contract", + "2.0.1.BUILD-SNAPSHOT"); + properties.getFixedVersions().put("spring-cloud-release", + "Finchley.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-build", "2.0.3.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-cloud-bus", "2.0.1.BUILD-SNAPSHOT"); - properties.getFixedVersions().put("spring-cloud-function", "1.0.0.BUILD-SNAPSHOT"); - properties.getFixedVersions().put("spring-cloud-starter-build", "Finchley.BUILD-SNAPSHOT"); + properties.getFixedVersions().put("spring-cloud-function", + "1.0.0.BUILD-SNAPSHOT"); + properties.getFixedVersions().put("spring-cloud-starter-build", + "Finchley.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-boot", "2.0.3.RELEASE"); properties.getFixedVersions().put("spring-cloud-gateway", "2.0.1.BUILD-SNAPSHOT"); ProjectPomUpdater updater = new ProjectPomUpdater(properties); - Map fixedVersions = updater.fixedVersions() - .stream() - .collect(Collectors.toMap( - projectVersion -> projectVersion.projectName, + Map fixedVersions = updater.fixedVersions().stream() + .collect(Collectors.toMap(projectVersion -> projectVersion.projectName, projectVersion -> projectVersion.version)); - BDDAssertions.then(fixedVersions) - .containsEntry("spring-boot", "2.0.3.RELEASE") + BDDAssertions.then(fixedVersions).containsEntry("spring-boot", "2.0.3.RELEASE") .containsEntry("spring-boot-dependencies", "2.0.3.RELEASE") .containsEntry("spring-boot-starter", "2.0.3.RELEASE") .containsEntry("spring-cloud-build", "2.0.3.BUILD-SNAPSHOT") @@ -57,14 +79,16 @@ public class ProjectPomUpdaterTests { .containsEntry("spring-cloud", "Finchley.BUILD-SNAPSHOT"); } - @Test public void should_skip_any_steps_if_there_is_no_pom_xml() { + @Test + public void should_skip_any_steps_if_there_is_no_pom_xml() { ReleaserProperties properties = new ReleaserProperties(); ProjectGitHandler handler = BDDMockito.mock(ProjectGitHandler.class); ProjectPomUpdater updater = new ProjectPomUpdater(properties, handler); - updater.updateProjectFromReleaseTrain( - new File("target"), new Projects(), new ProjectVersion("foo", "1.0.0.RELEASE"), false); + updater.updateProjectFromReleaseTrain(new File("target"), new Projects(), + new ProjectVersion("foo", "1.0.0.RELEASE"), false); BDDMockito.then(handler).shouldHaveZeroInteractions(); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectVersionTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectVersionTests.java index 8c5c9bb9..836e61bd 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectVersionTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectVersionTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -20,12 +36,15 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; public class ProjectVersionTests { File springCloudReleaseProject; + File springCloudContract; @Before public void setup() throws URISyntaxException { - URI scRelease = GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI(); - URI scContract = GitRepoTests.class.getResource("/projects/spring-cloud-contract").toURI(); + URI scRelease = GitRepoTests.class.getResource("/projects/spring-cloud-release") + .toURI(); + URI scContract = GitRepoTests.class.getResource("/projects/spring-cloud-contract") + .toURI(); this.springCloudReleaseProject = new File(scRelease.getPath(), "pom.xml"); this.springCloudContract = new File(scContract.getPath(), "pom.xml"); } @@ -48,7 +67,8 @@ public class ProjectVersionTests { @Test public void should_build_version_from_file() { - ProjectVersion projectVersion = new ProjectVersion(this.springCloudReleaseProject); + ProjectVersion projectVersion = new ProjectVersion( + this.springCloudReleaseProject); then(projectVersion.version).isEqualTo("Dalston.BUILD-SNAPSHOT"); then(projectVersion.projectName).isEqualTo("spring-cloud-starter-build"); @@ -137,36 +157,44 @@ public class ProjectVersionTests { @Test public void should_not_bump_version_by_patch_version_when_non_ga_or_sr() { - then(projectVersion("1.0.1.BUILD-SNAPSHOT").postReleaseSnapshotVersion()).isEqualTo("1.0.1.BUILD-SNAPSHOT"); - then(projectVersion("1.0.1.M1").postReleaseSnapshotVersion()).isEqualTo("1.0.1.BUILD-SNAPSHOT"); - then(projectVersion("1.0.1.RC1").postReleaseSnapshotVersion()).isEqualTo("1.0.1.BUILD-SNAPSHOT"); - then(projectVersion("Finchley.SR1").postReleaseSnapshotVersion()).isEqualTo("Finchley.BUILD-SNAPSHOT"); + then(projectVersion("1.0.1.BUILD-SNAPSHOT").postReleaseSnapshotVersion()) + .isEqualTo("1.0.1.BUILD-SNAPSHOT"); + then(projectVersion("1.0.1.M1").postReleaseSnapshotVersion()) + .isEqualTo("1.0.1.BUILD-SNAPSHOT"); + then(projectVersion("1.0.1.RC1").postReleaseSnapshotVersion()) + .isEqualTo("1.0.1.BUILD-SNAPSHOT"); + then(projectVersion("Finchley.SR1").postReleaseSnapshotVersion()) + .isEqualTo("Finchley.BUILD-SNAPSHOT"); } @Test public void should_bump_version_by_patch_version_when_bumping_snapshots_for_ga() { - then(projectVersion("1.0.1.RELEASE").postReleaseSnapshotVersion()).isEqualTo("1.0.2.BUILD-SNAPSHOT"); + then(projectVersion("1.0.1.RELEASE").postReleaseSnapshotVersion()) + .isEqualTo("1.0.2.BUILD-SNAPSHOT"); } @Test public void should_return_the_previous_version_for_release_train_version_when_bumping_snapshots() { String version = "Edgware.BUILD-SNAPSHOT"; - then(projectVersion(version).postReleaseSnapshotVersion()).isEqualTo("Edgware.BUILD-SNAPSHOT"); + then(projectVersion(version).postReleaseSnapshotVersion()) + .isEqualTo("Edgware.BUILD-SNAPSHOT"); } @Test public void should_bump_version_by_patch_version_when_bumping_releases() { String version = "1.0.1.RELEASE"; - then(projectVersion(version).postReleaseSnapshotVersion()).isEqualTo("1.0.2.BUILD-SNAPSHOT"); + then(projectVersion(version).postReleaseSnapshotVersion()) + .isEqualTo("1.0.2.BUILD-SNAPSHOT"); } @Test public void should_return_the_previous_version_for_release_train_version_when_bumping_releases() { String version = "Edgware.RELEASE"; - then(projectVersion(version).postReleaseSnapshotVersion()).isEqualTo("Edgware.BUILD-SNAPSHOT"); + then(projectVersion(version).postReleaseSnapshotVersion()) + .isEqualTo("Edgware.BUILD-SNAPSHOT"); } @Test @@ -240,7 +268,8 @@ public class ProjectVersionTests { @Test public void should_return_False_when_checking_ga_version_against_non_ga() { - then(projectVersion("1.0.1.BUILD-SNAPSHOT").isReleaseOrServiceRelease()).isFalse(); + then(projectVersion("1.0.1.BUILD-SNAPSHOT").isReleaseOrServiceRelease()) + .isFalse(); then(projectVersion("1.0.1.M4").isReleaseOrServiceRelease()).isFalse(); then(projectVersion("1.0.1.RC4").isReleaseOrServiceRelease()).isFalse(); } @@ -296,7 +325,8 @@ public class ProjectVersionTests { String thisVersion = "Finchley.SR1"; String thatVersion = "Finchley.SR10"; - then(projectVersion(thatVersion).compareToReleaseTrainName(thisVersion)).isPositive(); + then(projectVersion(thatVersion).compareToReleaseTrainName(thisVersion)) + .isPositive(); } @Test @@ -312,12 +342,14 @@ public class ProjectVersionTests { String thisVersion = "Finchley.SR2"; String thatVersion = "Finchley.SR1"; - then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)).isPositive(); + then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)) + .isPositive(); thisVersion = "Greenwich.SR1"; thatVersion = "Finchley.SR2"; - then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)).isPositive(); + then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)) + .isPositive(); } @Test @@ -333,12 +365,14 @@ public class ProjectVersionTests { String thisVersion = "Finchley.SR1"; String thatVersion = "Finchley.SR2"; - then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)).isNegative(); + then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)) + .isNegative(); thisVersion = "Finchley.SR2"; thatVersion = "Greenwich.SR1"; - then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)).isNegative(); + then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)) + .isNegative(); } @Test @@ -346,7 +380,8 @@ public class ProjectVersionTests { String thisVersion = ""; String thatVersion = "Finchley.SR2"; - then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)).isNegative(); + then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)) + .isNegative(); thisVersion = ""; thatVersion = ""; @@ -359,42 +394,51 @@ public class ProjectVersionTests { String thisVersion = "Finchley.SR1"; String thatVersion = ""; - then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)).isPositive(); + then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)) + .isPositive(); } @Test public void should_return_no_unacceptable_patterns_for_a_snapshot_version() { - then(projectVersion("1.0.0.BUILD-SNAPSHOT").unacceptableVersionPatterns()).isEmpty(); + then(projectVersion("1.0.0.BUILD-SNAPSHOT").unacceptableVersionPatterns()) + .isEmpty(); then(projectVersion("1.0.0.SNAPSHOT").unacceptableVersionPatterns()).isEmpty(); } @Test public void should_return_snapshot_unacceptable_patterns_for_a_milestone_or_rc_version() { - List milestonePatterns = projectVersion("1.0.0.M1").unacceptableVersionPatterns(); + List milestonePatterns = projectVersion("1.0.0.M1") + .unacceptableVersionPatterns(); then(milestonePatterns).isNotEmpty(); then(milestonePatterns.get(0).pattern()).contains("SNAPSHOT"); - List rcPatterns = projectVersion("1.0.0.RC1").unacceptableVersionPatterns(); + List rcPatterns = projectVersion("1.0.0.RC1") + .unacceptableVersionPatterns(); then(rcPatterns).isNotEmpty(); then(rcPatterns.get(0).pattern()).contains("SNAPSHOT"); } @Test public void should_return_snapshot_milestone_rc_unacceptable_patterns_for_a_ga_or_sr_version() { - List gaPatterns = projectVersion("1.0.0.RELEASE").unacceptableVersionPatterns(); + List gaPatterns = projectVersion("1.0.0.RELEASE") + .unacceptableVersionPatterns(); thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(gaPatterns); gaPatterns = projectVersion("1.0.0").unacceptableVersionPatterns(); thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(gaPatterns); - List srPatterns = projectVersion("1.0.0.SR1").unacceptableVersionPatterns(); + List srPatterns = projectVersion("1.0.0.SR1") + .unacceptableVersionPatterns(); thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(srPatterns); - List unknownTypeOfVersion = projectVersion("1.0.0.SOMETHING").unacceptableVersionPatterns(); - thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(unknownTypeOfVersion); + List unknownTypeOfVersion = projectVersion("1.0.0.SOMETHING") + .unacceptableVersionPatterns(); + thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent( + unknownTypeOfVersion); } - private void thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(List unknownTypeOfVersion) { + private void thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent( + List unknownTypeOfVersion) { then(unknownTypeOfVersion).isNotEmpty(); then(unknownTypeOfVersion.get(0).pattern()).contains("SNAPSHOT"); then(unknownTypeOfVersion.get(1).pattern()).contains("M[0-9]"); @@ -404,4 +448,5 @@ public class ProjectVersionTests { private ProjectVersion projectVersion(String version) { return new ProjectVersion("foo", version); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectsTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectsTests.java index 11be87dd..d2ea22e7 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectsTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/ProjectsTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -53,7 +69,8 @@ public class ProjectsTests { projectVersions.add(new ProjectVersion("spring-boot-starter-build", "1.0.0")); Projects projects = new Projects(projectVersions); - then(projects.forNameStartingWith("spring-boot").get(0).version).isEqualTo("1.0.0"); + then(projects.forNameStartingWith("spring-boot").get(0).version) + .isEqualTo("1.0.0"); } @Test @@ -65,7 +82,8 @@ public class ProjectsTests { projectVersions.add(boot); ProjectVersion bootDeps = new ProjectVersion("spring-boot-dependencies", "2.0.0"); projectVersions.add(bootDeps); - ProjectVersion original = new ProjectVersion("spring-cloud-starter-foo", "3.0.0.BUILD-SNAPSHOT"); + ProjectVersion original = new ProjectVersion("spring-cloud-starter-foo", + "3.0.0.BUILD-SNAPSHOT"); projectVersions.add(original); Projects projects = new Projects(projectVersions); @@ -73,7 +91,8 @@ public class ProjectsTests { then(forRollback.forName("spring-boot-starter").version).isEqualTo("2.0.0"); then(forRollback.forName("spring-boot-dependencies").version).isEqualTo("2.0.0"); - then(forRollback.forName("spring-cloud-starter-foo").version).isEqualTo("3.0.1.BUILD-SNAPSHOT"); + then(forRollback.forName("spring-cloud-starter-foo").version) + .isEqualTo("3.0.1.BUILD-SNAPSHOT"); } @Test @@ -122,7 +141,8 @@ public class ProjectsTests { @Test public void should_return_projects_with_bumped_versions() { Set projectVersions = new HashSet<>(); - projectVersions.add(new ProjectVersion("spring-boot-dependencies", "2.0.0.RELEASE")); + projectVersions + .add(new ProjectVersion("spring-boot-dependencies", "2.0.0.RELEASE")); projectVersions.add(new ProjectVersion("spring-boot-starter", "2.0.0.RELEASE")); projectVersions.add(new ProjectVersion("foo", "1.0.0.RELEASE")); projectVersions.add(new ProjectVersion("bar", "1.0.1.M1")); @@ -132,9 +152,11 @@ public class ProjectsTests { projectVersions.add(new ProjectVersion("foo4", "Finchley.SR4")); Projects projects = new Projects(projectVersions); - Projects bumped = projects.postReleaseSnapshotVersion(Collections.singletonList("spring-boot")); + Projects bumped = projects + .postReleaseSnapshotVersion(Collections.singletonList("spring-boot")); - then(bumped.forName("spring-boot-dependencies").version).isEqualTo("2.0.0.RELEASE"); + then(bumped.forName("spring-boot-dependencies").version) + .isEqualTo("2.0.0.RELEASE"); then(bumped.forName("spring-boot-starter").version).isEqualTo("2.0.0.RELEASE"); then(bumped.forName("foo").version).isEqualTo("1.0.1.BUILD-SNAPSHOT"); then(bumped.forName("bar").version).isEqualTo("1.0.1.BUILD-SNAPSHOT"); @@ -151,8 +173,8 @@ public class ProjectsTests { Projects projects = new Projects(projectVersions); thenThrownBy(() -> projects.forFile(this.springCloudReleasePom)) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("Project with name [spring-cloud-starter-build] is not present"); + .isInstanceOf(IllegalStateException.class).hasMessageContaining( + "Project with name [spring-cloud-starter-build] is not present"); } @Test @@ -162,8 +184,8 @@ public class ProjectsTests { Projects projects = new Projects(projectVersions); thenThrownBy(() -> projects.forName("spring-cloud-starter-build")) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("Project with name [spring-cloud-starter-build] is not present"); + .isInstanceOf(IllegalStateException.class).hasMessageContaining( + "Project with name [spring-cloud-starter-build] is not present"); } @Test @@ -208,4 +230,4 @@ public class ProjectsTests { } } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PropertyStorerTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PropertyStorerTests.java index b816fdcc..626095aa 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PropertyStorerTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PropertyStorerTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import org.apache.maven.plugin.logging.Log; @@ -17,19 +33,25 @@ import static org.mockito.BDDMockito.then; @RunWith(MockitoJUnitRunner.class) public class PropertyStorerTests { - @Mock Log log; - @Mock ModifiedPomXMLEventReader pom; - @InjectMocks PropertyStorer propertyStorer; + @Mock + Log log; - @Test public void should_not_set_a_version_when_its_empty() { + @Mock + ModifiedPomXMLEventReader pom; + + @InjectMocks + PropertyStorer propertyStorer; + + @Test + public void should_not_set_a_version_when_its_empty() { this.propertyStorer.setPropertyVersionIfApplicable(new Project("foo", "")); then(this.log).should().warn(containsWarnMsgAboutEmptyVersion()); } private String containsWarnMsgAboutEmptyVersion() { - return BDDMockito.argThat( - argument -> argument.contains("is empty. Will not set it")); + return BDDMockito + .argThat(argument -> argument.contains("is empty. Will not set it")); } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PropertyVersionChangerTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PropertyVersionChangerTests.java index 72a27df7..6e2e6a5e 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PropertyVersionChangerTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/PropertyVersionChangerTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.util.HashSet; @@ -11,8 +27,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import static org.mockito.BDDMockito.then; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; /** @@ -21,33 +37,42 @@ import static org.mockito.Mockito.never; @RunWith(MockitoJUnitRunner.class) public class PropertyVersionChangerTests { - @Mock PropertyStorer propertyStorer; + @Mock + PropertyStorer propertyStorer; @Test public void should_set_version_when_project_matches_property_name() throws Exception { - PropertyVersionChanger changer = new PropertyVersionChanger(model(), versions(), null, null, this.propertyStorer); + PropertyVersionChanger changer = new PropertyVersionChanger(model(), versions(), + null, null, this.propertyStorer); changer.apply(null); - then(this.propertyStorer).should().setPropertyVersionIfApplicable(project("spring-cloud-sleuth", "1.2.0.BUILD-SNAPSHOT")); + then(this.propertyStorer).should().setPropertyVersionIfApplicable( + project("spring-cloud-sleuth", "1.2.0.BUILD-SNAPSHOT")); } @Test - public void should_not_set_version_when_project_doesnt_match_property_name() throws Exception { - PropertyVersionChanger changer = new PropertyVersionChanger(nonMatchingModel(), versions(), null, null, this.propertyStorer); + public void should_not_set_version_when_project_doesnt_match_property_name() + throws Exception { + PropertyVersionChanger changer = new PropertyVersionChanger(nonMatchingModel(), + versions(), null, null, this.propertyStorer); changer.apply(null); - then(this.propertyStorer).should(never()).setPropertyVersionIfApplicable(any(Project.class)); + then(this.propertyStorer).should(never()) + .setPropertyVersionIfApplicable(any(Project.class)); } @Test - public void should_not_set_version_when_project_matches_property_name_and_versions_are_the_same() throws Exception { - PropertyVersionChanger changer = new PropertyVersionChanger(modelWithSameValues(), versions(), null, null, this.propertyStorer); + public void should_not_set_version_when_project_matches_property_name_and_versions_are_the_same() + throws Exception { + PropertyVersionChanger changer = new PropertyVersionChanger(modelWithSameValues(), + versions(), null, null, this.propertyStorer); changer.apply(null); - then(this.propertyStorer).should(never()).setPropertyVersionIfApplicable(any(Project.class)); + then(this.propertyStorer).should(never()) + .setPropertyVersionIfApplicable(any(Project.class)); } Versions versions() { @@ -56,10 +81,9 @@ public class PropertyVersionChangerTests { @SuppressWarnings("unchecked") private Set allProjects() { - return new HashSet<>(Arrays.asList(new Project[] { - project("spring-cloud-aws", "1.2.0.BUILD-SNAPSHOT"), - project("spring-cloud-sleuth", "1.2.0.BUILD-SNAPSHOT") - })); + return new HashSet<>(Arrays.asList( + new Project[] { project("spring-cloud-aws", "1.2.0.BUILD-SNAPSHOT"), + project("spring-cloud-sleuth", "1.2.0.BUILD-SNAPSHOT") })); } Project project(String name, String value) { @@ -101,4 +125,5 @@ public class PropertyVersionChangerTests { properties.setProperty("spring-cloud-non-matching.version", "1.0.0.RELEASE"); return properties; } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/TestPomReader.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/TestPomReader.java index 87d9f96b..cac08b41 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/TestPomReader.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/TestPomReader.java @@ -1,9 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; import org.apache.maven.model.Model; -import org.springframework.cloud.release.internal.pom.PomReader; /** * @author Marcin Grzejszczak @@ -15,4 +30,5 @@ public class TestPomReader { public Model readPom(File pom) { return this.pomReader.readPom(pom); } + } diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/TestUtils.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/TestUtils.java index ee08ae1e..90be8b50 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/TestUtils.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/TestUtils.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -16,7 +32,8 @@ public class TestUtils { prepareLocalRepo("target/test-classes/projects/", "spring-cloud-static"); } - private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException { + private static void prepareLocalRepo(String buildDir, String repoPath) + throws IOException { File dotGit = new File(buildDir + repoPath + "/.git"); File git = new File(buildDir + repoPath + "/git"); if (git.exists()) { @@ -27,4 +44,4 @@ public class TestUtils { git.renameTo(dotGit); } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionChangeAssertions.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionChangeAssertions.java index 717a9bb6..c0ceb616 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionChangeAssertions.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionChangeAssertions.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.util.ArrayList; @@ -29,16 +45,17 @@ class ListOfChanges { ListOfChanges(ModelWrapper model) { this.changes = new ArrayList<>(model.sourceChanges); } + } -class VersionChangeAssert extends - AbstractAssert { +class VersionChangeAssert extends AbstractAssert { - public VersionChangeAssert(ListOfChanges actual) { + VersionChangeAssert(ListOfChanges actual) { super(actual, VersionChangeAssert.class); } - VersionChangeAssert newParentVersionIsEqualTo(String groupId, String artifactId, String newVersion) { + VersionChangeAssert newParentVersionIsEqualTo(String groupId, String artifactId, + String newVersion) { boolean matches = false; for (VersionChange change : this.actual.changes) { if (newVersion.equals(change.getNewVersion()) @@ -54,5 +71,5 @@ class VersionChangeAssert extends failWithMessage("There is no change with that parent coordinates"); return this; } -} +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionsTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionsTests.java index 7e26c75b..04f91a70 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionsTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionsTests.java @@ -1,17 +1,33 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.springframework.cloud.release.internal.pom; @@ -36,12 +52,10 @@ public class VersionsTests { @Test public void should_add_boot_to_versions_when_version_is_created() { - then(new Versions("1.2.3.RELEASE").projects) - .contains( - new Project("spring-boot", "1.2.3.RELEASE"), - new Project("spring-boot-starter-parent", "1.2.3.RELEASE"), - new Project("spring-boot-dependencies", "1.2.3.RELEASE") - ); + then(new Versions("1.2.3.RELEASE").projects).contains( + new Project("spring-boot", "1.2.3.RELEASE"), + new Project("spring-boot-starter-parent", "1.2.3.RELEASE"), + new Project("spring-boot-dependencies", "1.2.3.RELEASE")); } @Test @@ -113,14 +127,19 @@ public class VersionsTests { versions = mixedVersions().setVersion("spring-cloud-build", "3.0.0"); - then(versions.versionForProject("spring-cloud-dependencies-parent")).isEqualTo("3.0.0"); - then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.RELEASE"); + then(versions.versionForProject("spring-cloud-dependencies-parent")) + .isEqualTo("3.0.0"); + then(versions.versionForProject("spring-cloud-dependencies")) + .isEqualTo("Greenwich.RELEASE"); - versions = mixedVersions().setVersion("spring-cloud-dependencies-parent", "3.0.0"); + versions = mixedVersions().setVersion("spring-cloud-dependencies-parent", + "3.0.0"); then(versions.versionForProject("spring-cloud-build")).isEqualTo("3.0.0"); - then(versions.versionForProject("spring-cloud-dependencies-parent")).isEqualTo("3.0.0"); - then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.RELEASE"); + then(versions.versionForProject("spring-cloud-dependencies-parent")) + .isEqualTo("3.0.0"); + then(versions.versionForProject("spring-cloud-dependencies")) + .isEqualTo("Greenwich.RELEASE"); } @Test @@ -142,48 +161,68 @@ public class VersionsTests { versions = mixedVersions().setVersion("spring-cloud-release", "Greenwich.SR8"); then(versions.versionForProject("spring-cloud")).isEqualTo("Greenwich.SR8"); - then(versions.versionForProject("spring-cloud-release")).isEqualTo("Greenwich.SR8"); - then(versions.versionForProject("spring-cloud-starter")).isEqualTo("Greenwich.SR8"); - then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.SR8"); + then(versions.versionForProject("spring-cloud-release")) + .isEqualTo("Greenwich.SR8"); + then(versions.versionForProject("spring-cloud-starter")) + .isEqualTo("Greenwich.SR8"); + then(versions.versionForProject("spring-cloud-dependencies")) + .isEqualTo("Greenwich.SR8"); - versions = mixedVersions().setVersion("spring-cloud-dependencies", "Greenwich.SR8"); + versions = mixedVersions().setVersion("spring-cloud-dependencies", + "Greenwich.SR8"); then(versions.versionForProject("spring-cloud")).isEqualTo("Greenwich.SR8"); - then(versions.versionForProject("spring-cloud-release")).isEqualTo("Greenwich.SR8"); - then(versions.versionForProject("spring-cloud-starter")).isEqualTo("Greenwich.SR8"); - then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.SR8"); + then(versions.versionForProject("spring-cloud-release")) + .isEqualTo("Greenwich.SR8"); + then(versions.versionForProject("spring-cloud-starter")) + .isEqualTo("Greenwich.SR8"); + then(versions.versionForProject("spring-cloud-dependencies")) + .isEqualTo("Greenwich.SR8"); } @Test public void should_update_projects_for_custom_bom_only() { - Versions versions = mixedVersions(customBom()).setVersion("spring-cloud", "3.0.0"); + Versions versions = mixedVersions(customBom()).setVersion("spring-cloud", + "3.0.0"); then(versions.versionForProject("spring-cloud")).isEqualTo("3.0.0"); - then(versions.versionForProject("spring-cloud-stream-starters")).isEqualTo("Fishtown.RELEASE"); + then(versions.versionForProject("spring-cloud-stream-starters")) + .isEqualTo("Fishtown.RELEASE"); then(versions.versionForProject("spring-cloud-starter")).isEmpty(); - then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.RELEASE"); + then(versions.versionForProject("spring-cloud-dependencies")) + .isEqualTo("Greenwich.RELEASE"); - versions = mixedVersions(customBom()).setVersion("spring-cloud-stream-starters", "Fishtown.SR4"); + versions = mixedVersions(customBom()).setVersion("spring-cloud-stream-starters", + "Fishtown.SR4"); then(versions.versionForProject("spring-cloud")).isEmpty(); - then(versions.versionForProject("spring-cloud-stream-starters")).isEqualTo("Fishtown.SR4"); + then(versions.versionForProject("spring-cloud-stream-starters")) + .isEqualTo("Fishtown.SR4"); then(versions.versionForProject("spring-cloud-starter")).isEmpty(); - then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.RELEASE"); + then(versions.versionForProject("spring-cloud-dependencies")) + .isEqualTo("Greenwich.RELEASE"); - versions = mixedVersions(customBom()).setVersion("spring-cloud-release", "Greenwich.SR8"); + versions = mixedVersions(customBom()).setVersion("spring-cloud-release", + "Greenwich.SR8"); - then(versions.versionForProject("spring-cloud-release")).isEqualTo("Greenwich.SR8"); - then(versions.versionForProject("spring-cloud-stream-starters")).isEqualTo("Fishtown.RELEASE"); + then(versions.versionForProject("spring-cloud-release")) + .isEqualTo("Greenwich.SR8"); + then(versions.versionForProject("spring-cloud-stream-starters")) + .isEqualTo("Fishtown.RELEASE"); then(versions.versionForProject("spring-cloud")).isEmpty(); then(versions.versionForProject("spring-cloud-starter")).isEmpty(); - then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.RELEASE"); + then(versions.versionForProject("spring-cloud-dependencies")) + .isEqualTo("Greenwich.RELEASE"); - versions = mixedVersions(customBom()).setVersion("spring-cloud-dependencies", "Greenwich.SR8"); + versions = mixedVersions(customBom()).setVersion("spring-cloud-dependencies", + "Greenwich.SR8"); then(versions.versionForProject("spring-cloud")).isEmpty(); - then(versions.versionForProject("spring-cloud-stream-starters")).isEqualTo("Fishtown.RELEASE"); + then(versions.versionForProject("spring-cloud-stream-starters")) + .isEqualTo("Fishtown.RELEASE"); then(versions.versionForProject("spring-cloud-starter")).isEmpty(); - then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("Greenwich.SR8"); + then(versions.versionForProject("spring-cloud-dependencies")) + .isEqualTo("Greenwich.SR8"); } @Test @@ -203,8 +242,10 @@ public class VersionsTests { private ReleaserProperties customBom() { ReleaserProperties properties = new ReleaserProperties(); - properties.getMetaRelease().setReleaseTrainDependencyNames(Collections.emptyList()); - properties.getMetaRelease().setReleaseTrainProjectName("spring-cloud-stream-starters"); + properties.getMetaRelease() + .setReleaseTrainDependencyNames(Collections.emptyList()); + properties.getMetaRelease() + .setReleaseTrainProjectName("spring-cloud-stream-starters"); properties.getPom().setThisTrainBom("spring-cloud-stream-dependencies"); return properties; } @@ -236,4 +277,5 @@ public class VersionsTests { properties.setProperty("missing.version", "1.0.0"); return properties; } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/post/PostReleaseActionsTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/post/PostReleaseActionsTests.java index 0a4a5508..20667087 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/post/PostReleaseActionsTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/post/PostReleaseActionsTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.post; import java.io.File; @@ -39,12 +55,19 @@ public class PostReleaseActionsTests { @Rule public TemporaryFolder tmp = new TemporaryFolder(); + File temporaryFolder; + TestPomReader testPomReader = new TestPomReader(); + GradleUpdater gradleUpdater = BDDMockito.mock(GradleUpdater.class); + ReleaserProperties properties = new ReleaserProperties(); + File cloned; + LinkedMultiValueMap clonedTestProjects = new LinkedMultiValueMap<>(); + ProjectGitHandler projectGitHandler = new ProjectGitHandler(this.properties) { @Override public File cloneTestSamplesProject() { @@ -65,7 +88,9 @@ public class PostReleaseActionsTests { return file; } }; + ProjectPomUpdater updater = new ProjectPomUpdater(this.properties); + ProjectBuilder builder = new ProjectBuilder(this.properties); @Before @@ -102,7 +127,8 @@ public class PostReleaseActionsTests { @Test public void should_update_project_and_run_tests_and_update_test_is_called() { this.properties.getMetaRelease().setEnabled(true); - this.properties.getGit().setTestSamplesProjectUrl(tmpFile("spring-cloud-core-tests/").getAbsolutePath() + "/"); + this.properties.getGit().setTestSamplesProjectUrl( + tmpFile("spring-cloud-core-tests/").getAbsolutePath() + "/"); this.properties.getMaven().setBuildCommand("touch build.log"); PostReleaseActions actions = new PostReleaseActions(this.projectGitHandler, this.updater, this.gradleUpdater, this.builder, this.properties); @@ -118,8 +144,9 @@ public class PostReleaseActionsTests { } private void thenGradleUpdaterWasCalled() { - BDDMockito.then(this.gradleUpdater).should().updateProjectFromBom(BDDMockito.any(File.class), - BDDMockito.any(Projects.class), BDDMockito.any(ProjectVersion.class), BDDMockito.eq(false)); + BDDMockito.then(this.gradleUpdater).should().updateProjectFromBom( + BDDMockito.any(File.class), BDDMockito.any(Projects.class), + BDDMockito.any(ProjectVersion.class), BDDMockito.eq(false)); } @Test @@ -147,8 +174,10 @@ public class PostReleaseActionsTests { @Test public void should_update_project_and_run_tests_and_release_train_docs_generation_is_called() { this.properties.getMetaRelease().setEnabled(true); - this.properties.getGit().setReleaseTrainDocsUrl(tmpFile("spring-cloud-core-tests/").getAbsolutePath() + "/"); - this.properties.getMaven().setGenerateReleaseTrainDocsCommand("touch generate.log"); + this.properties.getGit().setReleaseTrainDocsUrl( + tmpFile("spring-cloud-core-tests/").getAbsolutePath() + "/"); + this.properties.getMaven() + .setGenerateReleaseTrainDocsCommand("touch generate.log"); PostReleaseActions actions = new PostReleaseActions(this.projectGitHandler, this.updater, this.gradleUpdater, this.builder, this.properties); @@ -175,7 +204,7 @@ public class PostReleaseActionsTests { } @Test - public void should_do_nothing_when_the_switch_for_test_samples_update_check_is_off_and_test_samples_update_is_called() { + public void should_do_nothing_when_the_switch_for_test_samples_update_check_is_off_and_update_is_called() { this.properties.getGit().setUpdateReleaseTrainDocs(false); PostReleaseActions actions = new PostReleaseActions(this.projectGitHandler, this.updater, this.gradleUpdater, this.builder, this.properties); @@ -187,12 +216,13 @@ public class PostReleaseActionsTests { } @Test - public void should_update_test_sample_projects_when_test_samples_update_is_called() throws Exception { + public void should_update_test_sample_projects_when_test_samples_update_is_called() + throws Exception { this.properties.getMetaRelease().setEnabled(true); this.properties.getGit().getAllTestSampleUrls().clear(); this.properties.getGit().getAllTestSampleUrls().put("spring-cloud-sleuth", - Collections.singletonList(tmpFile("spring-cloud-core-tests/") - .getAbsolutePath() + "/")); + Collections.singletonList( + tmpFile("spring-cloud-core-tests/").getAbsolutePath() + "/")); AtomicReference postReleaseProjects = new AtomicReference<>(); PostReleaseActions actions = new PostReleaseActions(this.projectGitHandler, this.updater, this.gradleUpdater, this.builder, this.properties) { @@ -205,31 +235,36 @@ public class PostReleaseActionsTests { actions.updateAllTestSamples(currentGa()); - Map.Entry> entry = this.clonedTestProjects.entrySet() - .stream() - .filter(s -> s.getKey().contains("spring-cloud-core-tests")) - .findFirst().orElseThrow(() -> new IllegalStateException("Not found")); + Map.Entry> entry = this.clonedTestProjects.entrySet().stream() + .filter(s -> s.getKey().contains("spring-cloud-core-tests")).findFirst() + .orElseThrow(() -> new IllegalStateException("Not found")); File clonedFile = entry.getValue().get(0); - Model pomWithCloud = this.testPomReader.readPom(new File(clonedFile, "zuul-proxy-eureka/pom.xml")); + Model pomWithCloud = this.testPomReader + .readPom(new File(clonedFile, "zuul-proxy-eureka/pom.xml")); Git git = GitTestUtils.openGitProject(clonedFile); - BDDAssertions.then(pomWithCloud.getProperties().getProperty("spring-cloud.version")).isEqualTo("Finchley.BUILD-SNAPSHOT"); - BDDAssertions.then(pomWithCloud.getParent().getVersion()).isEqualTo("2.0.4.RELEASE"); + BDDAssertions + .then(pomWithCloud.getProperties().getProperty("spring-cloud.version")) + .isEqualTo("Finchley.BUILD-SNAPSHOT"); + BDDAssertions.then(pomWithCloud.getParent().getVersion()) + .isEqualTo("2.0.4.RELEASE"); Iterator iterator = git.log().call().iterator(); RevCommit commit = iterator.next(); - BDDAssertions.then(commit.getShortMessage()) - .isEqualTo("Updated versions after [Finchley.SR1] release train and [2.0.1.RELEASE] [spring-cloud-sleuth] project release"); + BDDAssertions.then(commit.getShortMessage()).isEqualTo( + "Updated versions after [Finchley.SR1] release train and [2.0.1.RELEASE] [spring-cloud-sleuth] project release"); thenGradleUpdaterWasCalled(); - BDDAssertions.then(postReleaseProjects.get() - .forName("spring-boot-dependencies").version).isEqualTo("2.0.4.RELEASE"); + BDDAssertions.then( + postReleaseProjects.get().forName("spring-boot-dependencies").version) + .isEqualTo("2.0.4.RELEASE"); } @Test - public void should_assume_that_project_version_is_snapshot_when_no_pom_is_present() throws Exception { + public void should_assume_that_project_version_is_snapshot_when_no_pom_is_present() + throws Exception { this.properties.getMetaRelease().setEnabled(true); this.properties.getGit().getAllTestSampleUrls().clear(); this.properties.getGit().getAllTestSampleUrls().put("spring-cloud-sleuth", - Collections.singletonList(tmpFile("spring-cloud-static/") - .getAbsolutePath() + "/")); + Collections.singletonList( + tmpFile("spring-cloud-static/").getAbsolutePath() + "/")); AtomicReference postReleaseProjects = new AtomicReference<>(); PostReleaseActions actions = new PostReleaseActions(this.projectGitHandler, this.updater, this.gradleUpdater, this.builder, this.properties) { @@ -242,10 +277,9 @@ public class PostReleaseActionsTests { actions.updateAllTestSamples(currentGa()); - Map.Entry> entry = this.clonedTestProjects.entrySet() - .stream() - .filter(s -> s.getKey().contains("spring-cloud-static")) - .findFirst().orElseThrow(() -> new IllegalStateException("Not found")); + Map.Entry> entry = this.clonedTestProjects.entrySet().stream() + .filter(s -> s.getKey().contains("spring-cloud-static")).findFirst() + .orElseThrow(() -> new IllegalStateException("Not found")); } private String sleuthParentPomVersion() { @@ -254,8 +288,7 @@ public class PostReleaseActionsTests { } Projects currentGa() { - return new Projects( - new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), + return new Projects(new ProjectVersion("spring-cloud-aws", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-bus", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-cli", "2.0.0.RELEASE"), new ProjectVersion("spring-cloud-commons", "2.0.1.RELEASE"), @@ -286,4 +319,5 @@ public class PostReleaseActionsTests { private File file(String relativePath) throws URISyntaxException { return new File(PomUpdateAcceptanceTests.class.getResource(relativePath).toURI()); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/project/ProjectBuilderTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/project/ProjectBuilderTests.java index 9ead32ae..be38f8c9 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/project/ProjectBuilderTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/project/ProjectBuilderTests.java @@ -1,7 +1,20 @@ -package org.springframework.cloud.release.internal.project; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.assertj.core.api.BDDAssertions.then; -import static org.assertj.core.api.BDDAssertions.thenThrownBy; +package org.springframework.cloud.release.internal.project; import java.io.File; import java.io.IOException; @@ -15,6 +28,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; + import org.springframework.boot.test.rule.OutputCapture; import org.springframework.cloud.release.internal.PomUpdateAcceptanceTests; import org.springframework.cloud.release.internal.ReleaserProperties; @@ -22,14 +36,21 @@ import org.springframework.cloud.release.internal.pom.ProjectVersion; import org.springframework.cloud.release.internal.pom.TestUtils; import org.springframework.util.FileSystemUtils; +import static org.assertj.core.api.BDDAssertions.then; +import static org.assertj.core.api.BDDAssertions.thenThrownBy; + /** * @author Marcin Grzejszczak */ public class ProjectBuilderTests { - @Rule public TemporaryFolder tmp = new TemporaryFolder(); + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + @Rule + public OutputCapture outputCapture = new OutputCapture(); + File temporaryFolder; - @Rule public OutputCapture outputCapture = new OutputCapture(); @Before public void checkOs() throws Exception { @@ -49,7 +70,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_command_when_after_running_there_is_no_html_file_with_unresolved_tag() throws Exception { + public void should_successfully_execute_a_command_when_after_running_there_is_no_html_file_with_unresolved_tag() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("ls -al"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -62,20 +84,23 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_command_when_path_is_provided_explicitly() throws Exception { + public void should_successfully_execute_a_command_when_path_is_provided_explicitly() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("ls -al"); properties.setWorkingDir(new File("/foo/bar").getAbsolutePath()); ProjectBuilder builder = projectBuilder(properties); - builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"), tmpFile("/builder/resolved").getPath()); + builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"), + tmpFile("/builder/resolved").getPath()); then(asString(tmpFile("/builder/resolved/resolved.log"))) .contains("resolved.log"); } @Test - public void should_successfully_execute_a_build_command_for_milestone_version() throws Exception { + public void should_successfully_execute_a_build_command_for_milestone_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo foo"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -88,7 +113,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_build_command_for_rc_version() throws Exception { + public void should_successfully_execute_a_build_command_for_rc_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo foo"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -101,7 +127,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_build_command_for_release_version() throws Exception { + public void should_successfully_execute_a_build_command_for_release_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo foo"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -114,7 +141,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_build_command_for_sr_version() throws Exception { + public void should_successfully_execute_a_build_command_for_sr_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo foo"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -127,7 +155,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_command_when_system_props_placeholder_is_present() throws Exception { + public void should_successfully_execute_a_command_when_system_props_placeholder_is_present() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo {{systemProps}}"); properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar"); @@ -141,7 +170,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_and_there_are_no_sys_props() throws Exception { + public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_and_there_are_no_sys_props() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo foo {{systemProps}}"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -149,12 +179,12 @@ public class ProjectBuilderTests { builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")); - then(asString(tmpFile("/builder/resolved/resolved.log"))) - .contains("foo"); + then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo"); } @Test - public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_without_system_props() throws Exception { + public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_without_system_props() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo {{systemProps}}"); properties.getMaven().setSystemProperties("hello=world foo=bar"); @@ -168,7 +198,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_inside_command() throws Exception { + public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_inside_command() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo {{systemProps}} bar"); properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar"); @@ -182,7 +213,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_pass_system_props_when_build_gets_executed_without_explicit_system_props() throws Exception { + public void should_successfully_pass_system_props_when_build_gets_executed_without_explicit_system_props() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setBuildCommand("echo bar"); properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar"); @@ -202,8 +234,10 @@ public class ProjectBuilderTests { properties.setWorkingDir(tmpFile("/builder/unresolved").getPath()); ProjectBuilder builder = projectBuilder(properties); - thenThrownBy(() -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))) - .hasMessageContaining("contains a tag that wasn't resolved properly"); + thenThrownBy( + () -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))) + .hasMessageContaining( + "contains a tag that wasn't resolved properly"); } @Test @@ -214,8 +248,10 @@ public class ProjectBuilderTests { properties.setWorkingDir(tmpFile("/builder/unresolved").getPath()); ProjectBuilder builder = projectBuilder(properties); - thenThrownBy(() -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))) - .hasMessageContaining("Process waiting time of [0] minutes exceeded"); + thenThrownBy( + () -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))) + .hasMessageContaining( + "Process waiting time of [0] minutes exceeded"); } @Test @@ -232,7 +268,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_deploy_command_for_milestone_version() throws Exception { + public void should_successfully_execute_a_deploy_command_for_milestone_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setDeployCommand("echo foo"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -245,7 +282,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_deploy_command_for_rc_version() throws Exception { + public void should_successfully_execute_a_deploy_command_for_rc_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setDeployCommand("echo foo"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -258,7 +296,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_deploy_command_for_release_version() throws Exception { + public void should_successfully_execute_a_deploy_command_for_release_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setDeployCommand("echo foo"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -271,7 +310,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_deploy_command_for_sr_version() throws Exception { + public void should_successfully_execute_a_deploy_command_for_sr_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setDeployCommand("echo foo"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); @@ -284,7 +324,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_deploy_command_with_sys_props_placeholder() throws Exception { + public void should_successfully_execute_a_deploy_command_with_sys_props_placeholder() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setDeployCommand("echo \"{{systemProps}}\""); properties.getMaven().setSystemProperties("-Dhello=hello-world"); @@ -298,7 +339,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_pass_system_props_when_deploy_gets_executed_without_explicit_system_props() throws Exception { + public void should_successfully_pass_system_props_when_deploy_gets_executed_without_explicit_system_props() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setDeployCommand("echo "); properties.getMaven().setSystemProperties("-Dhello=hello-world"); @@ -319,8 +361,10 @@ public class ProjectBuilderTests { properties.setWorkingDir(tmpFile("/builder/unresolved").getPath()); ProjectBuilder builder = projectBuilder(properties); - thenThrownBy(() -> builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))) - .hasMessageContaining("Process waiting time of [0] minutes exceeded"); + thenThrownBy( + () -> builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))) + .hasMessageContaining( + "Process waiting time of [0] minutes exceeded"); } @Test @@ -344,9 +388,11 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_publish_docs_command_with_sys_props_placeholder() throws Exception { + public void should_successfully_execute_a_publish_docs_command_with_sys_props_placeholder() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); - properties.getMaven().setPublishDocsCommands(new String[] { "echo {{systemProps}} 1", "echo {{systemProps}} 2" }); + properties.getMaven().setPublishDocsCommands( + new String[] { "echo {{systemProps}} 1", "echo {{systemProps}} 2" }); properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar"); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); TestProcessExecutor executor = testExecutor(properties.getWorkingDir()); @@ -365,9 +411,11 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_a_publish_docs_command_and_substitute_the_version() throws Exception { + public void should_successfully_execute_a_publish_docs_command_and_substitute_the_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); - properties.getMaven().setPublishDocsCommands(new String[] { "echo '{{version}}'" }); + properties.getMaven() + .setPublishDocsCommands(new String[] { "echo '{{version}}'" }); properties.setWorkingDir(tmpFile("/builder/resolved").getPath()); TestProcessExecutor executor = testExecutor(properties.getWorkingDir()); ProjectBuilder builder = new ProjectBuilder(properties) { @@ -384,7 +432,8 @@ public class ProjectBuilderTests { } @Test - public void should_successfully_execute_an_update_docs_command_and_substitute_the_version() throws Exception { + public void should_successfully_execute_an_update_docs_command_and_substitute_the_version() + throws Exception { ReleaserProperties properties = new ReleaserProperties(); properties.getMaven().setGenerateReleaseTrainDocsCommand("echo '{{version}}'"); File resolved = tmpFile("/builder/resolved"); @@ -406,12 +455,14 @@ public class ProjectBuilderTests { @Test public void should_throw_exception_when_publish_docs_command_took_too_long_to_execute() { ReleaserProperties properties = new ReleaserProperties(); - properties.getMaven().setPublishDocsCommands(new String[] { "sleep 1", "sleep 1" }); + properties.getMaven() + .setPublishDocsCommands(new String[] { "sleep 1", "sleep 1" }); properties.getMaven().setWaitTimeInMinutes(0); properties.setWorkingDir(tmpFile("/builder/unresolved").getPath()); ProjectBuilder builder = projectBuilder(properties); - thenThrownBy(() -> builder.publishDocs("")).hasMessageContaining("Process waiting time of [0] minutes exceeded"); + thenThrownBy(() -> builder.publishDocs("")) + .hasMessageContaining("Process waiting time of [0] minutes exceeded"); } @Test @@ -423,40 +474,49 @@ public class ProjectBuilderTests { @Override ProcessExecutor executor(String workingDir) { return new ProcessExecutor(properties.getWorkingDir()) { - @Override Process startProcess(ProcessBuilder builder) { + @Override + Process startProcess(ProcessBuilder builder) { return processWithInvalidExitCode(); } }; } }; - thenThrownBy(() -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))) - .hasMessageContaining("The process has exited with exit code [1]"); + thenThrownBy( + () -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))) + .hasMessageContaining( + "The process has exited with exit code [1]"); } private Process processWithInvalidExitCode() { return new Process() { - @Override public OutputStream getOutputStream() { + @Override + public OutputStream getOutputStream() { return null; } - @Override public InputStream getInputStream() { + @Override + public InputStream getInputStream() { return null; } - @Override public InputStream getErrorStream() { + @Override + public InputStream getErrorStream() { return null; } - @Override public int waitFor() { + @Override + public int waitFor() { return 0; } - @Override public int exitValue() { + @Override + public int exitValue() { return 1; } - @Override public void destroy() { + @Override + public void destroy() { } }; @@ -466,21 +526,6 @@ public class ProjectBuilderTests { return new TestProcessExecutor(workingDir); } - class TestProcessExecutor extends ProcessExecutor { - - int counter = 0; - - TestProcessExecutor(String workingDir) { - super(workingDir); - } - - @Override ProcessBuilder builder(String[] commands, String workingDir) { - this.counter++; - return super.builder(commands, workingDir) - .redirectOutput(tmpFile("/builder/resolved/resolved.log")); - } - } - private File tmpFile(String relativePath) { return new File(this.temporaryFolder, relativePath); } @@ -493,4 +538,21 @@ public class ProjectBuilderTests { return new String(Files.readAllBytes(file.toPath())); } -} \ No newline at end of file + class TestProcessExecutor extends ProcessExecutor { + + int counter = 0; + + TestProcessExecutor(String workingDir) { + super(workingDir); + } + + @Override + ProcessBuilder builder(String[] commands, String workingDir) { + this.counter++; + return super.builder(commands, workingDir) + .redirectOutput(tmpFile("/builder/resolved/resolved.log")); + } + + } + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClientTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClientTests.java index b8c59dcb..38aebd03 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClientTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClientTests.java @@ -1,14 +1,29 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import java.util.Arrays; import java.util.List; -import static org.assertj.core.api.BDDAssertions.then; - import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -19,6 +34,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; +import static org.assertj.core.api.BDDAssertions.then; + /** * @author Marcin Grzejszczak */ @@ -27,7 +44,9 @@ import org.springframework.web.client.RestTemplate; @AutoConfigureStubRunner(ids = "sagan:sagan-site") public class RestTemplateSaganClientTests { - @Value("${stubrunner.runningstubs.sagan-site.port}") Integer saganPort; + @Value("${stubrunner.runningstubs.sagan-site.port}") + Integer saganPort; + SaganClient client; @Before @@ -45,7 +64,8 @@ public class RestTemplateSaganClientTests { then(project.id).isEqualTo("spring-framework"); then(project.name).isEqualTo("Spring Framework"); - then(project.repoUrl).isEqualTo("http://github.com/spring-projects/spring-framework"); + then(project.repoUrl) + .isEqualTo("http://github.com/spring-projects/spring-framework"); then(project.siteUrl).isEqualTo("http://projects.spring.io/spring-framework"); then(project.category).isEqualTo("active"); then(project.stackOverflowTags).isNotBlank(); @@ -54,8 +74,10 @@ public class RestTemplateSaganClientTests { then(project.projectReleases).isNotEmpty(); Release release = project.projectReleases.get(0); then(release.releaseStatus).isEqualTo("PRERELEASE"); - then(release.refDocUrl).isEqualTo("http://docs.spring.io/spring/docs/5.0.0.RC4/spring-framework-reference/"); - then(release.apiDocUrl).isEqualTo("http://docs.spring.io/spring/docs/5.0.0.RC4/javadoc-api/"); + then(release.refDocUrl).isEqualTo( + "http://docs.spring.io/spring/docs/5.0.0.RC4/spring-framework-reference/"); + then(release.apiDocUrl) + .isEqualTo("http://docs.spring.io/spring/docs/5.0.0.RC4/javadoc-api/"); then(release.groupId).isEqualTo("org.springframework"); then(release.artifactId).isEqualTo("spring-context"); then(release.repository.id).isEqualTo("spring-milestones"); @@ -75,8 +97,10 @@ public class RestTemplateSaganClientTests { Release release = this.client.getRelease("spring-framework", "5.0.0.RC4"); then(release.releaseStatus).isEqualTo("PRERELEASE"); - then(release.refDocUrl).isEqualTo("http://docs.spring.io/spring/docs/{version}/spring-framework-reference/"); - then(release.apiDocUrl).isEqualTo("http://docs.spring.io/spring/docs/{version}/javadoc-api/"); + then(release.refDocUrl).isEqualTo( + "http://docs.spring.io/spring/docs/{version}/spring-framework-reference/"); + then(release.apiDocUrl) + .isEqualTo("http://docs.spring.io/spring/docs/{version}/javadoc-api/"); then(release.groupId).isEqualTo("org.springframework"); then(release.artifactId).isEqualTo("spring-context"); then(release.repository.id).isEqualTo("spring-milestones"); @@ -156,7 +180,8 @@ public class RestTemplateSaganClientTests { sithRelease.refDocUrl = "http://docs.spring.io/spring/docs/{version}/spring-framework-reference/htmlsingle/"; sithRelease.apiDocUrl = "http://docs.spring.io/spring/docs/{version}/javadoc-api/"; - List updates = Arrays.asList(firstRelease, secondRelease, thirdRelease, fourthRelease ,fithRelease, sithRelease); + List updates = Arrays.asList(firstRelease, secondRelease, + thirdRelease, fourthRelease, fithRelease, sithRelease); Project project = this.client.updateRelease("spring-framework", updates); @@ -190,8 +215,7 @@ public class RestTemplateSaganClientTests { private RestTemplate restTemplate(ReleaserProperties properties) { return new RestTemplateBuilder() - .basicAuthorization(properties.getGit().getOauthToken(), "") - .build(); + .basicAuthorization(properties.getGit().getOauthToken(), "").build(); } @Configuration @@ -199,4 +223,5 @@ public class RestTemplateSaganClientTests { static class Config { } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/SaganUpdaterTest.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/SaganUpdaterTest.java index 60b327b3..d6d3d1b9 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/SaganUpdaterTest.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/sagan/SaganUpdaterTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import java.util.Arrays; @@ -12,8 +28,8 @@ import org.mockito.Mockito; import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.pom.ProjectVersion; -import static org.mockito.BDDMockito.then; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.never; /** @@ -22,19 +38,17 @@ import static org.mockito.Mockito.never; public class SaganUpdaterTest { SaganClient saganClient = Mockito.mock(SaganClient.class); + ReleaserProperties properties = new ReleaserProperties(); + SaganUpdater saganUpdater = new SaganUpdater(this.saganClient, this.properties); @Before public void setup() { Project project = new Project(); - project.projectReleases.addAll(Arrays.asList( - release("1.0.0.RC1"), - release("1.1.0.BUILD-SNAPSHOT"), - release("2.0.0.M4")) - ); - BDDMockito.given(this.saganClient.getProject(anyString())) - .willReturn(project); + project.projectReleases.addAll(Arrays.asList(release("1.0.0.RC1"), + release("1.1.0.BUILD-SNAPSHOT"), release("2.0.0.M4"))); + BDDMockito.given(this.saganClient.getProject(anyString())).willReturn(project); } private Release release(String version) { @@ -44,7 +58,8 @@ public class SaganUpdaterTest { return release; } - @Test public void should_not_update_sagan_when_switch_is_off() { + @Test + public void should_not_update_sagan_when_switch_is_off() { this.properties.getSagan().setUpdateSagan(false); this.saganUpdater.updateSagan("master", version("1.0.0.M1"), version("1.0.0.M1")); @@ -52,27 +67,33 @@ public class SaganUpdaterTest { then(this.saganClient).shouldHaveZeroInteractions(); } - @Test public void should_update_sagan_for_milestone() { + @Test + public void should_update_sagan_for_milestone() { this.saganUpdater.updateSagan("master", version("1.0.0.M1"), version("1.0.0.M1")); then(this.saganClient).should().updateRelease(BDDMockito.eq("foo"), BDDMockito.argThat(withReleaseUpdate("1.0.0.M1", - "http://cloud.spring.io/spring-cloud-static/foo/{version}/", "PRERELEASE"))); + "http://cloud.spring.io/spring-cloud-static/foo/{version}/", + "PRERELEASE"))); } - @Test public void should_update_sagan_for_rc() { - this.saganUpdater.updateSagan("master", version("1.0.0.RC1"), version("1.0.0.RC1")); + @Test + public void should_update_sagan_for_rc() { + this.saganUpdater.updateSagan("master", version("1.0.0.RC1"), + version("1.0.0.RC1")); then(this.saganClient).should().updateRelease(BDDMockito.eq("foo"), BDDMockito.argThat(withReleaseUpdate("1.0.0.RC1", - "http://cloud.spring.io/spring-cloud-static/foo/{version}/", "PRERELEASE"))); + "http://cloud.spring.io/spring-cloud-static/foo/{version}/", + "PRERELEASE"))); } private ProjectVersion version(String version) { return new ProjectVersion("foo", version); } - @Test public void should_update_sagan_from_master() { + @Test + public void should_update_sagan_from_master() { ProjectVersion projectVersion = version("1.0.0.BUILD-SNAPSHOT"); this.saganUpdater.updateSagan("master", projectVersion, projectVersion); @@ -82,7 +103,8 @@ public class SaganUpdaterTest { "http://cloud.spring.io/foo/foo.html", "SNAPSHOT"))); } - @Test public void should_update_sagan_from_release_version() { + @Test + public void should_update_sagan_from_release_version() { ProjectVersion projectVersion = version("1.0.0.RELEASE"); this.saganUpdater.updateSagan("master", projectVersion, projectVersion); @@ -91,14 +113,16 @@ public class SaganUpdaterTest { then(this.saganClient).should().deleteRelease("foo", "1.0.0.BUILD-SNAPSHOT"); then(this.saganClient).should().updateRelease(BDDMockito.eq("foo"), BDDMockito.argThat(withReleaseUpdate("1.0.0.RELEASE", - "http://cloud.spring.io/spring-cloud-static/foo/{version}/", "GENERAL_AVAILABILITY"))); + "http://cloud.spring.io/spring-cloud-static/foo/{version}/", + "GENERAL_AVAILABILITY"))); then(this.saganClient).should().deleteRelease("foo", "1.0.0.BUILD-SNAPSHOT"); then(this.saganClient).should().updateRelease(BDDMockito.eq("foo"), BDDMockito.argThat(withReleaseUpdate("1.0.1.BUILD-SNAPSHOT", "http://cloud.spring.io/foo/foo.html", "SNAPSHOT"))); } - @Test public void should_update_sagan_from_non_master() { + @Test + public void should_update_sagan_from_non_master() { ProjectVersion projectVersion = version("1.1.0.BUILD-SNAPSHOT"); this.saganUpdater.updateSagan("1.1.x", projectVersion, projectVersion); @@ -111,15 +135,13 @@ public class SaganUpdaterTest { private ArgumentMatcher> withReleaseUpdate(final String version, final String refDocUrl, final String releaseStatus) { - return argument -> { + return argument -> { ReleaseUpdate item = argument.get(0); - return "foo".equals(item.artifactId) && - releaseStatus.equals(item.releaseStatus) && - version.equals(item.version) && - refDocUrl.equals(item.apiDocUrl) && - refDocUrl.equals(item.refDocUrl) && - item.current; - }; + return "foo".equals(item.artifactId) + && releaseStatus.equals(item.releaseStatus) + && version.equals(item.version) && refDocUrl.equals(item.apiDocUrl) + && refDocUrl.equals(item.refDocUrl) && item.current; + }; } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/template/TemplateGeneratorTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/template/TemplateGeneratorTests.java index fc0af337..041c02c2 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/template/TemplateGeneratorTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/template/TemplateGeneratorTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.template; import java.io.File; @@ -6,6 +22,7 @@ import java.nio.file.Files; import java.util.HashSet; import org.junit.Test; + import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.git.ProjectGitHandler; import org.springframework.cloud.release.internal.pom.ProjectVersion; @@ -19,6 +36,7 @@ import static org.assertj.core.api.BDDAssertions.then; public class TemplateGeneratorTests { ReleaserProperties props = new ReleaserProperties(); + ProjectGitHandler handler = new ProjectGitHandler(this.props) { @Override public String milestoneUrl(ProjectVersion releaseVersion) { @@ -30,7 +48,8 @@ public class TemplateGeneratorTests { public void should_generate_email_from_template_for_tag_with_v_prefix() { this.props.getPom().setBranch("vDalston.RELEASE"); - File generatedMail = new TemplateGenerator(this.props, this.handler).email(new Projects()); + File generatedMail = new TemplateGenerator(this.props, this.handler) + .email(new Projects()); then(generatedMail).hasContent(expectedEmail()); } @@ -39,8 +58,9 @@ public class TemplateGeneratorTests { public void should_generate_email_from_template_when_output_folder_is_missing() { this.props.getPom().setBranch("vDalston.RELEASE"); - File generatedMail = new TemplateGenerator(this.props, new File("target/foo/bar/baz/template.txt"), - this.handler).email(new Projects()); + File generatedMail = new TemplateGenerator(this.props, + new File("target/foo/bar/baz/template.txt"), this.handler) + .email(new Projects()); then(generatedMail).hasContent(expectedEmail()); } @@ -49,7 +69,8 @@ public class TemplateGeneratorTests { public void should_generate_email_from_template_for_tag_without_v_prefix() { this.props.getPom().setBranch("Dalston.RELEASE"); - File generatedMail = new TemplateGenerator(this.props, this.handler).email(new Projects()); + File generatedMail = new TemplateGenerator(this.props, this.handler) + .email(new Projects()); then(generatedMail).hasContent(expectedEmail()); } @@ -58,7 +79,8 @@ public class TemplateGeneratorTests { public void should_generate_tweet_from_template_for_tag_with_v_prefix() { this.props.getPom().setBranch("vDalston.RELEASE"); - File generatedTweet = new TemplateGenerator(this.props, this.handler).tweet(new Projects()); + File generatedTweet = new TemplateGenerator(this.props, this.handler) + .tweet(new Projects()); then(generatedTweet).hasContent(expectedTweet()); } @@ -67,7 +89,8 @@ public class TemplateGeneratorTests { public void should_generate_tweet_from_template_for_tag_without_v_prefix() { this.props.getPom().setBranch("Dalston.RELEASE"); - File generatedTweet = new TemplateGenerator(this.props, this.handler).tweet(new Projects()); + File generatedTweet = new TemplateGenerator(this.props, this.handler) + .tweet(new Projects()); then(generatedTweet).hasContent(expectedTweet()); } @@ -76,209 +99,227 @@ public class TemplateGeneratorTests { public void should_generate_blog_from_template_for_tag_with_v_prefix_release() throws IOException { this.props.getPom().setBranch("vDalston.RELEASE"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.RELEASE")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.RELEASE")); + } + }); - File generatedBlog = new TemplateGenerator(this.props, this.handler).blog(projects); + File generatedBlog = new TemplateGenerator(this.props, this.handler) + .blog(projects); then(content(generatedBlog)) .contains("General Availability (RELEASE) of the [Spring Cloud Dalston]") .contains("The release can be found in [Maven Central]") .contains("### Spring Cloud Sleuth") - .contains("| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](http://foo.bar.com))") - .contains("Dalston.RELEASE") - .contains("mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE'"); + .contains( + "| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](http://foo.bar.com))") + .contains("Dalston.RELEASE").contains( + "mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE'"); } @Test public void should_generate_blog_from_template_for_tag_without_v_prefix_release() throws IOException { this.props.getPom().setBranch("Dalston.RELEASE"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.RELEASE")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.RELEASE")); + } + }); - File generatedBlog = new TemplateGenerator(this.props, this.handler).blog(projects); + File generatedBlog = new TemplateGenerator(this.props, this.handler) + .blog(projects); then(content(generatedBlog)) .contains("General Availability (RELEASE) of the [Spring Cloud Dalston]") .contains("The release can be found in [Maven Central]") .contains("### Spring Cloud Sleuth") - .contains("| Spring Cloud Sleuth\t| 1.0.0.RELEASE\t| ([issues](http://foo.bar.com))") - .contains("Dalston.RELEASE") - .contains("mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE'"); + .contains( + "| Spring Cloud Sleuth\t| 1.0.0.RELEASE\t| ([issues](http://foo.bar.com))") + .contains("Dalston.RELEASE").contains( + "mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE'"); } @Test public void should_generate_sr_blog_from_template_for_tag_with_v_prefix_release() throws IOException { this.props.getPom().setBranch("vDalston.SR1"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.RELEASE")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.RELEASE")); + } + }); - File generatedBlog = new TemplateGenerator(this.props, this.handler).blog(projects); + File generatedBlog = new TemplateGenerator(this.props, this.handler) + .blog(projects); then(content(generatedBlog)) .contains("Service Release 1 (SR1) of the [Spring Cloud Dalston]") .contains("The release can be found in [Maven Central]") .contains("### Spring Cloud Sleuth") - .contains("| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](http://foo.bar.com))") - .contains("Dalston.SR1") - .contains("mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.SR1'"); + .contains( + "| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](http://foo.bar.com))") + .contains("Dalston.SR1").contains( + "mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.SR1'"); } @Test public void should_generate_sr_blog_from_template_for_tag_without_v_prefix_release() throws IOException { this.props.getPom().setBranch("Dalston.SR1"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.RELEASE")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RELEASE")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.RELEASE")); + } + }); - File generatedBlog = new TemplateGenerator(this.props, this.handler).blog(projects); + File generatedBlog = new TemplateGenerator(this.props, this.handler) + .blog(projects); then(content(generatedBlog)) .contains("Service Release 1 (SR1) of the [Spring Cloud Dalston]") .contains("The release can be found in [Maven Central]") .contains("### Spring Cloud Sleuth") - .contains("| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](http://foo.bar.com))") - .contains("Dalston.SR1") - .contains("mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.SR1'"); + .contains( + "| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](http://foo.bar.com))") + .contains("Dalston.SR1").contains( + "mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.SR1'"); } @Test public void should_generate_milestone_blog_from_template_for_tag_with_v_prefix_release() throws IOException { this.props.getPom().setBranch("vDalston.M1"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.M1")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.M1")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.M1")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.M1")); + } + }); - File generatedBlog = new TemplateGenerator(this.props, this.handler).blog(projects); + File generatedBlog = new TemplateGenerator(this.props, this.handler) + .blog(projects); then(content(generatedBlog)) .contains("Milestone 1 (M1) of the [Spring Cloud Dalston]") .contains("The release can be found in [Spring Milestone]") .contains("### Spring Cloud Sleuth") - .contains("| Spring Cloud Sleuth\t| 1.0.0.M1\t| ([issues](http://foo.bar.com))") + .contains( + "| Spring Cloud Sleuth\t| 1.0.0.M1\t| ([issues](http://foo.bar.com))") .contains("spring-milestones") .contains("url 'http://repo.spring.io/milestone'") - .contains("Dalston.M1") - .contains("mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.M1'"); + .contains("Dalston.M1").contains( + "mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.M1'"); } @Test public void should_generate_milestone_blog_from_template_for_tag_without_v_prefix_release() throws IOException { this.props.getPom().setBranch("Dalston.M1"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.M1")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.M1")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.M1")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.M1")); + } + }); - File generatedBlog = new TemplateGenerator(this.props, this.handler).blog(projects); + File generatedBlog = new TemplateGenerator(this.props, this.handler) + .blog(projects); then(content(generatedBlog)) .contains("Milestone 1 (M1) of the [Spring Cloud Dalston]") .contains("The release can be found in [Spring Milestone]") .contains("### Spring Cloud Sleuth") - .contains("| Spring Cloud Sleuth\t| 1.0.0.M1\t| ([issues](http://foo.bar.com))") + .contains( + "| Spring Cloud Sleuth\t| 1.0.0.M1\t| ([issues](http://foo.bar.com))") .contains("spring-milestones") .contains("url 'http://repo.spring.io/milestone'") - .contains("Dalston.M1") - .contains("mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.M1'"); + .contains("Dalston.M1").contains( + "mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.M1'"); } @Test public void should_generate_rc_blog_from_template_for_tag_with_v_prefix_release() throws IOException { this.props.getPom().setBranch("vDalston.RC1"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RC1")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.RC1")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RC1")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.RC1")); + } + }); - File generatedBlog = new TemplateGenerator(this.props, this.handler).blog(projects); + File generatedBlog = new TemplateGenerator(this.props, this.handler) + .blog(projects); then(content(generatedBlog)) .contains("Release Candidate 1 (RC1) of the [Spring Cloud Dalston]") .contains("The release can be found in [Spring Milestone]") .contains("### Spring Cloud Sleuth") - .contains("| Spring Cloud Sleuth\t| 1.0.0.RC1\t| ([issues](http://foo.bar.com))") + .contains( + "| Spring Cloud Sleuth\t| 1.0.0.RC1\t| ([issues](http://foo.bar.com))") .contains("spring-milestones") .contains("url 'http://repo.spring.io/milestone'") - .contains("Dalston.RC1") - .contains("mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RC1'"); + .contains("Dalston.RC1").contains( + "mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RC1'"); } @Test public void should_generate_rc_blog_from_template_for_tag_without_v_prefix_release() throws IOException { this.props.getPom().setBranch("Dalston.RC1"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RC1")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.RC1")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RC1")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.RC1")); + } + }); - File generatedBlog = new TemplateGenerator(this.props, this.handler).blog(projects); + File generatedBlog = new TemplateGenerator(this.props, this.handler) + .blog(projects); then(content(generatedBlog)) .contains("Release Candidate 1 (RC1) of the [Spring Cloud Dalston]") .contains("The release can be found in [Spring Milestone]") .contains("### Spring Cloud Sleuth") - .contains("| Spring Cloud Sleuth\t| 1.0.0.RC1\t| ([issues](http://foo.bar.com))") + .contains( + "| Spring Cloud Sleuth\t| 1.0.0.RC1\t| ([issues](http://foo.bar.com))") .contains("spring-milestones") .contains("url 'http://repo.spring.io/milestone'") - .contains("Dalston.RC1") - .contains("mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RC1'"); + .contains("Dalston.RC1").contains( + "mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RC1'"); } @Test public void should_generate_release_notes_template_when_url_exists() throws IOException { ProjectGitHandler handler = new ProjectGitHandler(this.props) { - @Override public String milestoneUrl(ProjectVersion releaseVersion) { + @Override + public String milestoneUrl(ProjectVersion releaseVersion) { return "http://foo.bar.com?closed=1"; } }; this.props.getPom().setBranch("Dalston.RC1"); - Projects projects = new Projects( - new HashSet() {{ - add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RC1")); - add(new ProjectVersion("spring-cloud-consul", "1.0.1.RC1")); - add(new ProjectVersion("spring-boot-dependencies", "1.0.1.RC1")); - }} - ); + Projects projects = new Projects(new HashSet() { + { + add(new ProjectVersion("spring-cloud-sleuth", "1.0.0.RC1")); + add(new ProjectVersion("spring-cloud-consul", "1.0.1.RC1")); + add(new ProjectVersion("spring-boot-dependencies", "1.0.1.RC1")); + } + }); - File generatedOutput = new TemplateGenerator(this.props, handler).releaseNotes(projects); + File generatedOutput = new TemplateGenerator(this.props, handler) + .releaseNotes(projects); - then(content(generatedOutput)) - .contains("# Dalston.RC1") - .contains("Spring Cloud Sleuth `1.0.0.RC1` ([issues](http://foo.bar.com?closed=1))") - .contains("Spring Cloud Consul `1.0.1.RC1` ([issues](http://foo.bar.com?closed=1))") + then(content(generatedOutput)).contains("# Dalston.RC1").contains( + "Spring Cloud Sleuth `1.0.0.RC1` ([issues](http://foo.bar.com?closed=1))") + .contains( + "Spring Cloud Consul `1.0.1.RC1` ([issues](http://foo.bar.com?closed=1))") .doesNotContain("Boot"); } @@ -287,18 +328,14 @@ public class TemplateGeneratorTests { } private String expectedEmail() { - return "Title:\n" - + "Spring Cloud Dalston.RELEASE available\n\n" - + "Content:\n" + return "Title:\n" + "Spring Cloud Dalston.RELEASE available\n\n" + "Content:\n" + "All,\n" + "\n" + "On behalf of the team and the community, I'm excited to announce Spring Cloud Dalston RELEASE Train release.\n" - + "\n" - + "link to blog post\n" - + "link to twitter\n\n" - + "Cheers,\n"; + + "\n" + "link to blog post\n" + "link to twitter\n\n" + "Cheers,\n"; } private String expectedTweet() { return "The Dalston.RELEASE version of @springcloud has been released!"; } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom.xml index 22fadf05..63aaf110 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_case_from_contract.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_case_from_contract.xml index eeea0f1f..f73d2a6c 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_case_from_contract.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_case_from_contract.xml @@ -17,7 +17,7 @@ limitations under the License. --> - 4.0.0 @@ -105,7 +105,8 @@ Test org.junit.rules.ErrorCollector - com.blogspot.toomuchcoding.frauddetection.matchers.CustomMatchers.* + com.blogspot.toomuchcoding.frauddetection.matchers.CustomMatchers.* + com.blogspot.toomuchcoding.frauddetection.matchers.CustomMatchers diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group.xml index 2da88924..b7460ff4 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 @@ -31,7 +31,7 @@ org.foo.bar foo-bar 1.5.8.RELEASE - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_boot_parent.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_boot_parent.xml index 4b2f7f49..851074d2 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_boot_parent.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_boot_parent.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 @@ -28,7 +28,7 @@ org.springframework.boot spring-boot-starter-parent 1.5.8.RELEASE - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_plugin.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_plugin.xml index 9d437c14..5a7b174b 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_plugin.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_plugin.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 @@ -31,7 +31,7 @@ org.springframework.boot spring-boot-starter-parent 1.5.8.RELEASE - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_plugin_mngmnt.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_plugin_mngmnt.xml index 11100e63..44e0579f 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_plugin_mngmnt.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_plugin_mngmnt.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 @@ -31,7 +31,7 @@ org.springframework.boot spring-boot-starter-parent 1.5.8.RELEASE - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_prop.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_prop.xml index 7a2a0458..adcd9584 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_prop.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_different_group_skip_deployment_prop.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 @@ -31,7 +31,7 @@ org.springframework.boot spring-boot-starter-parent 1.5.8.RELEASE - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_artifact.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_artifact.xml index 23e899ab..ab137ecb 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_artifact.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_artifact.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_parent.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_parent.xml index b6a155d1..c7fb46b2 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_parent.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_parent.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_parent_v2.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_parent_v2.xml index b6a155d1..c7fb46b2 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_parent_v2.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_parent_v2.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_properties.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_properties.xml index 75c810fa..cc2d1389 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_properties.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/children/pom_matching_properties.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom.xml index f02671f4..62c54e27 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_artifact.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_artifact.xml index 542a1a94..989e6ff2 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_artifact.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_artifact.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_artifact_same_version.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_artifact_same_version.xml index 5a059c9f..91ea7115 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_artifact_same_version.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_artifact_same_version.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_parent.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_parent.xml index ee3ecd24..284959ca 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_parent.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_parent.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_parent_v2.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_parent_v2.xml index ee3ecd24..284959ca 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_parent_v2.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_parent_v2.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_properties.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_properties.xml index 611a766a..ac53205b 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_properties.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_properties.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_with_parent_suffix.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_with_parent_suffix.xml index 5a8a2e9b..07a37c8a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_with_parent_suffix.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_matching_with_parent_suffix.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_with_parent_suffix.xml b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_with_parent_suffix.xml index 6b774e93..fb8ba317 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_with_parent_suffix.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/project/pom_with_parent_suffix.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/.gitignore b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/.gitignore index 8db262c5..bd9bb4ce 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/.gitignore +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/.gitignore @@ -13,4 +13,4 @@ _site/ *.ipr .factorypath *.swp -/consul \ No newline at end of file +/consul diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/pom.xml index 14e930a3..8b094250 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/spring-cloud-starter-consul/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/spring-cloud-starter-consul/pom.xml index 3fe60ad8..36326190 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/spring-cloud-starter-consul/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-consul/spring-cloud-starter-consul/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/pom.xml index dcae48f3..8fc118e0 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-dependencies/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-dependencies/pom.xml index 2ea7e734..040b6906 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-dependencies/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-dependencies/pom.xml @@ -1,12 +1,12 @@ - 4.0.0 spring-cloud-dependencies-parent org.springframework.cloud 1.3.1.BUILD-SNAPSHOT - + spring-cloud-contract-dependencies 1.1.0.BUILD-SNAPSHOT diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-tools/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-tools/pom.xml index dfe7b507..c324f509 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-tools/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-tools/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-tools/spring-cloud-contract-converters/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-tools/spring-cloud-contract-converters/pom.xml index cb274e94..875b7e65 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-tools/spring-cloud-contract-converters/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-contract/spring-cloud-contract-tools/spring-cloud-contract-converters/pom.xml @@ -1,5 +1,5 @@ - 4.0.0 @@ -12,7 +12,9 @@ jar Spring Cloud Contract Converters Spring Cloud Contract Converters - 1.8 + + 1.8 + org.springframework diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/.settings.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/.settings.xml index 6c355129..6f542c94 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/.settings.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/.settings.xml @@ -1,66 +1,68 @@ - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - true - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - http://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - - + + + repo.spring.io + ${env.CI_DEPLOY_USERNAME} + ${env.CI_DEPLOY_PASSWORD} + + + + + + spring + + true + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + http://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/.travis.yml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/.travis.yml index ca6831bf..e1f3e158 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/.travis.yml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/.travis.yml @@ -13,9 +13,9 @@ before_install: - git config credential.helper "store --file=.git/credentials" - echo "https://$GH_TOKEN:@github.com" > .git/credentials install: -- ./mvnw --fail-at-end --update-snapshots clean package -Dmaven.test.redirectTestOutputToFile=true + - ./mvnw --fail-at-end --update-snapshots clean package -Dmaven.test.redirectTestOutputToFile=true env: global: - - GIT_NAME="Dave Syer" - - GIT_EMAIL=dsyer@pivotal.io - - CI_DEPLOY_USERNAME=buildmaster + - GIT_NAME="Dave Syer" + - GIT_EMAIL=dsyer@pivotal.io + - CI_DEPLOY_USERNAME=buildmaster diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/pom.xml index 1b2351e1..1584a99e 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/main/java/demo/BootstrapClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/main/java/demo/BootstrapClientApplication.java index 92819271..7558fe17 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/main/java/demo/BootstrapClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/main/java/demo/BootstrapClientApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -12,4 +28,5 @@ public class BootstrapClientApplication { public static void main(String[] args) { SpringApplication.run(BootstrapClientApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/main/resources/bootstrap.yml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/main/resources/bootstrap.yml index fb274ac4..45ad0556 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/main/resources/bootstrap.yml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/main/resources/bootstrap.yml @@ -1,7 +1,7 @@ spring: config: -# N.B. you don't normally want to do this in a real app. It switches -# off the local application.yml: + # N.B. you don't normally want to do this in a real app. It switches + # off the local application.yml: name: sample logging: level: diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/test/java/demo/BootstrapClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/test/java/demo/BootstrapClientApplicationTests.java index 50daed27..9568e80d 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/test/java/demo/BootstrapClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bootstrap/src/test/java/demo/BootstrapClientApplicationTests.java @@ -1,9 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertEquals; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.test.context.SpringBootTest; @@ -12,7 +27,7 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext public class BootstrapClientApplicationTests { @@ -21,9 +36,9 @@ public class BootstrapClientApplicationTests { @Test public void contextLoads() throws Exception { - assertEquals(2, this.server.getTomcat().getMaxThreads()); + assertThat(2).isEqualTo(this.server.getTomcat().getMaxThreads()); // The application.yml is never read because spring.config.name=sample - assertEquals("application", this.server.getServlet().getApplicationDisplayName()); + assertThat("application").isEqualTo(this.server.getServlet().getApplicationDisplayName()); } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/pom.xml index 96a0ef02..90d3856f 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/src/main/java/demo/StandaloneClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/src/main/java/demo/StandaloneClientApplication.java index 79855f8c..6ef13436 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/src/main/java/demo/StandaloneClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/src/main/java/demo/StandaloneClientApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -12,4 +28,5 @@ public class StandaloneClientApplication { public static void main(String[] args) { SpringApplication.run(StandaloneClientApplication.class, args); } + } \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/src/test/java/demo/StandaloneClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/src/test/java/demo/StandaloneClientApplicationTests.java index 8c3e9c58..8e84ca7f 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/src/test/java/demo/StandaloneClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/bus/src/test/java/demo/StandaloneClientApplicationTests.java @@ -1,15 +1,32 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertNotNull; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertNotNull; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/pom.xml index a24340c8..fd4cfdaa 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/src/main/java/demo/BootstrapDecryptionClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/src/main/java/demo/BootstrapDecryptionClientApplication.java index a6485d38..102593f6 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/src/main/java/demo/BootstrapDecryptionClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/src/main/java/demo/BootstrapDecryptionClientApplication.java @@ -1,7 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; @@ -15,7 +32,8 @@ import org.springframework.core.env.Environment; @SpringBootApplication public class BootstrapDecryptionClientApplication implements CommandLineRunner { - private static Log logger = LogFactory.getLog(BootstrapDecryptionClientApplication.class); + private static Log logger = LogFactory + .getLog(BootstrapDecryptionClientApplication.class); @Autowired private ConfigClientProperties config; @@ -23,6 +41,10 @@ public class BootstrapDecryptionClientApplication implements CommandLineRunner { @Autowired private Environment environment; + public static void main(String[] args) { + SpringApplication.run(BootstrapDecryptionClientApplication.class, args); + } + @Override public void run(String... args) throws Exception { logger.info("Config Server URI: " + this.config.getUri()); @@ -30,7 +52,4 @@ public class BootstrapDecryptionClientApplication implements CommandLineRunner { logger.info("And info.spam: " + this.environment.getProperty("info.spam")); } - public static void main(String[] args) { - SpringApplication.run(BootstrapDecryptionClientApplication.class, args); - } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/src/test/java/demo/BootstrapDecryptionClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/src/test/java/demo/BootstrapDecryptionClientApplicationTests.java index 051aed2f..3fb9562b 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/src/test/java/demo/BootstrapDecryptionClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client-decrypt/src/test/java/demo/BootstrapDecryptionClientApplicationTests.java @@ -1,11 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.config.client.ConfigClientProperties; @@ -13,6 +26,8 @@ import org.springframework.cloud.config.client.ConfigServicePropertySourceLocato import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertNotNull; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -26,8 +41,9 @@ public class BootstrapDecryptionClientApplicationTests { @Test public void contextLoads() throws Exception { - assertArrayEquals(new String[]{"http://localhost:8888"}, this.config.getUri()); - assertNotNull(this.locator); + assertThat(new String[] { "http://localhost:8888" }).isEqualTo(this.config.getUri()); + // The application.yml is never read because spring.config.name=sample + assertThat(this.locator).isNotNull(); } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/pom.xml index 9223be67..6d99a2ff 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/src/main/java/demo/StandaloneClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/src/main/java/demo/StandaloneClientApplication.java index 5e1a1428..3e2f6b2e 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/src/main/java/demo/StandaloneClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/src/main/java/demo/StandaloneClientApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -12,4 +28,5 @@ public class StandaloneClientApplication { public static void main(String[] args) { SpringApplication.run(StandaloneClientApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/src/test/java/demo/StandaloneClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/src/test/java/demo/StandaloneClientApplicationTests.java index 8c3e9c58..8e84ca7f 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/src/test/java/demo/StandaloneClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-client/src/test/java/demo/StandaloneClientApplicationTests.java @@ -1,15 +1,32 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertNotNull; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertNotNull; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/pom.xml index 6ea8e0e5..f305c72b 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/main/java/bootstrap/RetryConfiguration.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/main/java/bootstrap/RetryConfiguration.java index 474d3841..0fc42c8b 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/main/java/bootstrap/RetryConfiguration.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/main/java/bootstrap/RetryConfiguration.java @@ -14,10 +14,27 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package bootstrap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.retry.interceptor.RetryInterceptorBuilder; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/main/java/demo/StandaloneClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/main/java/demo/StandaloneClientApplication.java index 77951444..0dc150d3 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/main/java/demo/StandaloneClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/main/java/demo/StandaloneClientApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -11,7 +27,8 @@ import org.springframework.boot.builder.SpringApplicationBuilder; public class StandaloneClientApplication { public static void main(String[] args) { - new SpringApplicationBuilder(StandaloneClientApplication.class).properties( - "spring.cloud.config.enabled=true").run(args); + new SpringApplicationBuilder(StandaloneClientApplication.class) + .properties("spring.cloud.config.enabled=true").run(args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/test/java/apps/ConfigServer.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/test/java/apps/ConfigServer.java index 45134f3c..ee040ef0 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/test/java/apps/ConfigServer.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/test/java/apps/ConfigServer.java @@ -14,6 +14,22 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package apps; import org.springframework.boot.Banner.Mode; @@ -35,8 +51,7 @@ public class ConfigServer { } public static ConfigurableApplicationContext start(String... args) { - return new SpringApplicationBuilder(ConfigServer.class) - .bannerMode(Mode.OFF) + return new SpringApplicationBuilder(ConfigServer.class).bannerMode(Mode.OFF) .profiles("native") .properties("server.port=8888", "spring.cloud.config.server.native.searchLocation:file:./src/test/resources/config/") diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/test/java/demo/StandaloneClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/test/java/demo/StandaloneClientApplicationTests.java index 4070c80e..2e76422e 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/test/java/demo/StandaloneClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/config-retry/src/test/java/demo/StandaloneClientApplicationTests.java @@ -1,18 +1,32 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +package demo; import java.lang.reflect.Method; import java.util.Map; import java.util.concurrent.Executors; +import apps.ConfigServer; import org.aopalliance.intercept.MethodInterceptor; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -27,20 +41,20 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.util.ReflectionTestUtils; -import apps.ConfigServer; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; @RunWith(SpringRunner.class) // Explicitly enable config client because test classpath has config server on it -@SpringBootTest(properties={ "spring.cloud.config.enabled=true", +@SpringBootTest(properties = { "spring.cloud.config.enabled=true", "logging.level.org.springframework.retry=TRACE" }) @DirtiesContext public class StandaloneClientApplicationTests { + private static ConfigurableApplicationContext context; @Autowired private ConfigServicePropertySourceLocator locator; - private static ConfigurableApplicationContext context; - @BeforeClass public static void delayConfigServer() { Executors.newSingleThreadExecutor().execute(new Runnable() { @@ -55,10 +69,10 @@ public class StandaloneClientApplicationTests { } }); } - + @AfterClass public static void shutdown() { - if (context!=null) { + if (context != null) { context.close(); } } @@ -72,21 +86,23 @@ public class StandaloneClientApplicationTests { @SuppressWarnings("unchecked") Map delegates = (Map) ReflectionTestUtils .getField(advice, "delegates"); - Object obj = delegates - .values().iterator().next(); + Object obj = delegates.values().iterator().next(); RetryTemplate retryTemplate = null; - if(RetryOperationsInterceptor.class.isInstance(obj)) { - //Prior to Boot 1.5.10 - RetryOperationsInterceptor interceptor = (RetryOperationsInterceptor)obj; - retryTemplate = (RetryTemplate) ReflectionTestUtils.getField( - interceptor, "retryOperations"); - } else if(Map.class.isInstance(obj)) { - //Boot 1.5.10 and later - Object[] methodInterceptors = ((Map)obj).values().toArray(); - RetryOperationsInterceptor interceptor = (RetryOperationsInterceptor)methodInterceptors[0]; - retryTemplate = (RetryTemplate)ReflectionTestUtils.getField( - interceptor, "retryOperations");; - } else { + if (RetryOperationsInterceptor.class.isInstance(obj)) { + // Prior to Boot 1.5.10 + RetryOperationsInterceptor interceptor = (RetryOperationsInterceptor) obj; + retryTemplate = (RetryTemplate) ReflectionTestUtils.getField(interceptor, + "retryOperations"); + } + else if (Map.class.isInstance(obj)) { + // Boot 1.5.10 and later + Object[] methodInterceptors = ((Map) obj).values().toArray(); + RetryOperationsInterceptor interceptor = (RetryOperationsInterceptor) methodInterceptors[0]; + retryTemplate = (RetryTemplate) ReflectionTestUtils.getField(interceptor, + "retryOperations"); + ; + } + else { fail("Could not find RetryTemplate"); } ExponentialBackOffPolicy backoff = (ExponentialBackOffPolicy) ReflectionTestUtils diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/pom.xml index dd761081..3b528e1a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/src/main/java/demo/ConfigServerBootstrapApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/src/main/java/demo/ConfigServerBootstrapApplication.java index 0968a0a6..97638703 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/src/main/java/demo/ConfigServerBootstrapApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/src/main/java/demo/ConfigServerBootstrapApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/src/test/java/demo/ConfigServerEurekaApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/src/test/java/demo/ConfigServerEurekaApplicationTests.java index 9120268d..ff89af1c 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/src/test/java/demo/ConfigServerEurekaApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-bootstrap/src/test/java/demo/ConfigServerEurekaApplicationTests.java @@ -1,7 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/pom.xml index 35c92a3f..f9e49e37 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/src/main/java/demo/ConfigServerEurekaApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/src/main/java/demo/ConfigServerEurekaApplication.java index 8cf43b4f..47569e2a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/src/main/java/demo/ConfigServerEurekaApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/src/main/java/demo/ConfigServerEurekaApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/src/test/java/demo/ConfigServerEurekaApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/src/test/java/demo/ConfigServerEurekaApplicationTests.java index fad3c27d..33d7b363 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/src/test/java/demo/ConfigServerEurekaApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver-eureka/src/test/java/demo/ConfigServerEurekaApplicationTests.java @@ -1,9 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -12,6 +27,8 @@ import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -26,9 +43,12 @@ public class ConfigServerEurekaApplicationTests { @Test public void discoveryClientIsEureka() { - assertTrue("discoveryClient is wrong type", discoveryClient instanceof CompositeDiscoveryClient); - assertTrue("composite discovery client should have a Eureka client with higher precendence" - , ((CompositeDiscoveryClient)discoveryClient).getDiscoveryClients().get(0) instanceof EurekaDiscoveryClient); + assertTrue("discoveryClient is wrong type", + discoveryClient instanceof CompositeDiscoveryClient); + assertTrue( + "composite discovery client should have a Eureka client with higher precendence", + ((CompositeDiscoveryClient) discoveryClient).getDiscoveryClients() + .get(0) instanceof EurekaDiscoveryClient); } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/pom.xml index f458196f..f68b54a8 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/src/main/java/demo/ConfigServerApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/src/main/java/demo/ConfigServerApplication.java index 98cb9f36..17f35a8d 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/src/main/java/demo/ConfigServerApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/src/main/java/demo/ConfigServerApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/src/test/java/demo/ConfigServerApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/src/test/java/demo/ConfigServerApplicationTests.java index a98bd1cf..e7293b19 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/src/test/java/demo/ConfigServerApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/configserver/src/test/java/demo/ConfigServerApplicationTests.java @@ -1,7 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/pom.xml index 43e497cb..bb171aac 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/src/main/java/demo/EurekaClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/src/main/java/demo/EurekaClientApplication.java index 23125049..04111929 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/src/main/java/demo/EurekaClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/src/main/java/demo/EurekaClientApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -16,13 +32,14 @@ import org.springframework.web.bind.annotation.RestController; @RestController public class EurekaClientApplication { + public static void main(String[] args) { + SpringApplication.run(EurekaClientApplication.class, args); + } + @RequestMapping("/good") - public String good(@RequestParam MultiValueMap params) { + public String good(@RequestParam MultiValueMap params) { System.err.println(params); return "GOOD!"; } - public static void main(String[] args) { - SpringApplication.run(EurekaClientApplication.class, args); - } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/src/test/java/demo/EurekaClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/src/test/java/demo/EurekaClientApplicationTests.java index 46deec8d..d3e4fa7e 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/src/test/java/demo/EurekaClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-client/src/test/java/demo/EurekaClientApplicationTests.java @@ -1,15 +1,32 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertNotNull; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertNotNull; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/pom.xml index f3d747d6..4b666e20 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/src/main/java/demo/EurekaFirstApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/src/main/java/demo/EurekaFirstApplication.java index 50c6f7d4..db4cfd04 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/src/main/java/demo/EurekaFirstApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/src/main/java/demo/EurekaFirstApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -11,4 +27,5 @@ public class EurekaFirstApplication { public static void main(String[] args) { SpringApplication.run(EurekaFirstApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/src/test/java/demo/EurekaFirstApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/src/test/java/demo/EurekaFirstApplicationTests.java index 96cc9d7f..37a2f367 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/src/test/java/demo/EurekaFirstApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-first/src/test/java/demo/EurekaFirstApplicationTests.java @@ -1,9 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -12,6 +27,8 @@ import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -26,10 +43,12 @@ public class EurekaFirstApplicationTests { @Test public void discoveryClientIsEureka() { - assertTrue("discoveryClient is wrong type: " + discoveryClient, + assertTrue("discoveryClient is wrong type: " + discoveryClient, discoveryClient instanceof CompositeDiscoveryClient); - assertTrue("composite discovery client should have a Eureka client with higher precendence" - , ((CompositeDiscoveryClient)discoveryClient).getDiscoveryClients().get(0) instanceof EurekaDiscoveryClient); + assertTrue( + "composite discovery client should have a Eureka client with higher precendence", + ((CompositeDiscoveryClient) discoveryClient).getDiscoveryClients() + .get(0) instanceof EurekaDiscoveryClient); } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/pom.xml index 51c83da3..7cda50e6 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/main/java/demo/StandaloneClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/main/java/demo/StandaloneClientApplication.java index 77192159..5b998753 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/main/java/demo/StandaloneClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/main/java/demo/StandaloneClientApplication.java @@ -1,9 +1,26 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; @@ -24,13 +41,14 @@ public class StandaloneClientApplication implements CommandLineRunner { @Autowired private DiscoveryClient client; - @Override - public void run(String... args) throws Exception { - List services = client.getServices(); - logger.info("Services: " + services ); - } - public static void main(String[] args) { SpringApplication.run(StandaloneClientApplication.class, args); } + + @Override + public void run(String... args) throws Exception { + List services = client.getServices(); + logger.info("Services: " + services); + } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/test/java/demo/DefaultStandaloneClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/test/java/demo/DefaultStandaloneClientApplicationTests.java index ef83ed90..e3f5c9fa 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/test/java/demo/DefaultStandaloneClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/test/java/demo/DefaultStandaloneClientApplicationTests.java @@ -1,7 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/test/java/demo/StandaloneClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/test/java/demo/StandaloneClientApplicationTests.java index 14188170..ef43b1d8 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/test/java/demo/StandaloneClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-noweb/src/test/java/demo/StandaloneClientApplicationTests.java @@ -1,9 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -12,6 +27,8 @@ import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -22,9 +39,12 @@ public class StandaloneClientApplicationTests { @Test public void testDiscoveryClientIsEureka() { - assertTrue("discoveryClient is wrong instance type", discoveryClient instanceof CompositeDiscoveryClient); - assertTrue("composite discovery client should have a Eureka client with higher precendence" - , ((CompositeDiscoveryClient)discoveryClient).getDiscoveryClients().get(0) instanceof EurekaDiscoveryClient); + assertTrue("discoveryClient is wrong instance type", + discoveryClient instanceof CompositeDiscoveryClient); + assertTrue( + "composite discovery client should have a Eureka client with higher precendence", + ((CompositeDiscoveryClient) discoveryClient).getDiscoveryClients() + .get(0) instanceof EurekaDiscoveryClient); } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/pom.xml index 85235745..e800dcb3 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/src/main/java/demo/EurekaApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/src/main/java/demo/EurekaApplication.java index ea0586e4..bb19907e 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/src/main/java/demo/EurekaApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/src/main/java/demo/EurekaApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -8,7 +24,8 @@ import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @EnableEurekaServer public class EurekaApplication { - public static void main(String[] args) { - SpringApplication.run(EurekaApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(EurekaApplication.class, args); + } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/src/test/java/demo/EurekaServerApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/src/test/java/demo/EurekaServerApplicationTests.java index c2d3898c..6d83158a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/src/test/java/demo/EurekaServerApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/eureka-server/src/test/java/demo/EurekaServerApplicationTests.java @@ -1,9 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -12,6 +27,8 @@ import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest @WebAppConfiguration @@ -26,14 +43,17 @@ public class EurekaServerApplicationTests { @Test public void discoveryClientIsEureka() { - assertTrue("discoveryClient is wrong type " + discoveryClient.getClass(), discoveryClient instanceof CompositeDiscoveryClient); + assertTrue("discoveryClient is wrong type " + discoveryClient.getClass(), + discoveryClient instanceof CompositeDiscoveryClient); CompositeDiscoveryClient compositeDiscoveryClient = (CompositeDiscoveryClient) discoveryClient; - assertTrue("composite discovery client should be composed of Eureka and Simple Discovery client's" - , compositeDiscoveryClient.getDiscoveryClients().size() == 2); + assertTrue( + "composite discovery client should be composed of Eureka and Simple Discovery client's", + compositeDiscoveryClient.getDiscoveryClients().size() == 2); - assertTrue("the composed discovery client should have a EurekaDiscoveryClient with a higher precedence ", - compositeDiscoveryClient.getDiscoveryClients().get(0) instanceof EurekaDiscoveryClient); + assertTrue( + "the composed discovery client should have a EurekaDiscoveryClient with a higher precedence ", + compositeDiscoveryClient.getDiscoveryClients() + .get(0) instanceof EurekaDiscoveryClient); } - } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/pom.xml index 6f1668a5..5b066aad 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/pom.xml @@ -1,124 +1,124 @@ - - 4.0.0 + + 4.0.0 - org.springframework.cloud.sample - spring-cloud-sample-feign-eager-instantiation - 0.0.1-SNAPSHOT - jar + org.springframework.cloud.sample + spring-cloud-sample-feign-eager-instantiation + 0.0.1-SNAPSHOT + jar - spring-cloud-sample-feign-eager-instantiation - Demo project for Spring Cloud + spring-cloud-sample-feign-eager-instantiation + Demo project for Spring Cloud - - org.springframework.boot - spring-boot-starter-parent - 2.1.0.BUILD-SNAPSHOT - - + + org.springframework.boot + spring-boot-starter-parent + 2.1.0.BUILD-SNAPSHOT + + - - UTF-8 - UTF-8 - 1.8 - + + UTF-8 + UTF-8 + 1.8 + - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - org.springframework.boot - spring-boot-devtools - - - org.springframework.boot - spring-boot-starter-test - test - - + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.boot + spring-boot-devtools + + + org.springframework.boot + spring-boot-starter-test + test + + - - - - org.springframework.cloud - spring-cloud-dependencies - Greenwich.BUILD-SNAPSHOT - pom - import - - - + + + + org.springframework.cloud + spring-cloud-dependencies + Greenwich.BUILD-SNAPSHOT + pom + import + + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - - maven-deploy-plugin - - true - - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + + maven-deploy-plugin + + true + + + + - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/main/java/demo/ExampleClient.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/main/java/demo/ExampleClient.java index 71819bf1..90cec0bd 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/main/java/demo/ExampleClient.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/main/java/demo/ExampleClient.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.cloud.openfeign.FeignClient; @@ -7,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMethod; @FeignClient(name = "example", url = "http://example.com") public interface ExampleClient { - @RequestMapping(value = "/", method = RequestMethod.GET) - String get(); + @RequestMapping(value = "/", method = RequestMethod.GET) + String get(); + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/main/java/demo/FeignEagerInstantiationApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/main/java/demo/FeignEagerInstantiationApplication.java index 2d486471..cc4368e6 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/main/java/demo/FeignEagerInstantiationApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/main/java/demo/FeignEagerInstantiationApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -10,7 +26,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication public class FeignEagerInstantiationApplication { - public static void main(String[] args) { - SpringApplication.run(FeignEagerInstantiationApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(FeignEagerInstantiationApplication.class, args); + } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/test/java/demo/FeignEagerInstantiationApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/test/java/demo/FeignEagerInstantiationApplicationTests.java index 19d7769a..feb418e7 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/test/java/demo/FeignEagerInstantiationApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eager-instantiation/src/test/java/demo/FeignEagerInstantiationApplicationTests.java @@ -1,7 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/pom.xml index 3e1ad938..2a5c313a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/main/java/demo/HelloClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/main/java/demo/HelloClientApplication.java index 664843de..40dc9de7 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/main/java/demo/HelloClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/main/java/demo/HelloClientApplication.java @@ -1,24 +1,40 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; -import static org.springframework.web.bind.annotation.RequestMethod.GET; - import java.util.Arrays; +import com.netflix.loadbalancer.BaseLoadBalancer; +import com.netflix.loadbalancer.ILoadBalancer; +import com.netflix.loadbalancer.Server; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.netflix.loadbalancer.BaseLoadBalancer; -import com.netflix.loadbalancer.ILoadBalancer; -import com.netflix.loadbalancer.Server; +import static org.springframework.web.bind.annotation.RequestMethod.GET; /** * @author Spencer Gibb @@ -29,23 +45,27 @@ import com.netflix.loadbalancer.Server; @EnableFeignClients @RibbonClient(name = "hello", configuration = HelloRibbonClientConfiguration.class) public class HelloClientApplication { + @Autowired HelloClient client; + public static void main(String[] args) { + SpringApplication.run(HelloClientApplication.class, args); + } + @RequestMapping("/") public String hello() { return client.hello(); } - public static void main(String[] args) { - SpringApplication.run(HelloClientApplication.class, args); - } - @FeignClient("hello") interface HelloClient { + @RequestMapping(value = "/", method = GET) String hello(); + } + } // Load balancer with fixed server list for "hello" pointing to example.com @@ -54,7 +74,7 @@ class HelloRibbonClientConfiguration { @Bean public ILoadBalancer ribbonLoadBalancer() { - //because of this, it doesn't use eureka to lookup the server, + // because of this, it doesn't use eureka to lookup the server, // but the classpath is tested BaseLoadBalancer balancer = new BaseLoadBalancer(); balancer.setServersList(Arrays.asList(new Server("example.com", 80))); diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/test/java/demo/HelloClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/test/java/demo/HelloClientApplicationTests.java index 650efca6..96a9ebb3 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/test/java/demo/HelloClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/test/java/demo/HelloClientApplicationTests.java @@ -1,11 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; @@ -15,6 +28,10 @@ import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + // We disable Hystrix because we are not concerned about testing circuit breakers in this // test and it eliminates hystrix timeouts from messing with the request @RunWith(SpringRunner.class) diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/test/java/demo/NoWebApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/test/java/demo/NoWebApplicationTests.java index 560ffe96..d90f94e7 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/test/java/demo/NoWebApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-eureka/src/test/java/demo/NoWebApplicationTests.java @@ -1,7 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/pom.xml index 6928f2aa..8d459fc7 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/main/java/demo/FeignClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/main/java/demo/FeignClientApplication.java index 14f2bfa6..1ec71c3f 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/main/java/demo/FeignClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/main/java/demo/FeignClientApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.ApplicationArguments; @@ -11,10 +27,22 @@ import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +@FeignClient(name = "example", url = "example.com", fallback = FallbackClient.class) +interface UrlRestClient { + + @RequestMapping(value = "/", method = RequestMethod.GET) + String hello(); + +} + @SpringBootApplication @EnableFeignClients public class FeignClientApplication { + public static void main(String[] args) { + SpringApplication.run(FeignClientApplication.class, args); + } + @Bean public ApplicationRunner runner(final UrlRestClient client) { return new ApplicationRunner() { @@ -26,21 +54,14 @@ public class FeignClientApplication { }; } - public static void main(String[] args) { - SpringApplication.run(FeignClientApplication.class, args); - } -} - -@FeignClient(name = "example", url = "example.com", fallback=FallbackClient.class) -interface UrlRestClient { - @RequestMapping(value="/", method = RequestMethod.GET) - String hello(); } @Component class FallbackClient implements UrlRestClient { + @Override public String hello() { return "oops"; } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/test/java/demo/AdhocTestSuite.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/test/java/demo/AdhocTestSuite.java index 8e2c7f23..8aa90d42 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/test/java/demo/AdhocTestSuite.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/test/java/demo/AdhocTestSuite.java @@ -14,6 +14,22 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Ignore; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/test/java/demo/FeignClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/test/java/demo/FeignClientApplicationTests.java index 2fc33233..f547037c 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/test/java/demo/FeignClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign-hystrix/src/test/java/demo/FeignClientApplicationTests.java @@ -1,9 +1,25 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; -import static org.junit.Assert.assertTrue; - +import demo.FeignClientWithServerListApplicationTests.FallbackRestClient; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -15,8 +31,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; -import demo.FeignClientWithServerListApplicationTests.FallbackRestClient; - +import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @@ -26,11 +41,20 @@ public class FeignClientApplicationTests { @Autowired private UrlRestClient client; + @Test + public void clientConnects() { + assertTrue(client.hello().contains(" - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/main/java/demo/FeignClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/main/java/demo/FeignClientApplication.java index 3e645ed1..96de35a6 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/main/java/demo/FeignClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/main/java/demo/FeignClientApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -7,6 +23,15 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +@FeignClient(name = "example", url = "example.com") +@RequestMapping("/") +interface RestClient { + + @RequestMapping(method = RequestMethod.GET) + String hello(); + +} + @SpringBootApplication @EnableFeignClients public class FeignClientApplication { @@ -14,11 +39,5 @@ public class FeignClientApplication { public static void main(String[] args) { SpringApplication.run(FeignClientApplication.class, args); } -} -@FeignClient(name = "example", url = "example.com") -@RequestMapping("/") -interface RestClient { - @RequestMapping(method = RequestMethod.GET) - String hello(); } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/test/java/demo/AdhocTestSuite.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/test/java/demo/AdhocTestSuite.java index 8e2c7f23..8aa90d42 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/test/java/demo/AdhocTestSuite.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/test/java/demo/AdhocTestSuite.java @@ -14,6 +14,22 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Ignore; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/test/java/demo/FeignClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/test/java/demo/FeignClientApplicationTests.java index 88c5618f..1c9fa70b 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/test/java/demo/FeignClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/feign/src/test/java/demo/FeignClientApplicationTests.java @@ -1,23 +1,40 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext public class FeignClientApplicationTests { @Autowired private RestClient client; - + @Test public void clientConnects() { assertTrue(client.hello().contains(" - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/java/demo/HystrixApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/java/demo/HystrixApplication.java index 5e28a678..3d3f6969 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/java/demo/HystrixApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/java/demo/HystrixApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.beans.factory.annotation.Autowired; @@ -13,25 +29,26 @@ import org.springframework.web.bind.annotation.RestController; @RestController public class HystrixApplication { - @Bean - public MyService myService() { - return new MyService(); - } - - @Autowired - private MyService myService; - - @RequestMapping("/") - public String ok() { - return myService.ok(); - } - - @RequestMapping("/fail") - public String fail() { - return myService.fail(); - } + @Autowired + private MyService myService; public static void main(String[] args) { - SpringApplication.run(HystrixApplication.class, args); - } + SpringApplication.run(HystrixApplication.class, args); + } + + @Bean + public MyService myService() { + return new MyService(); + } + + @RequestMapping("/") + public String ok() { + return myService.ok(); + } + + @RequestMapping("/fail") + public String fail() { + return myService.fail(); + } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/java/demo/MyService.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/java/demo/MyService.java index ad995e3f..f0c2afd0 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/java/demo/MyService.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/java/demo/MyService.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; @@ -20,4 +36,5 @@ public class MyService { public String fallback() { return "from the fallback"; } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/resources/application.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/resources/application.properties index 38e5ce06..3c3e546f 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/resources/application.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/main/resources/application.properties @@ -1,4 +1,4 @@ # This way you get to see the exceptions when the fallback is accessed -logging.level.com.netflix.hystrix.AbstractCommand: DEBUG -logging.level.org.springframework.integration: DEBUG -management.endpoints.web.exposure.include: * \ No newline at end of file +logging.level.com.netflix.hystrix.AbstractCommand:DEBUG +logging.level.org.springframework.integration:DEBUG +management.endpoints.web.exposure.include:* \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/test/java/demo/HystrixApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/test/java/demo/HystrixApplicationTests.java index b05362dd..76d18d6c 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/test/java/demo/HystrixApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix-amqp/src/test/java/demo/HystrixApplicationTests.java @@ -1,23 +1,40 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +package demo; import java.io.InputStream; import java.net.URL; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.boot.web.server.LocalServerPort; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext @@ -28,7 +45,8 @@ public class HystrixApplicationTests { @Test public void testOk() { - ResponseEntity response = new TestRestTemplate().getForEntity("http://localhost:" + port, String.class); + ResponseEntity response = new TestRestTemplate() + .getForEntity("http://localhost:" + port, String.class); assertNotNull("response was null", response); assertEquals("Bad status code", HttpStatus.OK, response.getStatusCode()); assertEquals("Wrong response text", "OK", response.getBody()); @@ -36,7 +54,8 @@ public class HystrixApplicationTests { @Test public void testFallback() { - ResponseEntity response = new TestRestTemplate().getForEntity("http://localhost:" + port+"/fail", String.class); + ResponseEntity response = new TestRestTemplate() + .getForEntity("http://localhost:" + port + "/fail", String.class); assertNotNull("response was null", response); assertEquals("Bad status code", HttpStatus.OK, response.getStatusCode()); assertEquals("Wrong response text", "from the fallback", response.getBody()); @@ -45,8 +64,9 @@ public class HystrixApplicationTests { @Test public void hystrixStreamWorks() throws Exception { String url = "http://localhost:" + port; - //you have to hit a Hystrix circuit breaker before the stream sends anything - ResponseEntity response = new TestRestTemplate().getForEntity(url, String.class); + // you have to hit a Hystrix circuit breaker before the stream sends anything + ResponseEntity response = new TestRestTemplate().getForEntity(url, + String.class); assertEquals("bad response code", HttpStatus.OK, response.getStatusCode()); URL hystrixUrl = new URL(url + "/actuator/hystrix.stream"); @@ -54,7 +74,9 @@ public class HystrixApplicationTests { byte[] buffer = new byte[1024]; in.read(buffer); String contents = new String(buffer); - assertTrue("Wrong content: \n" + contents, contents.contains("data") || contents.contains("ping")); + assertTrue("Wrong content: \n" + contents, + contents.contains("data") || contents.contains("ping")); in.close(); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/pom.xml index 81f5c82e..6b458bbf 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/java/demo/HystrixApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/java/demo/HystrixApplication.java index fcee7810..4526a966 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/java/demo/HystrixApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/java/demo/HystrixApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.beans.factory.annotation.Autowired; @@ -14,28 +30,30 @@ import org.springframework.web.bind.annotation.RestController; @RestController public class HystrixApplication { + @Autowired + private MyService myService; + + public static void main(String[] args) { + SpringApplication.run(HystrixApplication.class, args); + } + @Bean public MyService myService() { return new MyService(); } - @Autowired - private MyService myService; - @RequestMapping("/") public String ok() { return this.myService.ok(); } @RequestMapping("/fail") - public String fail(@RequestHeader(name = "X-No-Fail", required = false) String noFail) { + public String fail( + @RequestHeader(name = "X-No-Fail", required = false) String noFail) { if (noFail != null) { return this.myService.fail(false); } return this.myService.fail(true); } - public static void main(String[] args) { - SpringApplication.run(HystrixApplication.class, args); - } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/java/demo/MyService.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/java/demo/MyService.java index 6b5d758d..d9489cd2 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/java/demo/MyService.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/java/demo/MyService.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; @@ -14,10 +30,10 @@ public class MyService { @HystrixCommand(fallbackMethod = "fallback") public String fail(boolean throwSomething) { - if(throwSomething) - throw new RuntimeException("fail now"); + if (throwSomething) + throw new RuntimeException("fail now"); else - return ""; + return ""; } @@ -28,4 +44,5 @@ public class MyService { public String fallback(boolean throwSomething) { return "from the fallback"; } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/resources/application.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/resources/application.properties index c018efa3..47b42db8 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/resources/application.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/main/resources/application.properties @@ -1,3 +1,3 @@ # This way you get to see the exceptions when the fallback is accessed -logging.level.com.netflix.hystrix.AbstractCommand: DEBUG -management.endpoints.web.exposure.include: * \ No newline at end of file +logging.level.com.netflix.hystrix.AbstractCommand:DEBUG +management.endpoints.web.exposure.include:* \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/test/java/demo/HystrixApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/test/java/demo/HystrixApplicationTests.java index b05362dd..76d18d6c 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/test/java/demo/HystrixApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/hystrix/src/test/java/demo/HystrixApplicationTests.java @@ -1,23 +1,40 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +package demo; import java.io.InputStream; import java.net.URL; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.boot.web.server.LocalServerPort; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext @@ -28,7 +45,8 @@ public class HystrixApplicationTests { @Test public void testOk() { - ResponseEntity response = new TestRestTemplate().getForEntity("http://localhost:" + port, String.class); + ResponseEntity response = new TestRestTemplate() + .getForEntity("http://localhost:" + port, String.class); assertNotNull("response was null", response); assertEquals("Bad status code", HttpStatus.OK, response.getStatusCode()); assertEquals("Wrong response text", "OK", response.getBody()); @@ -36,7 +54,8 @@ public class HystrixApplicationTests { @Test public void testFallback() { - ResponseEntity response = new TestRestTemplate().getForEntity("http://localhost:" + port+"/fail", String.class); + ResponseEntity response = new TestRestTemplate() + .getForEntity("http://localhost:" + port + "/fail", String.class); assertNotNull("response was null", response); assertEquals("Bad status code", HttpStatus.OK, response.getStatusCode()); assertEquals("Wrong response text", "from the fallback", response.getBody()); @@ -45,8 +64,9 @@ public class HystrixApplicationTests { @Test public void hystrixStreamWorks() throws Exception { String url = "http://localhost:" + port; - //you have to hit a Hystrix circuit breaker before the stream sends anything - ResponseEntity response = new TestRestTemplate().getForEntity(url, String.class); + // you have to hit a Hystrix circuit breaker before the stream sends anything + ResponseEntity response = new TestRestTemplate().getForEntity(url, + String.class); assertEquals("bad response code", HttpStatus.OK, response.getStatusCode()); URL hystrixUrl = new URL(url + "/actuator/hystrix.stream"); @@ -54,7 +74,9 @@ public class HystrixApplicationTests { byte[] buffer = new byte[1024]; in.read(buffer); String contents = new String(buffer); - assertTrue("Wrong content: \n" + contents, contents.contains("data") || contents.contains("ping")); + assertTrue("Wrong content: \n" + contents, + contents.contains("data") || contents.contains("ping")); in.close(); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/pom.xml index 41988dc5..0fc424bc 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/main/java/demo/SidecarApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/main/java/demo/SidecarApplication.java index b97c49b9..063e6771 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/main/java/demo/SidecarApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/main/java/demo/SidecarApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -11,4 +27,5 @@ public class SidecarApplication { public static void main(String[] args) { SpringApplication.run(SidecarApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/main/resources/health.json b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/main/resources/health.json index 41f3615e..623df4da 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/main/resources/health.json +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/main/resources/health.json @@ -1 +1,3 @@ -{"status":"UP"} \ No newline at end of file +{ + "status": "UP" +} \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/test/java/demo/SidecarApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/test/java/demo/SidecarApplicationTests.java index ff0b1ad3..f1ba1d50 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/test/java/demo/SidecarApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/netflix-sidecar/src/test/java/demo/SidecarApplicationTests.java @@ -1,16 +1,30 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; -import static org.junit.Assert.assertEquals; - +import com.netflix.appinfo.EurekaInstanceConfig; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; -import com.netflix.appinfo.EurekaInstanceConfig; - @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -25,7 +39,8 @@ public class SidecarApplicationTests { @Test public void instanceConfigHasCorrectPort() { - assertEquals("eureka instance config has wrong port", 8000, instanceConfig.getNonSecurePort()); + assertEquals("eureka instance config has wrong port", 8000, + instanceConfig.getNonSecurePort()); } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/pom.xml index b2e32bfd..6c4052f8 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/main/java/demo/NotWebApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/main/java/demo/NotWebApplication.java index e7efbb86..c73becd3 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/main/java/demo/NotWebApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/main/java/demo/NotWebApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -13,4 +29,5 @@ public class NotWebApplication { public static void main(String[] args) { SpringApplication.run(NotWebApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/test/java/demo/NotWebApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/test/java/demo/NotWebApplicationTests.java index 15c9c386..86f0e01e 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/test/java/demo/NotWebApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/test/java/demo/NotWebApplicationTests.java @@ -1,7 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/test/java/test/DiscoveryNotWebApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/test/java/test/DiscoveryNotWebApplicationTests.java index c3f0326f..2f48e7e7 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/test/java/test/DiscoveryNotWebApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/noweb/src/test/java/test/DiscoveryNotWebApplicationTests.java @@ -1,11 +1,29 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package test; import java.util.List; +import demo.NotWebApplication; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -16,8 +34,6 @@ import org.springframework.test.context.junit4.SpringRunner; import static org.junit.Assert.assertTrue; -import demo.NotWebApplication; - @RunWith(SpringRunner.class) @SpringBootTest public class DiscoveryNotWebApplicationTests { @@ -32,8 +48,8 @@ public class DiscoveryNotWebApplicationTests { } /* - * This works because the SimpleDiscoveryClient is installed if there is no @EnableDiscoveryClient - * *and* there is no implementation on the classpath + * This works because the SimpleDiscoveryClient is installed if there is + * no @EnableDiscoveryClient *and* there is no implementation on the classpath */ @SpringBootApplication protected static class NoDiscoveryApplication implements CommandLineRunner { @@ -48,6 +64,7 @@ public class DiscoveryNotWebApplicationTests { List services = client.getServices(); logger.info("Services: " + services); } + } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/pom.xml index 6a8a2319..5d8f164c 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/main/java/demo/RibbonClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/main/java/demo/RibbonClientApplication.java index 56267ce9..c12f1845 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/main/java/demo/RibbonClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/main/java/demo/RibbonClientApplication.java @@ -1,10 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.cloud.netflix.ribbon.RibbonClient; -import org.springframework.context.annotation.Bean; // import org.springframework.security.oauth2.client.OAuth2ClientContext; // import org.springframework.security.oauth2.client.OAuth2RestTemplate; // import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; @@ -16,14 +30,16 @@ import org.springframework.context.annotation.Bean; // FIXME boot 2.0.0 spring-security 5.0 missing oauth public class RibbonClientApplication { - /*@LoadBalanced - @Bean - public OAuth2RestTemplate loadBalancedOauth2RestTemplate(OAuth2ProtectedResourceDetails resource, - OAuth2ClientContext context) { - return new OAuth2RestTemplate(resource, context); - }*/ + /* + * @LoadBalanced + * + * @Bean public OAuth2RestTemplate + * loadBalancedOauth2RestTemplate(OAuth2ProtectedResourceDetails resource, + * OAuth2ClientContext context) { return new OAuth2RestTemplate(resource, context); } + */ public static void main(String[] args) { SpringApplication.run(RibbonClientApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/main/resources/application.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/main/resources/application.properties index 83da9f9b..23d1b12d 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/main/resources/application.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/main/resources/application.properties @@ -1,4 +1,4 @@ -security.oauth2.client.clientId: acme -security.oauth2.client.accessTokenUri: https://example.com -foo.ribbon.listOfServers: example.com +security.oauth2.client.clientId:acme +security.oauth2.client.accessTokenUri:https://example.com +foo.ribbon.listOfServers:example.com # debug: \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/test/java/demo/RibbonClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/test/java/demo/RibbonClientApplicationTests.java index c1102ac7..dcc8622a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/test/java/demo/RibbonClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-ribbon/src/test/java/demo/RibbonClientApplicationTests.java @@ -1,62 +1,71 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; -import java.net.URI; - -import org.junit.After; import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.test.context.junit4.SpringRunner; + // import org.springframework.http.HttpMethod; // import org.springframework.http.client.ClientHttpRequest; -import org.springframework.mock.web.MockHttpServletRequest; // import org.springframework.security.oauth2.client.OAuth2RestTemplate; // import org.springframework.security.oauth2.client.resource.UserRedirectRequiredException; -import org.springframework.test.context.junit4.SpringRunner; // import org.springframework.web.context.request.RequestContextHolder; // import org.springframework.web.context.request.ServletRequestAttributes; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class RibbonClientApplicationTests { // FIXME boot 2.0.0 spring-security 5.0 missing oauth - /*@Autowired - @LoadBalanced - private OAuth2RestTemplate oauth2RestTemplate; - - private MockHttpServletRequest request = new MockHttpServletRequest(); - - @Rule - public ExpectedException expected = ExpectedException.none(); - - @After - public void clean() { - RequestContextHolder.resetRequestAttributes(); - }*/ + /* + * @Autowired + * + * @LoadBalanced private OAuth2RestTemplate oauth2RestTemplate; + * + * private MockHttpServletRequest request = new MockHttpServletRequest(); + * + * @Rule public ExpectedException expected = ExpectedException.none(); + * + * @After public void clean() { RequestContextHolder.resetRequestAttributes(); } + */ @Test @Ignore public void oauth2RestTemplateHasLoadBalancer() throws Exception { - /* // Just to prove that the interceptor is present... - ClientHttpRequest request = oauth2RestTemplate.getRequestFactory() - .createRequest(new URI("http://nosuchservice"), HttpMethod.GET); - expected.expectMessage("No instances available for nosuchservice"); - request.execute();*/ + /* + * // Just to prove that the interceptor is present... ClientHttpRequest request = + * oauth2RestTemplate.getRequestFactory() .createRequest(new + * URI("http://nosuchservice"), HttpMethod.GET); + * expected.expectMessage("No instances available for nosuchservice"); + * request.execute(); + */ } - /*@Test - public void useRestTemplate() throws Exception { - // There's nowhere to get an access token so it should fail, but in a sensible way - this.expected.expect(UserRedirectRequiredException.class); - RequestContextHolder - .setRequestAttributes(new ServletRequestAttributes(this.request)); - this.oauth2RestTemplate.getForEntity("http://foo/bar", String.class); - }*/ + /* + * @Test public void useRestTemplate() throws Exception { // There's nowhere to get an + * access token so it should fail, but in a sensible way + * this.expected.expect(UserRedirectRequiredException.class); RequestContextHolder + * .setRequestAttributes(new ServletRequestAttributes(this.request)); + * this.oauth2RestTemplate.getForEntity("http://foo/bar", String.class); } + */ } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/pom.xml index be269aaa..7ec8a0d0 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/main/java/demo/ZuulApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/main/java/demo/ZuulApplication.java index 2684bb23..000b6232 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/main/java/demo/ZuulApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/main/java/demo/ZuulApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -12,4 +28,5 @@ public class ZuulApplication { public static void main(String[] args) { SpringApplication.run(ZuulApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/main/resources/application.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/main/resources/application.properties index 79990649..2b301a41 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/main/resources/application.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/main/resources/application.properties @@ -1,6 +1,6 @@ -security.oauth2.client.clientId: acme -security.oauth2.client.clientSecret: acmesecret -security.oauth2.client.accessTokenUri: https://example.com -security.oauth2.client.userAuthorizationUri: https://example.com -security.oauth2.resource.user-info-uri: https://example.com +security.oauth2.client.clientId:acme +security.oauth2.client.clientSecret:acmesecret +security.oauth2.client.accessTokenUri:https://example.com +security.oauth2.client.userAuthorizationUri:https://example.com +security.oauth2.resource.user-info-uri:https://example.com # debug: \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/test/java/demo/ZuulApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/test/java/demo/ZuulApplicationTests.java index 5e2b9941..4693c296 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/test/java/demo/ZuulApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/oauth2-zuul/src/test/java/demo/ZuulApplicationTests.java @@ -1,10 +1,25 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertEquals; +package demo; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; @@ -13,21 +28,24 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) -public class ZuulApplicationTests { +import static org.junit.Assert.assertEquals; - private TestRestTemplate restTemplate = new TestRestTemplate(); +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class ZuulApplicationTests { @Value("${local.server.port}") int port; + private TestRestTemplate restTemplate = new TestRestTemplate(); @Test @Ignore public void useRestTemplate() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("http://localhost:" + this.port, String.class); + ResponseEntity entity = this.restTemplate + .getForEntity("http://localhost:" + this.port, String.class); assertEquals(HttpStatus.FOUND, entity.getStatusCode()); - assertEquals("http://localhost:" + this.port + "/login", entity.getHeaders().getLocation().toString()); + assertEquals("http://localhost:" + this.port + "/login", + entity.getHeaders().getLocation().toString()); } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/pom.xml index dfdc8378..50d61d7f 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.springframework.boot @@ -55,13 +56,13 @@ - - - maven-deploy-plugin - - true - - + + + maven-deploy-plugin + + true + + org.apache.maven.plugins maven-surefire-plugin diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/pom.xml index 0bb96e04..512846a2 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/pom.xml @@ -1,11 +1,12 @@ - - 4.0.0 + + 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + @@ -48,10 +49,10 @@ - - org.springframework.boot - spring-boot-starter-web - + + org.springframework.boot + spring-boot-starter-web + org.springframework.cloud spring-cloud-starter-netflix-eureka-client diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/main/java/demo/MyDefaultRibbonConfig.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/main/java/demo/MyDefaultRibbonConfig.java index 134aa9fa..8c676120 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/main/java/demo/MyDefaultRibbonConfig.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/main/java/demo/MyDefaultRibbonConfig.java @@ -1,7 +1,20 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; +package demo; import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.BestAvailableRule; @@ -13,12 +26,16 @@ import com.netflix.loadbalancer.Server; import com.netflix.loadbalancer.ServerList; import com.netflix.loadbalancer.ServerListSubsetFilter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + /** * @author brenuart * */ @Configuration public class MyDefaultRibbonConfig { + @Bean public IRule ribbonRule() { return new BestAvailableRule(); @@ -41,8 +58,11 @@ public class MyDefaultRibbonConfig { } public static class BazServiceList extends ConfigurationBasedServerList { + public BazServiceList(IClientConfig config) { super.initWithNiwsConfig(config); } + } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/main/java/demo/RibbonDefaultConfigApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/main/java/demo/RibbonDefaultConfigApplication.java index edd93d91..e74bde57 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/main/java/demo/RibbonDefaultConfigApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/main/java/demo/RibbonDefaultConfigApplication.java @@ -1,7 +1,27 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import javax.annotation.PostConstruct; +import com.netflix.loadbalancer.Server; +import com.netflix.loadbalancer.ServerList; +import com.netflix.loadbalancer.ZoneAwareLoadBalancer; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -12,17 +32,15 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; -import com.netflix.loadbalancer.Server; -import com.netflix.loadbalancer.ServerList; -import com.netflix.loadbalancer.ZoneAwareLoadBalancer; - /** * @author brenuart */ @ComponentScan( -// Exclude @Configuration classes that should be included only in sub contexts created -// by Ribbon's SpringClientFactory. -excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*RibbonConfig") }) + // Exclude @Configuration classes that should be included only in sub contexts + // created + // by Ribbon's SpringClientFactory. + excludeFilters = { + @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*RibbonConfig") }) @SpringBootApplication @RibbonClients(defaultConfiguration = MyDefaultRibbonConfig.class) @@ -32,6 +50,15 @@ public class RibbonDefaultConfigApplication { @Autowired private SpringClientFactory clientFactory; + /** + * @param args + */ + public static void main(String[] args) { + SpringApplication app = new SpringApplicationBuilder( + RibbonDefaultConfigApplication.class).build(); + app.run(args); + } + /** * Throws exception if the SpringClientFactory doesn't return a balancer with a server * list of the expected type. @@ -40,7 +67,8 @@ public class RibbonDefaultConfigApplication { @PostConstruct public void test() throws Exception { @SuppressWarnings("unchecked") - ZoneAwareLoadBalancer lb = (ZoneAwareLoadBalancer) this.clientFactory.getLoadBalancer("baz"); + ZoneAwareLoadBalancer lb = (ZoneAwareLoadBalancer) this.clientFactory + .getLoadBalancer("baz"); ServerList serverList = lb.getServerListImpl(); if (!(serverList instanceof MyDefaultRibbonConfig.BazServiceList)) { @@ -48,11 +76,4 @@ public class RibbonDefaultConfigApplication { } } - /** - * @param args - */ - public static void main(String[] args) { - SpringApplication app = new SpringApplicationBuilder(RibbonDefaultConfigApplication.class).build(); - app.run(args); - } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/test/java/demo/RibbonDefaultConfigApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/test/java/demo/RibbonDefaultConfigApplicationTests.java index 0c10bb99..8756b3c0 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/test/java/demo/RibbonDefaultConfigApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-default-config/src/test/java/demo/RibbonDefaultConfigApplicationTests.java @@ -14,10 +14,27 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.annotation.DirtiesContext; @@ -31,5 +48,5 @@ public class RibbonDefaultConfigApplicationTests { @Test public void contextLoads() { } -} +} diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/pom.xml index 69eeb442..84369e69 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/main/java/demo/HelloClientApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/main/java/demo/HelloClientApplication.java index ca625239..49520fd9 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/main/java/demo/HelloClientApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/main/java/demo/HelloClientApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.beans.factory.annotation.Autowired; @@ -21,18 +37,19 @@ public class HelloClientApplication { @Autowired private RestTemplate client; + public static void main(String[] args) { + SpringApplication.run(HelloClientApplication.class, args); + } + @RequestMapping("/") public String hello() { return this.client.getForObject("http://simple/", String.class); } - public static void main(String[] args) { - SpringApplication.run(HelloClientApplication.class, args); - } - @Bean @LoadBalanced public RestTemplate restTemplate() { return new RestTemplate(); } + } \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/apps/EurekaServerApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/apps/EurekaServerApplication.java index 1983ade4..185cf115 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/apps/EurekaServerApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/apps/EurekaServerApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package apps; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -11,8 +27,9 @@ import org.springframework.context.annotation.Configuration; public class EurekaServerApplication { public static void main(String[] args) { - new SpringApplicationBuilder(EurekaServerApplication.class).properties( - "spring.config.name:eureka", "logging.level.com.netflix.discovery:OFF") + new SpringApplicationBuilder(EurekaServerApplication.class) + .properties("spring.config.name:eureka", + "logging.level.com.netflix.discovery:OFF") .run(args); } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/apps/SimpleApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/apps/SimpleApplication.java index e3e9a91c..30c1e844 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/apps/SimpleApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/apps/SimpleApplication.java @@ -14,6 +14,22 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package apps; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -29,13 +45,14 @@ import org.springframework.web.bind.annotation.RestController; @RestController public class SimpleApplication { + public static void main(String[] args) { + new SpringApplicationBuilder(SimpleApplication.class) + .properties("spring.config.name:simple").run(args); + } + @RequestMapping("/") public String hello() { return "Hello"; } - public static void main(String[] args) { - new SpringApplicationBuilder(SimpleApplication.class).properties( - "spring.config.name:simple").run(args); - } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/demo/HelloClientApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/demo/HelloClientApplicationTests.java index d6d948d7..15242af4 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/demo/HelloClientApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/java/demo/HelloClientApplicationTests.java @@ -1,20 +1,37 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +package demo; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.boot.web.server.LocalServerPort; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext @@ -26,7 +43,7 @@ public class HelloClientApplicationTests { @Test public void contextLoads() throws Exception { } - + @Test @Ignore /* @@ -36,8 +53,8 @@ public class HelloClientApplicationTests { * with Eureka (only registered services can access the registry). */ public void clientConnects() throws Exception { - ResponseEntity response = new TestRestTemplate().getForEntity( - "http://localhost:" + port, String.class); + ResponseEntity response = new TestRestTemplate() + .getForEntity("http://localhost:" + port, String.class); assertNotNull("response was null", response); assertEquals("Wrong status code", HttpStatus.OK, response.getStatusCode()); assertEquals("Hello", response.getBody()); diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/resources/eureka.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/resources/eureka.properties index a0e3d7fc..cdf66a49 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/resources/eureka.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/resources/eureka.properties @@ -1,4 +1,4 @@ -server.port: 8761 -spring.application.name: eureka +server.port:8761 +spring.application.name:eureka eureka.client.registerWithEureka=false eureka.client.fetchRegistry=false \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/resources/simple.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/resources/simple.properties index c6a8f1f8..63123e5b 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/resources/simple.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/ribbon-eureka/src/test/resources/simple.properties @@ -1,5 +1,5 @@ -server.port: 8081 -spring.application.name: simple -eureka.instance.leaseRenewalIntervalInSeconds: 10 -eureka.client.registryFetchIntervalSeconds: 5 -eureka.client.serviceUrl.defaultZone: http://localhost:${eureka.port:8761}/eureka/ +server.port:8081 +spring.application.name:simple +eureka.instance.leaseRenewalIntervalInSeconds:10 +eureka.client.registryFetchIntervalSeconds:5 +eureka.client.serviceUrl.defaultZone:http://localhost:${eureka.port:8761}/eureka/ diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/pom.xml index 05225d7c..efc2b946 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -23,17 +23,17 @@ 1.8 Greenwich.BUILD-SNAPSHOT - + - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/src/main/java/demo/TraceApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/src/main/java/demo/TraceApplication.java index 2e5ab30c..8bb826b1 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/src/main/java/demo/TraceApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/src/main/java/demo/TraceApplication.java @@ -1,7 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; @@ -14,22 +31,25 @@ import org.springframework.web.client.RestTemplate; @SpringBootApplication public class TraceApplication { + public static void main(String[] args) { + SpringApplication.run(TraceApplication.class, args); + } + @Bean public RestTemplate restTemplate() { return new RestTemplate(); } - public static void main(String[] args) { - SpringApplication.run(TraceApplication.class, args); - } } @RestController class HomeController { private static final Log log = LogFactory.getLog(HomeController.class); + @Autowired private RestTemplate restTemplate; + @Value("${app.url:http://localhost:${local.server.port:${server.port:8080}}}") private String url; @@ -52,4 +72,5 @@ class HiController { log.info("Hi"); return "hi"; } + } \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/src/test/java/demo/TraceApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/src/test/java/demo/TraceApplicationTests.java index 0c2e47b9..5544f328 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/src/test/java/demo/TraceApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/sleuth/src/test/java/demo/TraceApplicationTests.java @@ -1,8 +1,25 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import brave.Tracer; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; @@ -27,4 +44,5 @@ public class TraceApplicationTests { public void traceIsDefaultTrace() { assertNotNull("Tracer was null", this.traceManager); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/pom.xml index 157497a7..5d5e9d6a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/src/main/java/demo/StreamBusApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/src/main/java/demo/StreamBusApplication.java index 92a4f760..47f4ea27 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/src/main/java/demo/StreamBusApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/src/main/java/demo/StreamBusApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -15,4 +31,5 @@ public class StreamBusApplication { public static void main(String[] args) { SpringApplication.run(StreamBusApplication.class, args); } + } \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/src/test/java/demo/StreamBusApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/src/test/java/demo/StreamBusApplicationTests.java index 0e7893df..1471bea6 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/src/test/java/demo/StreamBusApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/stream-bus/src/test/java/demo/StreamBusApplicationTests.java @@ -1,12 +1,24 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.assertj.core.api.Assertions; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bus.SpringCloudBusClient; @@ -18,6 +30,8 @@ import org.springframework.messaging.support.MessageBuilder; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/pom.xml index bfe91b56..dcf874ba 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/main/java/demo/TurbineStreamApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/main/java/demo/TurbineStreamApplication.java index 059815e1..2c3f4990 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/main/java/demo/TurbineStreamApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/main/java/demo/TurbineStreamApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -13,4 +29,5 @@ public class TurbineStreamApplication { public static void main(String[] args) { SpringApplication.run(TurbineStreamApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/main/resources/application.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/main/resources/application.properties index 6449849b..4f5e54d0 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/main/resources/application.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.port: 8989 -spring.application.name: turbine -turbine.appConfig: simple -turbine.aggregator.clusterConfig: SIMPLE +server.port:8989 +spring.application.name:turbine +turbine.appConfig:simple +turbine.aggregator.clusterConfig:SIMPLE diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/java/demo/TurbineStreamApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/java/demo/TurbineStreamApplicationTests.java index b4dd1e93..cc62a225 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/java/demo/TurbineStreamApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/java/demo/TurbineStreamApplicationTests.java @@ -1,9 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -13,6 +28,8 @@ import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -27,16 +44,22 @@ public class TurbineStreamApplicationTests { @Test public void discoveryClientIsEureka() { - assertTrue("discoveryClient is wrong type " + discoveryClient.getClass(), discoveryClient instanceof CompositeDiscoveryClient); - CompositeDiscoveryClient compositeDiscoveryClient = (CompositeDiscoveryClient)discoveryClient; - assertTrue("composite discovery client should be composed of Eureka and Simple Discovery client's" - , compositeDiscoveryClient.getDiscoveryClients().size() == 2); + assertTrue("discoveryClient is wrong type " + discoveryClient.getClass(), + discoveryClient instanceof CompositeDiscoveryClient); + CompositeDiscoveryClient compositeDiscoveryClient = (CompositeDiscoveryClient) discoveryClient; + assertTrue( + "composite discovery client should be composed of Eureka and Simple Discovery client's", + compositeDiscoveryClient.getDiscoveryClients().size() == 2); - assertTrue("the composed discovery client should have a EurekaDiscoveryClient with a higher precedence ", - compositeDiscoveryClient.getDiscoveryClients().get(0) instanceof EurekaDiscoveryClient); + assertTrue( + "the composed discovery client should have a EurekaDiscoveryClient with a higher precedence ", + compositeDiscoveryClient.getDiscoveryClients() + .get(0) instanceof EurekaDiscoveryClient); - assertTrue("the composed discovery client should have a SimpleDiscoveryClient with a lower precedence ", - compositeDiscoveryClient.getDiscoveryClients().get(1) instanceof SimpleDiscoveryClient); + assertTrue( + "the composed discovery client should have a SimpleDiscoveryClient with a lower precedence ", + compositeDiscoveryClient.getDiscoveryClients() + .get(1) instanceof SimpleDiscoveryClient); } - + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/resources/eureka.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/resources/eureka.properties index a0e3d7fc..cdf66a49 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/resources/eureka.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/resources/eureka.properties @@ -1,4 +1,4 @@ -server.port: 8761 -spring.application.name: eureka +server.port:8761 +spring.application.name:eureka eureka.client.registerWithEureka=false eureka.client.fetchRegistry=false \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/resources/simple.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/resources/simple.properties index ec7a5fcb..c3d41c86 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/resources/simple.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine-amqp/src/test/resources/simple.properties @@ -1,2 +1,2 @@ -server.port: 8080 -spring.application.name: simple +server.port:8080 +spring.application.name:simple diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/pom.xml index 405d3151..23bbca99 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/main/java/demo/TurbineApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/main/java/demo/TurbineApplication.java index 4db13e30..cddd2495 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/main/java/demo/TurbineApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/main/java/demo/TurbineApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -8,7 +24,8 @@ import org.springframework.cloud.netflix.turbine.EnableTurbine; @EnableTurbine public class TurbineApplication { - public static void main(String[] args) { - SpringApplication.run(TurbineApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(TurbineApplication.class, args); + } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/EurekaServerApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/EurekaServerApplication.java index 1983ade4..185cf115 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/EurekaServerApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/EurekaServerApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package apps; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -11,8 +27,9 @@ import org.springframework.context.annotation.Configuration; public class EurekaServerApplication { public static void main(String[] args) { - new SpringApplicationBuilder(EurekaServerApplication.class).properties( - "spring.config.name:eureka", "logging.level.com.netflix.discovery:OFF") + new SpringApplicationBuilder(EurekaServerApplication.class) + .properties("spring.config.name:eureka", + "logging.level.com.netflix.discovery:OFF") .run(args); } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/OtherApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/OtherApplication.java index dbb58372..63ed334a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/OtherApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/OtherApplication.java @@ -14,10 +14,28 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package apps; import javax.servlet.http.HttpSession; +import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -28,8 +46,6 @@ import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; - @Configuration @EnableAutoConfiguration @EnableDiscoveryClient @@ -40,6 +56,11 @@ public class OtherApplication { @Autowired private HelloService service; + public static void main(String[] args) { + new SpringApplicationBuilder(OtherApplication.class) + .properties("spring.config.name:other").run(args); + } + @RequestMapping("/") public String hello() { return this.service.hello(); @@ -55,20 +76,15 @@ public class OtherApplication { return this.service.fail(); } - public static void main(String[] args) { - new SpringApplicationBuilder(OtherApplication.class).properties( - "spring.config.name:other").run(args); - } - @Service public static class HelloService { - @HystrixCommand(fallbackMethod="fallback") + @HystrixCommand(fallbackMethod = "fallback") public String hello() { return "Hello World"; } - @HystrixCommand(fallbackMethod="fallback") + @HystrixCommand(fallbackMethod = "fallback") public String fail() { throw new RuntimeException("Planned"); } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/SimpleApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/SimpleApplication.java index d24596f2..976b3e80 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/SimpleApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/apps/SimpleApplication.java @@ -14,10 +14,28 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package apps; import javax.servlet.http.HttpSession; +import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -28,8 +46,6 @@ import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; - @Configuration @EnableAutoConfiguration @EnableDiscoveryClient @@ -40,6 +56,11 @@ public class SimpleApplication { @Autowired private HelloService service; + public static void main(String[] args) { + new SpringApplicationBuilder(SimpleApplication.class) + .properties("spring.config.name:simple").run(args); + } + @RequestMapping("/") public String hello() { return this.service.hello(); @@ -55,20 +76,15 @@ public class SimpleApplication { return this.service.fail(); } - public static void main(String[] args) { - new SpringApplicationBuilder(SimpleApplication.class).properties( - "spring.config.name:simple").run(args); - } - @Service public static class HelloService { - @HystrixCommand(fallbackMethod="fallback") + @HystrixCommand(fallbackMethod = "fallback") public String hello() { return "Hello World"; } - @HystrixCommand(fallbackMethod="fallback") + @HystrixCommand(fallbackMethod = "fallback") public String fail() { throw new RuntimeException("Planned"); } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/demo/TurbineApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/demo/TurbineApplicationTests.java index cfdba6b0..c2f7e328 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/demo/TurbineApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/java/demo/TurbineApplicationTests.java @@ -1,9 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -11,6 +26,8 @@ import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryCl import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -25,7 +42,8 @@ public class TurbineApplicationTests { @Test public void discoveryClientIsEureka() { - assertTrue("discoveryClient is wrong type", discoveryClient instanceof CompositeDiscoveryClient); + assertTrue("discoveryClient is wrong type", + discoveryClient instanceof CompositeDiscoveryClient); } - + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/eureka.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/eureka.properties index a0e3d7fc..cdf66a49 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/eureka.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/eureka.properties @@ -1,4 +1,4 @@ -server.port: 8761 -spring.application.name: eureka +server.port:8761 +spring.application.name:eureka eureka.client.registerWithEureka=false eureka.client.fetchRegistry=false \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/other.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/other.properties index d1bfb709..2aaf0a96 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/other.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/other.properties @@ -1,3 +1,3 @@ -server.port: 8081 -spring.application.name: other -eureka.instance.metadata-map.cluster: MAIN \ No newline at end of file +server.port:8081 +spring.application.name:other +eureka.instance.metadata-map.cluster:MAIN \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/simple.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/simple.properties index 9be4e14a..fad5e874 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/simple.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/turbine/src/test/resources/simple.properties @@ -1,3 +1,3 @@ -server.port: 8080 -spring.application.name: simple -eureka.instance.metadata-map.cluster: MAIN \ No newline at end of file +server.port:8080 +spring.application.name:simple +eureka.instance.metadata-map.cluster:MAIN \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/pom.xml index fce156cf..c89d18ce 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/src/main/java/demo/VanillaApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/src/main/java/demo/VanillaApplication.java index 0c76535f..b8cfd863 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/src/main/java/demo/VanillaApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/src/main/java/demo/VanillaApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -11,13 +27,14 @@ import org.springframework.context.annotation.Bean; @SpringBootApplication public class VanillaApplication { + public static void main(String[] args) { + SpringApplication.run(VanillaApplication.class, args); + } + @Bean @RefreshScope public Runnable runner() { return () -> System.err.println("*****"); } - public static void main(String[] args) { - SpringApplication.run(VanillaApplication.class, args); - } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/src/test/java/demo/VanillaApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/src/test/java/demo/VanillaApplicationTests.java index 04d5be74..2428ef61 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/src/test/java/demo/VanillaApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/vanilla/src/test/java/demo/VanillaApplicationTests.java @@ -1,15 +1,32 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertNotNull; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.context.refresh.ContextRefresher; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertNotNull; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/pom.xml index 17fa1c6c..4ea61168 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -26,15 +26,15 @@ - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/src/main/java/demo/ZipkinApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/src/main/java/demo/ZipkinApplication.java index 150f14dc..79bc5b52 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/src/main/java/demo/ZipkinApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/src/main/java/demo/ZipkinApplication.java @@ -1,29 +1,48 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; - @SpringBootApplication public class ZipkinApplication { private static Logger log = LoggerFactory.getLogger(ZipkinApplication.class); // Use this for debugging (or if there is no Zipkin server running on port 9411) - /*@Bean - @ConditionalOnProperty(value="sample.zipkin.enabled", havingValue="false") - public ZipkinSpanReporter spanCollector(Reporter reporter, EndpointLocator endpointLocator, Environment environment, List spanAdjusters) { - return new ZipkinSpanReporter(reporter, endpointLocator, environment, spanAdjusters) { - @Override - public void report(Span span) { - log.info("Reporting span [{}]", span); - } - }; - }*/ + /* + * @Bean + * + * @ConditionalOnProperty(value="sample.zipkin.enabled", havingValue="false") public + * ZipkinSpanReporter spanCollector(Reporter reporter, EndpointLocator + * endpointLocator, Environment environment, List spanAdjusters) { + * return new ZipkinSpanReporter(reporter, endpointLocator, environment, + * spanAdjusters) { + * + * @Override public void report(Span span) { log.info("Reporting span [{}]", span); } + * }; } + */ public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/src/test/java/demo/ZipkinApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/src/test/java/demo/ZipkinApplicationTests.java index 1613a01c..3cbbbf11 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/src/test/java/demo/ZipkinApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zipkin/src/test/java/demo/ZipkinApplicationTests.java @@ -1,15 +1,30 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.boot.test.context.SpringBootTest; -// import org.springframework.cloud.sleuth.zipkin.ZipkinSpanListener; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +// import org.springframework.cloud.sleuth.zipkin.ZipkinSpanListener; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -22,9 +37,10 @@ public class ZipkinApplicationTests { public void contextLoads() { } - //FIXME: zipkin2 boot 2.0 - /*@Test - public void listenerIsInjected() { - assertTrue("listener is wrong type", this.listener instanceof ZipkinSpanListener); - }*/ + // FIXME: zipkin2 boot 2.0 + /* + * @Test public void listenerIsInjected() { assertTrue("listener is wrong type", + * this.listener instanceof ZipkinSpanListener); } + */ + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/pom.xml index 0bd16e50..5107c408 100755 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/pom.xml @@ -1,21 +1,21 @@ - + 4.0.0 - org.springframework.cloud.sample - spring-cloud-sample-zuul-config-discovery - ${spring-cloud.version} - jar + org.springframework.cloud.sample + spring-cloud-sample-zuul-config-discovery + ${spring-cloud.version} + jar - spring-cloud-sample-zuul-config-discovery + spring-cloud-sample-zuul-config-discovery Demo project for Spring Cloud org.springframework.boot spring-boot-starter-parent 2.1.0.BUILD-SNAPSHOT - + @@ -29,11 +29,11 @@ - - UTF-8 - 1.8 + + UTF-8 + 1.8 Greenwich.BUILD-SNAPSHOT - + @@ -44,10 +44,10 @@ org.springframework.boot spring-boot-starter-actuator - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + org.springframework.cloud spring-cloud-starter-netflix-zuul diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/src/main/java/demo/ZuulConfigDiscoveryApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/src/main/java/demo/ZuulConfigDiscoveryApplication.java index 032514a7..b9f91983 100755 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/src/main/java/demo/ZuulConfigDiscoveryApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/src/main/java/demo/ZuulConfigDiscoveryApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.WebApplicationType; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/src/test/java/demo/ZuulConfigDiscoveryApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/src/test/java/demo/ZuulConfigDiscoveryApplicationTests.java index c44ac107..9dd281cb 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/src/test/java/demo/ZuulConfigDiscoveryApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-config-discovery/src/test/java/demo/ZuulConfigDiscoveryApplicationTests.java @@ -1,10 +1,27 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.boot.web.server.LocalServerPort; + import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/pom.xml index 2bcc5a68..3223cb1b 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -36,7 +36,7 @@ 1.8 Greenwich.BUILD-SNAPSHOT - + org.springframework.cloud diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/main/java/demo/ZuulProxyEurekaApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/main/java/demo/ZuulProxyEurekaApplication.java index d0f845ee..1eb46da9 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/main/java/demo/ZuulProxyEurekaApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/main/java/demo/ZuulProxyEurekaApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -11,4 +27,5 @@ public class ZuulProxyEurekaApplication { public static void main(String[] args) { SpringApplication.run(ZuulProxyEurekaApplication.class, args); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/main/resources/application.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/main/resources/application.properties index 9923b369..157e0f2d 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/main/resources/application.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/main/resources/application.properties @@ -1,3 +1,3 @@ -debug: true -spring.application.name: zuulproxy -server.port: 9900 \ No newline at end of file +debug:true +spring.application.name:zuulproxy +server.port:9900 \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/test/java/demo/ZuulProxyEurekaApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/test/java/demo/ZuulProxyEurekaApplicationTests.java index bcbec8bd..83fa8b08 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/test/java/demo/ZuulProxyEurekaApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy-eureka/src/test/java/demo/ZuulProxyEurekaApplicationTests.java @@ -1,9 +1,24 @@ -package demo; +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -import static org.junit.Assert.assertTrue; +package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -12,6 +27,8 @@ import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext @@ -26,9 +43,12 @@ public class ZuulProxyEurekaApplicationTests { @Test public void discoveryClientIsEureka() { - assertTrue("discoveryClient is wrong type", discoveryClient instanceof CompositeDiscoveryClient); - assertTrue("composite discovery client should compose Eureka Discovery Client with highest precedence", - ((CompositeDiscoveryClient)discoveryClient).getDiscoveryClients().get(0) instanceof EurekaDiscoveryClient); + assertTrue("discoveryClient is wrong type", + discoveryClient instanceof CompositeDiscoveryClient); + assertTrue( + "composite discovery client should compose Eureka Discovery Client with highest precedence", + ((CompositeDiscoveryClient) discoveryClient).getDiscoveryClients() + .get(0) instanceof EurekaDiscoveryClient); } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/pom.xml index 0c908144..2c3ea47c 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -36,7 +36,7 @@ 1.8 Greenwich.BUILD-SNAPSHOT - + org.springframework.cloud diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/main/java/demo/ZuulProxyApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/main/java/demo/ZuulProxyApplication.java index eead11ba..79338838 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/main/java/demo/ZuulProxyApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/main/java/demo/ZuulProxyApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.springframework.boot.SpringApplication; @@ -12,6 +28,10 @@ import org.springframework.web.bind.annotation.RestController; @RestController public class ZuulProxyApplication { + public static void main(String[] args) { + SpringApplication.run(ZuulProxyApplication.class, args); + } + @RequestMapping("/good") public String good(@RequestParam(required = false) String value) { return "GOOD" + (value == null ? "" : " " + value) + "!"; @@ -22,7 +42,4 @@ public class ZuulProxyApplication { return "STUFF!"; } - public static void main(String[] args) { - SpringApplication.run(ZuulProxyApplication.class, args); - } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/main/resources/application.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/main/resources/application.properties index a779086f..2705064d 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/main/resources/application.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/main/resources/application.properties @@ -1,15 +1,15 @@ -spring.application.name: zuulproxy -server.port: 9900 -zuul.ignored-patterns: /missing -zuul.routes.admin.path: /admin/** -zuul.routes.admin.url: forward:/ -zuul.routes.good.path: /good/** -zuul.routes.good.url: forward:/good -zuul.routes.bad.path: /bad/** -zuul.routes.bad.url: http://localhost:7777 -zuul.routes.gh.path: /gh/** -zuul.routes.gh.url: https://github.com -zuul.routes.gh.sensitive-headers: Set-Cookie,Cookie -zuul.routes.ui.path: /** -zuul.routes.ui.url: http://localhost:8080 -logging.level.org.springframework.web: DEBUG \ No newline at end of file +spring.application.name:zuulproxy +server.port:9900 +zuul.ignored-patterns:/missing +zuul.routes.admin.path:/admin/** +zuul.routes.admin.url:forward:/ +zuul.routes.good.path:/good/** +zuul.routes.good.url:forward:/good +zuul.routes.bad.path:/bad/** +zuul.routes.bad.url:http://localhost:7777 +zuul.routes.gh.path:/gh/** +zuul.routes.gh.url:https://github.com +zuul.routes.gh.sensitive-headers:Set-Cookie,Cookie +zuul.routes.ui.path:/** +zuul.routes.ui.url:http://localhost:8080 +logging.level.org.springframework.web:DEBUG \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/java/apps/UiApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/java/apps/UiApplication.java index e4a4d0e6..e8aed751 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/java/apps/UiApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/java/apps/UiApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package apps; import java.io.IOException; @@ -15,6 +31,11 @@ import org.springframework.web.servlet.support.ServletUriComponentsBuilder; @RestController public class UiApplication { + public static void main(String[] args) { + new SpringApplicationBuilder(UiApplication.class) + .properties("spring.config.name:ui").run(args); + } + @RequestMapping("/") public String home(@RequestParam(required = false) String value) { return "Hello " + (value == null ? "World" : value); @@ -36,8 +57,4 @@ public class UiApplication { return new String(file.getBytes()); } - public static void main(String[] args) { - new SpringApplicationBuilder(UiApplication.class) - .properties("spring.config.name:ui").run(args); - } } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/java/demo/ZuulProxyApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/java/demo/ZuulProxyApplicationTests.java index d9789b72..c62deba7 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/java/demo/ZuulProxyApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/java/demo/ZuulProxyApplicationTests.java @@ -1,12 +1,29 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient; import org.springframework.http.HttpStatus; @@ -18,7 +35,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext public class ZuulProxyApplicationTests { @@ -32,26 +49,31 @@ public class ZuulProxyApplicationTests { @Test public void ignoredPatternMissing() { - ResponseEntity result = this.restTemplate.getForEntity("http://localhost:"+this.port +"/missing", String.class); + ResponseEntity result = this.restTemplate + .getForEntity("http://localhost:" + this.port + "/missing", String.class); assertEquals(HttpStatus.NOT_FOUND, result.getStatusCode()); } @Test public void forwardedPatternGood() { - ResponseEntity result = this.restTemplate.getForEntity("http://localhost:"+this.port +"/good", String.class); + ResponseEntity result = this.restTemplate + .getForEntity("http://localhost:" + this.port + "/good", String.class); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals("GOOD!", result.getBody()); } @Test public void forwardedPatternGoodWithPath() { - ResponseEntity result = this.restTemplate.getForEntity("http://localhost:"+this.port +"/good/stuff", String.class); + ResponseEntity result = this.restTemplate.getForEntity( + "http://localhost:" + this.port + "/good/stuff", String.class); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals("STUFF!", result.getBody()); } @Test public void discoveryClientIsComposite() { - assertTrue("discoveryClient is wrong type", this.discoveryClient instanceof CompositeDiscoveryClient); + assertTrue("discoveryClient is wrong type", + this.discoveryClient instanceof CompositeDiscoveryClient); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/resources/ui.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/resources/ui.properties index 04b145f7..b8343fab 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/resources/ui.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul-proxy/src/test/resources/ui.properties @@ -1,3 +1,3 @@ -spring.application.name: ui -multipart.maxFileSize: 128KB -multipart.maxRequestSize: 128KB \ No newline at end of file +spring.application.name:ui +multipart.maxFileSize:128KB +multipart.maxRequestSize:128KB \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/pom.xml index e80b9a9f..06d6de6a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud.sample @@ -24,17 +24,17 @@ 1.8 Greenwich.BUILD-SNAPSHOT - + - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/main/java/demo/ZuulApplication.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/main/java/demo/ZuulApplication.java index 854fa991..1e06a470 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/main/java/demo/ZuulApplication.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/main/java/demo/ZuulApplication.java @@ -1,15 +1,31 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import javax.servlet.http.HttpServletResponse; +import com.netflix.zuul.ZuulFilter; +import com.netflix.zuul.context.RequestContext; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.zuul.EnableZuulServer; import org.springframework.stereotype.Component; -import com.netflix.zuul.ZuulFilter; -import com.netflix.zuul.context.RequestContext; - @SpringBootApplication @EnableZuulServer public class ZuulApplication { @@ -17,6 +33,7 @@ public class ZuulApplication { public static void main(String[] args) { SpringApplication.run(ZuulApplication.class, args); } + } @Component @@ -61,4 +78,5 @@ class SampleStaticResponseFilter extends ZuulFilter { } return null; } + } \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/main/resources/application.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/main/resources/application.properties index b7407986..e197c261 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/main/resources/application.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/main/resources/application.properties @@ -1,3 +1,3 @@ -spring.application.name: zuul -server.port: 9900 -zuul.routes.ui.path: /static/** \ No newline at end of file +spring.application.name:zuul +server.port:9900 +zuul.routes.ui.path:/static/** \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/test/java/demo/ZuulApplicationTests.java b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/test/java/demo/ZuulApplicationTests.java index 9201309c..054587d6 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/test/java/demo/ZuulApplicationTests.java +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/test/java/demo/ZuulApplicationTests.java @@ -1,12 +1,29 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package demo; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient; import org.springframework.test.annotation.DirtiesContext; @@ -16,7 +33,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @DirtiesContext public class ZuulApplicationTests { @@ -37,4 +54,5 @@ public class ZuulApplicationTests { assertTrue("discoveryClient is wrong type", this.discoveryClient instanceof CompositeDiscoveryClient); } + } diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/test/resources/ui.properties b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/test/resources/ui.properties index 04b145f7..b8343fab 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/test/resources/ui.properties +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-core-tests/zuul/src/test/resources/ui.properties @@ -1,3 +1,3 @@ -spring.application.name: ui -multipart.maxFileSize: 128KB -multipart.maxRequestSize: 128KB \ No newline at end of file +spring.application.name:ui +multipart.maxFileSize:128KB +multipart.maxRequestSize:128KB \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/.settings.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/.settings.xml index 6c355129..6f542c94 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/.settings.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/.settings.xml @@ -1,66 +1,68 @@ - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - true - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - http://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - - + + + repo.spring.io + ${env.CI_DEPLOY_USERNAME} + ${env.CI_DEPLOY_PASSWORD} + + + + + + spring + + true + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + http://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/.travis.yml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/.travis.yml index 87c1ea4b..17d08479 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/.travis.yml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/.travis.yml @@ -6,4 +6,4 @@ language: java before_install: - gem install asciidoctor script: -- ./mvnw clean install -P docs -q -U -Dmaven.test.redirectTestOutputToFile=true + - ./mvnw clean install -P docs -q -U -Dmaven.test.redirectTestOutputToFile=true diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/docs/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/docs/pom.xml index 34780916..7b7c7381 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/docs/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/docs/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud spring-cloud-starter-docs diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/pom.xml index b4d75d7a..400e56d4 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 spring-cloud-starter-build pom @@ -11,7 +11,7 @@ org.springframework.cloud spring-cloud-build 1.3.1.BUILD-SNAPSHOT - + @@ -28,7 +28,7 @@ spring-cloud-dependencies spring-cloud-starter-parent - docs + docs diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/pom.xml index a136f9eb..febccf0c 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud @@ -32,7 +32,7 @@ - + org.springframework.cloud spring-cloud-commons-dependencies diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/pom.xml index 578e1504..4d82b00a 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.boot @@ -37,8 +37,9 @@ https://github.com/spring-cloud spring-docs - scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} - + + scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} + repo.spring.io diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/pom.xml index 93d76967..cc1150db 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -188,7 +188,7 @@ org.objenesis objenesis 2.1 - + org.hamcrest diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-core/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-core/pom.xml index 95e39305..18f75f4d 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-core/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-core/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 spring-cloud-sleuth-core diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-dependencies/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-dependencies/pom.xml index eff7bb02..c66ab1b1 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-dependencies/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-dependencies/pom.xml @@ -1,12 +1,12 @@ - 4.0.0 spring-cloud-dependencies-parent org.springframework.cloud 0.3.1.BUILD-SNAPSHOT - + spring-cloud-sleuth-dependencies 0.2.0.BUILD-SNAPSHOT diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples/pom.xml index acbc7e0c..b478b6a2 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml index af1ad015..c8d4486d 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - + 4.0.0 spring-cloud-sleuth-sample-zipkin-stream @@ -43,10 +43,10 @@ - - - - + + + + diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/pom.xml index ac5f1b59..dd79dcc9 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -188,7 +188,7 @@ org.objenesis objenesis 2.1 - + org.hamcrest diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-core/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-core/pom.xml index 95e39305..18f75f4d 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-core/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-core/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 spring-cloud-sleuth-core diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-dependencies/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-dependencies/pom.xml index eff7bb02..c66ab1b1 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-dependencies/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-dependencies/pom.xml @@ -1,12 +1,12 @@ - 4.0.0 spring-cloud-dependencies-parent org.springframework.cloud 0.3.1.BUILD-SNAPSHOT - + spring-cloud-sleuth-dependencies 0.2.0.BUILD-SNAPSHOT diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-samples/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-samples/pom.xml index acbc7e0c..b478b6a2 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-samples/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-samples/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml index 977e07d4..eafb5333 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-sleuth/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml @@ -15,8 +15,8 @@ ~ limitations under the License. --> - + 4.0.0 spring-cloud-sleuth-sample-zipkin-stream diff --git a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-static/current/index.html b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-static/current/index.html index 8ee4dcbf..efef4293 100644 --- a/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-static/current/index.html +++ b/spring-cloud-release-tools-core/src/test/resources/projects/spring-cloud-static/current/index.html @@ -4,10 +4,11 @@ Page Redirection -If you are not redirected automatically, follow the link to latest release +If you are not redirected automatically, follow the link + to latest release diff --git a/spring-cloud-release-tools-core/src/test/resources/raw/some-file.html b/spring-cloud-release-tools-core/src/test/resources/raw/some-file.html index e69de29b..8b137891 100644 --- a/spring-cloud-release-tools-core/src/test/resources/raw/some-file.html +++ b/spring-cloud-release-tools-core/src/test/resources/raw/some-file.html @@ -0,0 +1 @@ + diff --git a/spring-cloud-release-tools-core/src/test/resources/raw/spring-cloud-gh-pages-index.html b/spring-cloud-release-tools-core/src/test/resources/raw/spring-cloud-gh-pages-index.html index b90230a2..ff19a292 100644 --- a/spring-cloud-release-tools-core/src/test/resources/raw/spring-cloud-gh-pages-index.html +++ b/spring-cloud-release-tools-core/src/test/resources/raw/spring-cloud-gh-pages-index.html @@ -21,356 +21,423 @@ icon: stackoverflow - {% capture billboard_description %} - - Spring Cloud provides tools for developers to quickly build some of - the common patterns in distributed systems (e.g. configuration - management, service discovery, circuit breakers, intelligent routing, - micro-proxy, control bus, one-time tokens, global locks, leadership - election, distributed sessions, cluster state). Coordination of - distributed systems leads to boiler plate patterns, and using Spring - Cloud developers can quickly stand up services and applications that - implement those patterns. They will work well in any distributed - environment, including the developer's own laptop, bare metal data - centres, and managed platforms such as Cloud Foundry. - - {% endcapture %} - - {% capture main_content %} - - Spring Cloud builds on Spring Boot by providing a bunch of libraries - that enhance the behaviour of an application when added to the - classpath. You can take advantage of the basic default behaviour to - get started really quickly, and then when you need to, you can - configure or extend to create a custom solution. - - - - ## Quick Start - - The release train label (see below) is actually only used explicitly - in one artifact: "spring-cloud-dependencies" (all the others have - normal numeric release labels tied to their parent project). The - dependencies POM is the one you can use as a BOM for dependency - management. Example using the latest version with the config client - and eureka (change the artifact ids to pull in other starters): - - {% include download_widget.md %} - - ## Features - - Spring Cloud focuses on providing good out of box experience for typical use cases and extensibility mechanism to cover others. - - * Distributed/versioned configuration - * Service registration and discovery - * Routing - * Service-to-service calls - * Load balancing - * Circuit Breakers - * Global locks - * Leadership election and cluster state - * Distributed messaging - - Spring Cloud takes a very declarative approach, and often you get a - lot of fetaures with just a classpath change and/or an - annotation. Example application that is a discovery client: - - ```java - @SpringBootApplication - @EnableDiscoveryClient - public class Application { - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - } - ``` - - - - ## Main Projects - - - {% capture project_description %} - Centralized external configuration management backed by a git repository. The configuration resources map directly to Spring `Environment` but could be used by non-Spring applications if desired. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-config" repo_url="http://github.com/spring-cloud/spring-cloud-config" project_title="Spring Cloud Config" project_description=project_description %} - - - {% capture project_description %} - Integration with various Netflix OSS components (Eureka, Hystrix, Zuul, Archaius, etc.). - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-netflix" repo_url="http://github.com/spring-cloud/spring-cloud-netflix" project_title="Spring Cloud Netflix" project_description=project_description %} - - - {% capture project_description %} - An event bus for linking services and service instances together with distributed messaging. Useful for propagating state changes across a cluster (e.g. config change events). - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-bus" repo_url="http://github.com/spring-cloud/spring-cloud-bus" project_title="Spring Cloud Bus" project_description=project_description %} - - - {% capture project_description %} - Integrates your application with Pivotal Cloud Foundry. Provides a service discovery implementation and also makes it easy to implement SSO and OAuth2 protected resources. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-cloudfoundry" repo_url="http://github.com/spring-cloud/spring-cloud-cloudfoundry" project_title="Spring Cloud for Cloud Foundry" project_description=project_description %} - - - {% capture project_description %} - Provides a starting point for building a service broker that implements the Open Service Broker API. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-open-service-broker/" repo_url="http://github.com/spring-cloud/spring-cloud-open-service-broker" project_title="Spring Cloud Open Service Broker" project_description=project_description %} - - - {% capture project_description %} - Leadership election and common stateful patterns with an abstraction and implementation for Zookeeper, Redis, Hazelcast, Consul. - {% endcapture %} - - {% include project_block.md site_url="/spring-cloud" repo_url="http://github.com/spring-cloud/spring-cloud-cluster" project_title="Spring Cloud Cluster" project_description=project_description %} - - - {% capture project_description %} - Service discovery and configuration management with Hashicorp Consul. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-consul" repo_url="http://github.com/spring-cloud/spring-cloud-consul" project_title="Spring Cloud Consul" project_description=project_description %} - - - {% capture project_description %} - Provides support for load-balanced OAuth2 rest client and authentication header relays in a Zuul proxy. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-security" repo_url="http://github.com/spring-cloud/spring-cloud-security" project_title="Spring Cloud Security" project_description=project_description %} - - - {% capture project_description %} - Distributed tracing for Spring Cloud applications, compatible with Zipkin, HTrace and log-based (e.g. ELK) tracing. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-sleuth" repo_url="http://github.com/spring-cloud/spring-cloud-sleuth" project_title="Spring Cloud Sleuth" project_description=project_description %} - - - {% capture project_description %} - A cloud-native orchestration service for composable microservice applications on modern runtimes. Easy-to-use DSL, drag-and-drop GUI, and REST-APIs together simplifies the overall orchestration of microservice based data pipelines. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-dataflow" repo_url="https://github.com/spring-cloud/spring-cloud-dataflow" project_title="Spring Cloud Data Flow" project_description=project_description %} - - - {% capture project_description %} - A lightweight event-driven microservices framework to quickly build applications that can connect to external systems. Simple declarative model to send and receive messages using Apache Kafka or RabbitMQ between Spring Boot apps. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-stream" repo_url="http://github.com/spring-cloud/spring-cloud-stream" project_title="Spring Cloud Stream" project_description=project_description %} - - - {% capture project_description %} - Spring Cloud Stream App Starters are Spring Boot based Spring Integration applications that provide integration with external systems. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-stream-app-starters" repo_url="https://github.com/spring-cloud/spring-cloud-stream-app-starters" project_title="Spring Cloud Stream App Starters" project_description=project_description %} - - - {% capture project_description %} - A short-lived microservices framework to quickly build applications that perform finite amounts of data processing. Simple declarative for adding both functional and non-functional features to Spring Boot apps. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-task" repo_url="http://github.com/spring-cloud/spring-cloud-task" project_title="Spring Cloud Task" project_description=project_description %} - - - {% capture project_description %} - Spring Cloud Task App Starters are Spring Boot applications that may be any process including Spring Batch jobs that do not run forever, and they end/stop after a finite period of data processing. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-task-app-starters" repo_url="https://github.com/spring-cloud/spring-cloud-task-app-starters" project_title="Spring Cloud Task App Starters" project_description=project_description %} - - - {% capture project_description %} - Service discovery and configuration management with Apache Zookeeper. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-zookeeper" repo_url="http://github.com/spring-cloud/spring-cloud-zookeeper" project_title="Spring Cloud Zookeeper" project_description=project_description %} - - - {% capture project_description %} - Easy integration with hosted Amazon Web Services. It offers a convenient way to interact with AWS provided services using well-known Spring idioms and APIs, such as the messaging or caching API. Developers can build their application around the hosted services without having to care about infrastructure or maintenance. - {% endcapture %} - - {% capture site_url %} - {{ site.projects_site_url }}/spring-cloud-aws - {% endcapture %} - - {% include project_block.md site_url=site_url repo_url="http://github.com/spring-cloud/spring-cloud-aws" project_title="Spring Cloud for Amazon Web Services" project_description=project_description %} - - - {% capture project_description %} - Makes it easy for PaaS applications in a variety of platforms to connect to backend services like - databases and message brokers (the project formerly known as "Spring Cloud"). - {% endcapture %} - - {% capture site_url %} - {{ site.projects_site_url }}/spring-cloud-connectors - {% endcapture %} - - {% include project_block.md site_url=site_url repo_url="http://github.com/spring-cloud/spring-cloud-connectors" project_title="Spring Cloud Connectors" project_description=project_description %} - - - {% capture project_description %} - Spring Boot-style starter projects to ease dependency management for consumers of Spring Cloud. (Discontinued as a project and merged with the other projects after Angel.SR2.) - {% endcapture %} - - {% include project_block.md site_url="http://github.com/spring-cloud/spring-cloud-starters" repo_url="http://github.com/spring-cloud/spring-cloud-starters" project_title="Spring Cloud Starters" project_description=project_description %} - - - {% capture project_description %} - Spring Boot CLI plugin for creating Spring Cloud component applications quickly in Groovy - {% endcapture %} - - {% include project_block.md site_url="http://github.com/spring-cloud/spring-cloud-cli" repo_url="http://github.com/spring-cloud/spring-cloud-cli" project_title="Spring Cloud CLI" project_description=project_description %} - - - {% capture project_description %} - Spring Cloud Contract is an umbrella project holding solutions that help users in successfully implementing the Consumer Driven Contracts approach. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-contract" repo_url="http://github.com/spring-cloud/spring-cloud-contract" project_title="Spring Cloud Contract" project_description=project_description %} - - - {% capture project_description %} - Spring Cloud Gateway is an intelligent and programmable router based on Project Reactor. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-gateway" repo_url="http://github.com/spring-cloud/spring-cloud-gateway" project_title="Spring Cloud Gateway" project_description=project_description %} - - - {% capture project_description %} - Spring Cloud OpenFeign provides integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-openfeign" repo_url="http://github.com/spring-cloud/spring-cloud-openfeign" project_title="Spring Cloud OpenFeign" project_description=project_description %} - - - {% capture project_description %} - Spring Cloud Pipelines provides an opinionated deployment pipeline with steps to ensure that your application can be deployed in zero downtime fashion and easilly rolled back of something goes wrong. - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-pipelines" repo_url="http://github.com/spring-cloud/spring-cloud-pipelines" project_title="Spring Cloud Pipelines" project_description=project_description %} - - - {% capture project_description %} - Spring Cloud Function promotes the implementation of business logic via functions. It supports a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS). - {% endcapture %} - - {% include project_block.md site_url="http://cloud.spring.io/spring-cloud-function" repo_url="http://github.com/spring-cloud/spring-cloud-function" project_title="Spring Cloud Function" project_description=project_description %} - - ## Release Trains - - Spring Cloud is an umbrella project consisting of independent projects with, in principle, different - release cadences. To manage the portfolio a BOM (Bill of Materials) is published with a curated - set of dependencies on the individual project (see below). The release trains have names, not - versions, to avoid confusion with the sub-projects. The names are an alphabetic sequence (so - you can sort them chronologically) with names of London Tube stations ("Angel" is the first - release, "Brixton" is the second). When point releases of the individual projects accumulate to - a critical mass, or if there is a critical bug in one of them that needs to be available to everyone, - the release train will push out "service releases" with names ending ".SRX", where "X" - is a number. - - Release train contents: - - - - |Component | Edgware.SR5 | Finchley.SR1 | Finchley.BUILD-SNAPSHOT| - |--------------------------------------|-----------------|---------------------|------------------------| - |spring-cloud-aws | 1.2.3.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | - |spring-cloud-bus | 1.3.3.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | - |spring-cloud-cli | 1.4.1.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | - |spring-cloud-commons | 1.3.5.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-contract | 1.2.6.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-config | 1.4.5.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-netflix | 1.4.6.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-security | 1.2.3.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | - |spring-cloud-cloudfoundry | 1.1.2.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | - |spring-cloud-consul | 1.3.5.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-sleuth | 1.3.5.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-stream | Ditmars.SR4 | Elmhurst.SR1 | Elmhurst.BUILD-SNAPSHOT| - |spring-cloud-zookeeper | 1.2.2.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | - |spring-boot | 1.5.16.RELEASE | 2.0.4.RELEASE | 2.0.4.BUILD-SNAPSHOT | - |spring-cloud-task | 1.2.3.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | - |spring-cloud-vault | 1.1.2.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-gateway | 1.0.2.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-openfeign | | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | - |spring-cloud-function | 1.0.1.RELEASE | 1.0.0.RELEASE | 1.0.1.BUILD-SNAPSHOT | - - - - Finchley builds and works with Spring Boot 2.0.x, and is not expected - to work with Spring Boot 1.5.x. - - Note: The Dalston release train will [reach end-of-life](https://spring.io/blog/2018/06/19/spring-cloud-finchley-release-is-available) in December 2018. Edgware will follow the end-of-life cycle of Spring Boot 1.5.x. - - The Dalston and Edgware release trains build on Spring Boot 1.5.x, and - are not expected to work with Spring Boot 2.0.x. - - NOTE: The Camden release train was [marked end-of-life](https://spring.io/blog/2018/06/19/spring-cloud-finchley-release-is-available). - - The Camden release train builds on Spring Boot 1.4.x, but is also - tested with 1.5.x. - - NOTE: The Brixton and Angel release trains were [marked end-of-life](https://spring.io/blog/2017/07/21/spring-cloud-dalston-sr2-is-available-now#end-of-life-for-angel-and-brixton-release-trains) - (EOL) in July 2017. - - The Brixton release train builds on Spring Boot 1.3.x, but is also - tested with 1.4.x. - - The Angel release train builds on Spring Boot 1.2.x, and is - incompatible in some areas with Spring Boot 1.3.x. Brixton builds on - Spring Boot 1.3.x and is similarly incompatible with 1.2.x. Some - libraries and most apps built on Angel will run fine on Brixton, but - changes will be required anywhere that the OAuth2 features from - spring-cloud-security 1.0.x are used (they were mostly moved to Spring - Boot in 1.3.0). - - Use your dependency management tools to control the version. If you - are using Maven remember that the first version declared wins, so - declare the BOMs in order, with the first one usually being the most - recent (e.g. if you want to use Spring Boot 1.3.6 with Brixton.RELEASE, put - the Boot BOM first). The same rule applies to Gradle if you use the - Spring dependency management plugin. - - > NOTE: The release train contains a - > `spring-cloud-dependencies` as well as the - > `spring-cloud-starter-parent`. You can use the parent as you would - > the `spring-boot-starter-parent` (if you are using Maven). - > If you only need dependency management, the "dependencies" - > version is a BOM-only version of the same thing (it just - > contains dependency management and no plugin declarations - > or direct references to Spring or Spring Boot). If you are - > using the Spring Boot parent POM, then you can use the BOM from - > Spring Cloud. The opposite is not true: using the Cloud parent - > makes it impossible, or at least unreliable, to also use the - > Boot BOM to change the version of Spring Boot and its dependencies. - - > NOTE: If you find anything wrong or outdated on this page, please open an issue in [this](https://github.com/spring-projects/spring-cloud) repo. - - {% endcapture %} - - {% capture related_resources %} - - ### Sample Projects - - * [Config Server](https://github.com/spring-cloud-samples/configserver) - * [Service Registry](https://github.com/spring-cloud-samples/eureka) - * [Circuit Breaker Dashboard](https://github.com/spring-cloud-samples/hystrix-dashboard) - * [Business Application](https://github.com/spring-cloud-samples/customers-stores) (Customers and Stores) - * [OAuth2 Authorization Server](https://github.com/spring-cloud-samples/authserver) - * [OAuth2 SSO Client](https://github.com/spring-cloud-samples/sso) - * [Integration Test Samples](https://github.com/spring-cloud-samples/tests) - * [Spring Cloud Contract Samples](https://github.com/spring-cloud-samples/spring-cloud-contract-samples) - - {% endcapture %} - - {% include project_page.html %} - \ No newline at end of file +{% capture billboard_description %} + +Spring Cloud provides tools for developers to quickly build some of +the common patterns in distributed systems (e.g. configuration +management, service discovery, circuit breakers, intelligent routing, +micro-proxy, control bus, one-time tokens, global locks, leadership +election, distributed sessions, cluster state). Coordination of +distributed systems leads to boiler plate patterns, and using Spring +Cloud developers can quickly stand up services and applications that +implement those patterns. They will work well in any distributed +environment, including the developer's own laptop, bare metal data +centres, and managed platforms such as Cloud Foundry. + +{% endcapture %} + +{% capture main_content %} + +Spring Cloud builds on Spring Boot by providing a bunch of libraries +that enhance the behaviour of an application when added to the +classpath. You can take advantage of the basic default behaviour to +get started really quickly, and then when you need to, you can +configure or extend to create a custom solution. + + + +## Quick Start + +The release train label (see below) is actually only used explicitly +in one artifact: "spring-cloud-dependencies" (all the others have +normal numeric release labels tied to their parent project). The +dependencies POM is the one you can use as a BOM for dependency +management. Example using the latest version with the config client +and eureka (change the artifact ids to pull in other starters): + +{% include download_widget.md %} + +## Features + +Spring Cloud focuses on providing good out of box experience for typical use cases and extensibility mechanism to cover +others. + +* Distributed/versioned configuration +* Service registration and discovery +* Routing +* Service-to-service calls +* Load balancing +* Circuit Breakers +* Global locks +* Leadership election and cluster state +* Distributed messaging + +Spring Cloud takes a very declarative approach, and often you get a +lot of fetaures with just a classpath change and/or an +annotation. Example application that is a discovery client: + +```java +@SpringBootApplication +@EnableDiscoveryClient +public class Application { +public static void main(String[] args) { +SpringApplication.run(Application.class, args); +} +} +``` + + + +## Main Projects + + +{% capture project_description %} +Centralized external configuration management backed by a git repository. The configuration resources map directly to +Spring `Environment` but could be used by non-Spring applications if desired. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-config" +repo_url="http://github.com/spring-cloud/spring-cloud-config" project_title="Spring Cloud Config" +project_description=project_description %} + + +{% capture project_description %} +Integration with various Netflix OSS components (Eureka, Hystrix, Zuul, Archaius, etc.). +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-netflix" +repo_url="http://github.com/spring-cloud/spring-cloud-netflix" project_title="Spring Cloud Netflix" +project_description=project_description %} + + +{% capture project_description %} +An event bus for linking services and service instances together with distributed messaging. Useful for propagating +state changes across a cluster (e.g. config change events). +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-bus" +repo_url="http://github.com/spring-cloud/spring-cloud-bus" project_title="Spring Cloud Bus" +project_description=project_description %} + + +{% capture project_description %} +Integrates your application with Pivotal Cloud Foundry. Provides a service discovery implementation and also makes it +easy to implement SSO and OAuth2 protected resources. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-cloudfoundry" +repo_url="http://github.com/spring-cloud/spring-cloud-cloudfoundry" project_title="Spring Cloud for Cloud Foundry" +project_description=project_description %} + + +{% capture project_description %} +Provides a starting point for building a service broker that implements the Open Service Broker API. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-open-service-broker/" +repo_url="http://github.com/spring-cloud/spring-cloud-open-service-broker" project_title="Spring Cloud Open Service +Broker" project_description=project_description %} + + +{% capture project_description %} +Leadership election and common stateful patterns with an abstraction and implementation for Zookeeper, Redis, Hazelcast, +Consul. +{% endcapture %} + +{% include project_block.md site_url="/spring-cloud" repo_url="http://github.com/spring-cloud/spring-cloud-cluster" +project_title="Spring Cloud Cluster" project_description=project_description %} + + +{% capture project_description %} +Service discovery and configuration management with Hashicorp Consul. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-consul" +repo_url="http://github.com/spring-cloud/spring-cloud-consul" project_title="Spring Cloud Consul" +project_description=project_description %} + + +{% capture project_description %} +Provides support for load-balanced OAuth2 rest client and authentication header relays in a Zuul proxy. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-security" +repo_url="http://github.com/spring-cloud/spring-cloud-security" project_title="Spring Cloud Security" +project_description=project_description %} + + +{% capture project_description %} +Distributed tracing for Spring Cloud applications, compatible with Zipkin, HTrace and log-based (e.g. ELK) tracing. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-sleuth" +repo_url="http://github.com/spring-cloud/spring-cloud-sleuth" project_title="Spring Cloud Sleuth" +project_description=project_description %} + + +{% capture project_description %} +A cloud-native orchestration service for composable microservice applications on modern runtimes. Easy-to-use DSL, +drag-and-drop GUI, and REST-APIs together simplifies the overall orchestration of microservice based data pipelines. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-dataflow" +repo_url="https://github.com/spring-cloud/spring-cloud-dataflow" project_title="Spring Cloud Data Flow" +project_description=project_description %} + + +{% capture project_description %} +A lightweight event-driven microservices framework to quickly build applications that can connect to external systems. +Simple declarative model to send and receive messages using Apache Kafka or RabbitMQ between Spring Boot apps. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-stream" +repo_url="http://github.com/spring-cloud/spring-cloud-stream" project_title="Spring Cloud Stream" +project_description=project_description %} + + +{% capture project_description %} +Spring Cloud Stream App Starters are Spring Boot based Spring Integration applications that provide integration with +external systems. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-stream-app-starters" +repo_url="https://github.com/spring-cloud/spring-cloud-stream-app-starters" project_title="Spring Cloud Stream App +Starters" project_description=project_description %} + + +{% capture project_description %} +A short-lived microservices framework to quickly build applications that perform finite amounts of data processing. +Simple declarative for adding both functional and non-functional features to Spring Boot apps. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-task" +repo_url="http://github.com/spring-cloud/spring-cloud-task" project_title="Spring Cloud Task" +project_description=project_description %} + + +{% capture project_description %} +Spring Cloud Task App Starters are Spring Boot applications that may be any process including Spring Batch jobs that do +not run forever, and they end/stop after a finite period of data processing. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-task-app-starters" +repo_url="https://github.com/spring-cloud/spring-cloud-task-app-starters" project_title="Spring Cloud Task App Starters" +project_description=project_description %} + + +{% capture project_description %} +Service discovery and configuration management with Apache Zookeeper. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-zookeeper" +repo_url="http://github.com/spring-cloud/spring-cloud-zookeeper" project_title="Spring Cloud Zookeeper" +project_description=project_description %} + + +{% capture project_description %} +Easy integration with hosted Amazon Web Services. It offers a convenient way to interact with AWS provided services +using well-known Spring idioms and APIs, such as the messaging or caching API. Developers can build their application +around the hosted services without having to care about infrastructure or maintenance. +{% endcapture %} + +{% capture site_url %} +{{ site.projects_site_url }}/spring-cloud-aws +{% endcapture %} + +{% include project_block.md site_url=site_url repo_url="http://github.com/spring-cloud/spring-cloud-aws" +project_title="Spring Cloud for Amazon Web Services" project_description=project_description %} + + +{% capture project_description %} +Makes it easy for PaaS applications in a variety of platforms to connect to backend services like +databases and message brokers (the project formerly known as "Spring Cloud"). +{% endcapture %} + +{% capture site_url %} +{{ site.projects_site_url }}/spring-cloud-connectors +{% endcapture %} + +{% include project_block.md site_url=site_url repo_url="http://github.com/spring-cloud/spring-cloud-connectors" +project_title="Spring Cloud Connectors" project_description=project_description %} + + +{% capture project_description %} +Spring Boot-style starter projects to ease dependency management for consumers of Spring Cloud. (Discontinued as a +project and merged with the other projects after Angel.SR2.) +{% endcapture %} + +{% include project_block.md site_url="http://github.com/spring-cloud/spring-cloud-starters" +repo_url="http://github.com/spring-cloud/spring-cloud-starters" project_title="Spring Cloud Starters" +project_description=project_description %} + + +{% capture project_description %} +Spring Boot CLI plugin for creating Spring Cloud component applications quickly in Groovy +{% endcapture %} + +{% include project_block.md site_url="http://github.com/spring-cloud/spring-cloud-cli" +repo_url="http://github.com/spring-cloud/spring-cloud-cli" project_title="Spring Cloud CLI" +project_description=project_description %} + + +{% capture project_description %} +Spring Cloud Contract is an umbrella project holding solutions that help users in successfully implementing the Consumer +Driven Contracts approach. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-contract" +repo_url="http://github.com/spring-cloud/spring-cloud-contract" project_title="Spring Cloud Contract" +project_description=project_description %} + + +{% capture project_description %} +Spring Cloud Gateway is an intelligent and programmable router based on Project Reactor. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-gateway" +repo_url="http://github.com/spring-cloud/spring-cloud-gateway" project_title="Spring Cloud Gateway" +project_description=project_description %} + + +{% capture project_description %} +Spring Cloud OpenFeign provides integrations for Spring Boot apps through autoconfiguration and binding to the Spring +Environment and other Spring programming model idioms. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-openfeign" +repo_url="http://github.com/spring-cloud/spring-cloud-openfeign" project_title="Spring Cloud OpenFeign" +project_description=project_description %} + + +{% capture project_description %} +Spring Cloud Pipelines provides an opinionated deployment pipeline with steps to ensure that your application can be +deployed in zero downtime fashion and easilly rolled back of something goes wrong. +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-pipelines" +repo_url="http://github.com/spring-cloud/spring-cloud-pipelines" project_title="Spring Cloud Pipelines" +project_description=project_description %} + + +{% capture project_description %} +Spring Cloud Function promotes the implementation of business logic via functions. It supports a uniform programming +model across serverless providers, as well as the ability to run standalone (locally or in a PaaS). +{% endcapture %} + +{% include project_block.md site_url="http://cloud.spring.io/spring-cloud-function" +repo_url="http://github.com/spring-cloud/spring-cloud-function" project_title="Spring Cloud Function" +project_description=project_description %} + +## Release Trains + +Spring Cloud is an umbrella project consisting of independent projects with, in principle, different +release cadences. To manage the portfolio a BOM (Bill of Materials) is published with a curated +set of dependencies on the individual project (see below). The release trains have names, not +versions, to avoid confusion with the sub-projects. The names are an alphabetic sequence (so +you can sort them chronologically) with names of London Tube stations ("Angel" is the first +release, "Brixton" is the second). When point releases of the individual projects accumulate to +a critical mass, or if there is a critical bug in one of them that needs to be available to everyone, +the release train will push out "service releases" with names ending ".SRX", where "X" +is a number. + +Release train contents: + + + +|Component | Edgware.SR5 | Finchley.SR1 | Finchley.BUILD-SNAPSHOT| +|--------------------------------------|-----------------|---------------------|------------------------| +|spring-cloud-aws | 1.2.3.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | +|spring-cloud-bus | 1.3.3.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | +|spring-cloud-cli | 1.4.1.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | +|spring-cloud-commons | 1.3.5.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-contract | 1.2.6.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-config | 1.4.5.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-netflix | 1.4.6.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-security | 1.2.3.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | +|spring-cloud-cloudfoundry | 1.1.2.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | +|spring-cloud-consul | 1.3.5.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-sleuth | 1.3.5.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-stream | Ditmars.SR4 | Elmhurst.SR1 | Elmhurst.BUILD-SNAPSHOT| +|spring-cloud-zookeeper | 1.2.2.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | +|spring-boot | 1.5.16.RELEASE | 2.0.4.RELEASE | 2.0.4.BUILD-SNAPSHOT | +|spring-cloud-task | 1.2.3.RELEASE | 2.0.0.RELEASE | 2.0.1.BUILD-SNAPSHOT | +|spring-cloud-vault | 1.1.2.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-gateway | 1.0.2.RELEASE | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-openfeign | | 2.0.1.RELEASE | 2.0.2.BUILD-SNAPSHOT | +|spring-cloud-function | 1.0.1.RELEASE | 1.0.0.RELEASE | 1.0.1.BUILD-SNAPSHOT | + + + +Finchley builds and works with Spring Boot 2.0.x, and is not expected +to work with Spring Boot 1.5.x. + +Note: The Dalston release train will [reach +end-of-life](https://spring.io/blog/2018/06/19/spring-cloud-finchley-release-is-available) in December 2018. Edgware +will follow the end-of-life cycle of Spring Boot 1.5.x. + +The Dalston and Edgware release trains build on Spring Boot 1.5.x, and +are not expected to work with Spring Boot 2.0.x. + +NOTE: The Camden release train was [marked +end-of-life](https://spring.io/blog/2018/06/19/spring-cloud-finchley-release-is-available). + +The Camden release train builds on Spring Boot 1.4.x, but is also +tested with 1.5.x. + +NOTE: The Brixton and Angel release trains were [marked +end-of-life](https://spring.io/blog/2017/07/21/spring-cloud-dalston-sr2-is-available-now#end-of-life-for-angel-and-brixton-release-trains) +(EOL) in July 2017. + +The Brixton release train builds on Spring Boot 1.3.x, but is also +tested with 1.4.x. + +The Angel release train builds on Spring Boot 1.2.x, and is +incompatible in some areas with Spring Boot 1.3.x. Brixton builds on +Spring Boot 1.3.x and is similarly incompatible with 1.2.x. Some +libraries and most apps built on Angel will run fine on Brixton, but +changes will be required anywhere that the OAuth2 features from +spring-cloud-security 1.0.x are used (they were mostly moved to Spring +Boot in 1.3.0). + +Use your dependency management tools to control the version. If you +are using Maven remember that the first version declared wins, so +declare the BOMs in order, with the first one usually being the most +recent (e.g. if you want to use Spring Boot 1.3.6 with Brixton.RELEASE, put +the Boot BOM first). The same rule applies to Gradle if you use the +Spring dependency management plugin. + +> NOTE: The release train contains a +> `spring-cloud-dependencies` as well as the +> `spring-cloud-starter-parent`. You can use the parent as you would +> the `spring-boot-starter-parent` (if you are using Maven). +> If you only need dependency management, the "dependencies" +> version is a BOM-only version of the same thing (it just +> contains dependency management and no plugin declarations +> or direct references to Spring or Spring Boot). If you are +> using the Spring Boot parent POM, then you can use the BOM from +> Spring Cloud. The opposite is not true: using the Cloud parent +> makes it impossible, or at least unreliable, to also use the +> Boot BOM to change the version of Spring Boot and its dependencies. + +> NOTE: If you find anything wrong or outdated on this page, please open an issue in +[this](https://github.com/spring-projects/spring-cloud) repo. + +{% endcapture %} + +{% capture related_resources %} + +### Sample Projects + +* [Config Server](https://github.com/spring-cloud-samples/configserver) +* [Service Registry](https://github.com/spring-cloud-samples/eureka) +* [Circuit Breaker Dashboard](https://github.com/spring-cloud-samples/hystrix-dashboard) +* [Business Application](https://github.com/spring-cloud-samples/customers-stores) (Customers and Stores) +* [OAuth2 Authorization Server](https://github.com/spring-cloud-samples/authserver) +* [OAuth2 SSO Client](https://github.com/spring-cloud-samples/sso) +* [Integration Test Samples](https://github.com/spring-cloud-samples/tests) +* [Spring Cloud Contract Samples](https://github.com/spring-cloud-samples/spring-cloud-contract-samples) + +{% endcapture %} + +{% include project_page.html %} + diff --git a/spring-cloud-release-tools-spring/pom.xml b/spring-cloud-release-tools-spring/pom.xml index 4a2e8746..49c2a314 100644 --- a/spring-cloud-release-tools-spring/pom.xml +++ b/spring-cloud-release-tools-spring/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -37,9 +37,9 @@ true - - - + + + com.fasterxml.jackson.dataformat diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/ReleaserApplication.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/ReleaserApplication.java index da3c61d2..d3d0ea85 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/ReleaserApplication.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/ReleaserApplication.java @@ -1,22 +1,40 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; @@ -31,29 +49,37 @@ public class ReleaserApplication implements CommandLineRunner { private static final Logger log = LoggerFactory.getLogger(ReleaserApplication.class); + @Autowired + SpringReleaser releaser; + + @Autowired + Parser parser; + public static void main(String[] args) { try { - SpringApplication application = new SpringApplication(ReleaserApplication.class); + SpringApplication application = new SpringApplication( + ReleaserApplication.class); application.setWebApplicationType(WebApplicationType.NONE); application.run(args); - } catch (Throwable e) { + } + catch (Throwable e) { log.error("Exception occurred for the releaser", e); throw e; } } - @Autowired SpringReleaser releaser; - @Autowired Parser parser; - - @Override public void run(String... strings) { + @Override + public void run(String... strings) { Options options = this.parser.parse(strings); try { this.releaser.release(options); - } catch (Throwable e) { - log.error("Exception occurred for the releaser. Picked options were [" + options + "]"); + } + catch (Throwable e) { + log.error("Exception occurred for the releaser. Picked options were [" + + options + "]"); throw e; } System.exit(0); } -} +} diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/Options.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/Options.java index 5d5242c3..512cf1a5 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/Options.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/Options.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.options; import java.util.List; @@ -7,22 +39,44 @@ import java.util.stream.Collectors; * @author Marcin Grzejszczak */ public class Options { + + /** + * Is meta release set. + */ public Boolean metaRelease; + + /** + * Is full release set. + */ public Boolean fullRelease; + + /** + * Is interactive mode set. + */ public Boolean interactive; + + /** + * List of task names to release. + */ public List taskNames; + + /** + * Name of the task / projects to start from. + */ public String startFrom = ""; + + /** + * Range of task / projects to release. + */ public String range = ""; - Options(Boolean metaRelease, Boolean fullRelease, - Boolean interactive, List taskNames, String startFrom, - String range) { + Options(Boolean metaRelease, Boolean fullRelease, Boolean interactive, + List taskNames, String startFrom, String range) { this.metaRelease = metaRelease; this.fullRelease = fullRelease; this.interactive = interactive; - this.taskNames = taskNames.stream() - .map(this::removeQuotingChars).collect( - Collectors.toList()); + this.taskNames = taskNames.stream().map(this::removeQuotingChars) + .collect(Collectors.toList()); this.startFrom = removeQuotingChars(startFrom); this.range = removeQuotingChars(range); } @@ -34,9 +88,12 @@ public class Options { return string; } - @Override public String toString() { - return "Options{" + "metaRelease=" + this.metaRelease + ", fullRelease=" + this.fullRelease - + ", interactive=" + this.interactive + ", taskNames=" + this.taskNames - + ", startFrom='" + this.startFrom + '\'' + ", range='" + this.range + '\'' + '}'; + @Override + public String toString() { + return "Options{" + "metaRelease=" + this.metaRelease + ", fullRelease=" + + this.fullRelease + ", interactive=" + this.interactive + ", taskNames=" + + this.taskNames + ", startFrom='" + this.startFrom + '\'' + ", range='" + + this.range + '\'' + '}'; } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/OptionsBuilder.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/OptionsBuilder.java index bece7b68..1d01d572 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/OptionsBuilder.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/OptionsBuilder.java @@ -1,14 +1,52 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.options; import java.util.ArrayList; import java.util.List; public class OptionsBuilder { + private Boolean metaRelease = false; + private Boolean fullRelease = false; + private Boolean interactive = true; + private List taskNames = new ArrayList<>(); + private String startFrom = ""; + private String range = ""; public OptionsBuilder metaRelease(Boolean metaRelease) { @@ -42,8 +80,8 @@ public class OptionsBuilder { } public Options options() { - return new Options(this.metaRelease, this.fullRelease, - this.interactive, this.taskNames, this.startFrom, - this.range); + return new Options(this.metaRelease, this.fullRelease, this.interactive, + this.taskNames, this.startFrom, this.range); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/Parser.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/Parser.java index e3bf72b5..ee9105a4 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/Parser.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/options/Parser.java @@ -1,10 +1,44 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.options; /** - * Converts input arguments to a {@link Options} + * Converts input arguments to a {@link Options}. * * @author Marcin Grzejszczak */ public interface Parser { + Options parse(String[] args); + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/sagan/SaganConfiguration.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/sagan/SaganConfiguration.java index b358b260..c150f4a7 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/sagan/SaganConfiguration.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/sagan/SaganConfiguration.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.sagan; import org.springframework.boot.web.client.RestTemplateBuilder; @@ -20,10 +52,12 @@ class SaganConfiguration { } private RestTemplate restTemplate(ReleaserProperties properties) { - Assert.hasText(properties.getGit().getOauthToken(), "In order to connect to Sagan you need to pass the Github OAuth token. " - + "You can do it via the [--releaser.git.oauth-token=...] command line argument or an env variable [export RELEASER_GIT_OAUTH_TOKEN=...]."); + Assert.hasText(properties.getGit().getOauthToken(), + "In order to connect to Sagan you need to pass the Github OAuth token. " + + "You can do it via the [--releaser.git.oauth-token=...] " + + "command line argument or an env variable [export RELEASER_GIT_OAUTH_TOKEN=...]."); return new RestTemplateBuilder() - .basicAuthorization(properties.getGit().getOauthToken(), "") - .build(); + .basicAuthorization(properties.getGit().getOauthToken(), "").build(); } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Args.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Args.java index 0352310a..2e423568 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Args.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Args.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.io.File; @@ -16,21 +48,31 @@ import org.springframework.context.ApplicationEventPublisher; * @author Marcin Grzejszczak */ class Args { + private static final Logger log = LoggerFactory.getLogger(Args.class); final Releaser releaser; + final File project; + final Projects projects; + final ProjectVersion originalVersion; + final ProjectVersion versionFromScRelease; + final ReleaserProperties properties; + final boolean interactive; + final TaskType taskType; + final ApplicationEventPublisher applicationEventPublisher; - Args(Releaser releaser, File project, Projects projects, ProjectVersion originalVersion, - ProjectVersion versionFromScRelease, ReleaserProperties properties, - boolean interactive, TaskType taskType, ApplicationEventPublisher applicationEventPublisher) { + Args(Releaser releaser, File project, Projects projects, + ProjectVersion originalVersion, ProjectVersion versionFromScRelease, + ReleaserProperties properties, boolean interactive, TaskType taskType, + ApplicationEventPublisher applicationEventPublisher) { this.releaser = releaser; this.project = project; this.projects = projects; @@ -43,10 +85,9 @@ class Args { } // Used by meta-release task - Args(Releaser releaser, Projects projects, - ProjectVersion versionFromScRelease, - ReleaserProperties properties, - boolean interactive, ApplicationEventPublisher applicationEventPublisher) { + Args(Releaser releaser, Projects projects, ProjectVersion versionFromScRelease, + ReleaserProperties properties, boolean interactive, + ApplicationEventPublisher applicationEventPublisher) { this.releaser = releaser; this.project = null; this.projects = projects; @@ -85,15 +126,12 @@ class Args { @Override public String toString() { - return "Args{" + - "releaser=" + this.releaser + - ", project=" + this.project + - ", projects=" + this.projects + - ", originalVersion=" + this.originalVersion + - ", versionFromScRelease=" + this.versionFromScRelease + - ", properties=" + this.properties + - ", interactive=" + this.interactive + - ", taskType=" + this.taskType + - '}'; + return "Args{" + "releaser=" + this.releaser + ", project=" + this.project + + ", projects=" + this.projects + ", originalVersion=" + + this.originalVersion + ", versionFromScRelease=" + + this.versionFromScRelease + ", properties=" + this.properties + + ", interactive=" + this.interactive + ", taskType=" + this.taskType + + '}'; } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/BuildCompleted.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/BuildCompleted.java index a4411cd8..0ca7ebcd 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/BuildCompleted.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/BuildCompleted.java @@ -5,7 +5,23 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -25,4 +41,5 @@ class BuildCompleted extends ReleaserTask { BuildCompleted(Object source) { super(source); } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ConsoleInputStepSkipper.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ConsoleInputStepSkipper.java index adbb9581..9b1b95a4 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ConsoleInputStepSkipper.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ConsoleInputStepSkipper.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; /** @@ -5,7 +37,8 @@ package org.springframework.cloud.release.internal.spring; */ class ConsoleInputStepSkipper implements StepSkipper { - @Override public boolean skipStep() { + @Override + public boolean skipStep() { String input = chosenOption(); switch (input.toLowerCase()) { case "s": @@ -21,4 +54,5 @@ class ConsoleInputStepSkipper implements StepSkipper { String chosenOption() { return System.console().readLine(); } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/OptionsParser.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/OptionsParser.java index 2ef79ece..ee747e9c 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/OptionsParser.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/OptionsParser.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.io.IOException; @@ -11,6 +43,7 @@ import joptsimple.OptionParser; import joptsimple.OptionSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.cloud.release.internal.options.Options; import org.springframework.cloud.release.internal.options.OptionsBuilder; import org.springframework.cloud.release.internal.options.Parser; @@ -37,27 +70,30 @@ class OptionsParser implements Parser { .acceptsAll(Arrays.asList("f", "full-release"), "Do you want to do the full release of a single project?") .withOptionalArg().ofType(Boolean.class).defaultsTo(false); - ArgumentAcceptingOptionSpec interactiveOpt = parser - .acceptsAll(Arrays.asList("i", "interactive"), - "Do you want to set the properties from the command line of a single project?") + ArgumentAcceptingOptionSpec interactiveOpt = parser.acceptsAll( + Arrays.asList("i", "interactive"), + "Do you want to set the properties from the command line of a single project?") .withRequiredArg().ofType(Boolean.class).defaultsTo(true); - Tasks.NON_COMPOSITE_TASKS.forEach(task -> - parser.acceptsAll(Arrays.asList(task.shortName, task.name), - task.description) - .withOptionalArg()); - ArgumentAcceptingOptionSpec startFromOpt = parser - .acceptsAll(Arrays.asList("a", "start-from"), - "Starts all release task starting from the given task. Requires passing the task name (either one letter or the full name)") + Tasks.NON_COMPOSITE_TASKS.forEach( + task -> parser.acceptsAll(Arrays.asList(task.shortName, task.name), + task.description).withOptionalArg()); + ArgumentAcceptingOptionSpec startFromOpt = parser.acceptsAll( + Arrays.asList("a", "start-from"), + "Starts all release task starting " + + "from the given task. Requires passing the task name (either one letter or the full name)") .withRequiredArg().ofType(String.class); ArgumentAcceptingOptionSpec taskNamesOpt = parser .acceptsAll(Arrays.asList("tn", "task-names"), "Starts all release task for the given task names") .withRequiredArg().ofType(String.class).defaultsTo(""); - ArgumentAcceptingOptionSpec rangeOpt = parser.acceptsAll(Arrays.asList("r", "range"), - "Runs release tasks from the given range. Requires passing the task names with a hyphen. The first task is inclusive, the second inclusive. E.g. 's-m' would mean running 'snapshot', 'push' and 'milestone' tasks") + ArgumentAcceptingOptionSpec rangeOpt = parser.acceptsAll( + Arrays.asList("r", "range"), + "Runs release tasks from the given range. Requires passing " + + "the task names with a hyphen. The first task is inclusive, " + + "the second inclusive. E.g. 's-m' would mean running 'snapshot', " + + "'push' and 'milestone' tasks") .withRequiredArg().ofType(String.class); - parser.acceptsAll(Arrays.asList("h", "help")) - .withOptionalArg(); + parser.acceptsAll(Arrays.asList("h", "help")).withOptionalArg(); OptionSet options = parser.parse(args); if (options.has("h")) { printHelpMessage(parser); @@ -66,36 +102,32 @@ class OptionsParser implements Parser { Boolean metaRelease = options.valueOf(metaReleaseOpt); Boolean interactive = options.valueOf(interactiveOpt); Boolean fullRelease = options.has(fullReleaseOpt); - List providedTaskNames = StringUtils.hasText(options.valueOf(taskNamesOpt)) ? - Arrays.asList(removeQuotingChars(options.valueOf(taskNamesOpt)).split(",")) : - new ArrayList<>(); - providedTaskNames = providedTaskNames.stream() - .map(this::removeQuotingChars) + List providedTaskNames = StringUtils.hasText(options + .valueOf(taskNamesOpt)) ? Arrays.asList( + removeQuotingChars(options.valueOf(taskNamesOpt)).split(",")) + : new ArrayList<>(); + providedTaskNames = providedTaskNames.stream().map(this::removeQuotingChars) .collect(Collectors.toList()); log.info("Passed tasks {} from command line", providedTaskNames); List allTaskNames = Tasks.NON_COMPOSITE_TASKS.stream() - .map(task -> task.name) - .collect(Collectors.toList()); + .map(task -> task.name).collect(Collectors.toList()); List tasksFromOptions = Tasks.NON_COMPOSITE_TASKS.stream() .filter(task -> options.has(task.name) || options.has(task.shortName)) .map(task -> task.name).collect(Collectors.toList()); if (providedTaskNames.isEmpty()) { - providedTaskNames.addAll(tasksFromOptions.isEmpty() && !metaRelease ? - allTaskNames : tasksFromOptions); + providedTaskNames.addAll(tasksFromOptions.isEmpty() && !metaRelease + ? allTaskNames : tasksFromOptions); } - List taskNames = filterProvidedTaskNames( - providedTaskNames, allTaskNames, metaRelease); + List taskNames = filterProvidedTaskNames(providedTaskNames, + allTaskNames, metaRelease); String startFrom = options.valueOf(startFromOpt); String range = options.valueOf(rangeOpt); - Options buildOptions = new OptionsBuilder() - .metaRelease(metaRelease) - .fullRelease(fullRelease) - .interactive(interactive) - .taskNames(taskNames) - .startFrom(startFrom) - .range(range) - .options(); - log.info("\n\nWill use the following options to process the project\n\n{}\n\n", buildOptions); + Options buildOptions = new OptionsBuilder().metaRelease(metaRelease) + .fullRelease(fullRelease).interactive(interactive) + .taskNames(taskNames).startFrom(startFrom).range(range).options(); + log.info( + "\n\nWill use the following options to process the project\n\n{}\n\n", + buildOptions); return buildOptions; } catch (Exception e) { @@ -109,8 +141,7 @@ class OptionsParser implements Parser { if (metaRelease) { return providedTaskNames; } - return allTaskNames.stream() - .filter(providedTaskNames::contains) + return allTaskNames.stream().filter(providedTaskNames::contains) .collect(Collectors.toList()); } @@ -130,7 +161,8 @@ class OptionsParser implements Parser { "java -jar spring-cloud-release-tools-spring-1.0.0.BUILD-SNAPSHOT.jar [options...] "); try { parser.printHelpOn(System.err); - } catch (IOException e1) { + } + catch (IOException e1) { throw new IllegalStateException(e1); } System.err.println(examples()); @@ -141,23 +173,22 @@ class OptionsParser implements Parser { System.out.println(intro()); parser.printHelpOn(System.out); System.out.println(examples()); - } catch (IOException e1) { + } + catch (IOException e1) { throw new IllegalStateException(e1); } } private String intro() { - return "\nHere you can find the list of tasks in order\n\n[" + Tasks.allTasksInOrder() + "]\n\n"; + return "\nHere you can find the list of tasks in order\n\n[" + + Tasks.allTasksInOrder() + "]\n\n"; } private String examples() { - return "\nExamples of usage:\n\n" - + "Run 'build' & 'commit' & 'deploy'\n" - + "java -jar jar.jar -b -c -d\n\n" - + "Start from 'push'\n" - + "java -jar releaser.jar -a push\n\n" - + "Range 'docs' -> 'push'\n" - + "java -jar releaser.jar -r o-p\n\n" - + "\n\n"; + return "\nExamples of usage:\n\n" + "Run 'build' & 'commit' & 'deploy'\n" + + "java -jar jar.jar -b -c -d\n\n" + "Start from 'push'\n" + + "java -jar releaser.jar -a push\n\n" + "Range 'docs' -> 'push'\n" + + "java -jar releaser.jar -r o-p\n\n" + "\n\n"; } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/OptionsProcessor.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/OptionsProcessor.java index 3e6d54cb..9c77ab0d 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/OptionsProcessor.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/OptionsProcessor.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.util.ArrayList; @@ -6,6 +38,7 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.cloud.release.internal.Releaser; import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.options.Options; @@ -16,25 +49,33 @@ import org.springframework.util.StringUtils; * @author Marcin Grzejszczak */ class OptionsProcessor { + private static final Logger log = LoggerFactory.getLogger(OptionsProcessor.class); private final Releaser releaser; + private final ReleaserProperties properties; + private final List allTasks; + private final ApplicationEventPublisher applicationEventPublisher; - OptionsProcessor(Releaser releaser, ReleaserProperties properties, ApplicationEventPublisher applicationEventPublisher) { - this(releaser, properties, applicationEventPublisher, Tasks.ALL_TASKS_PER_PROJECT); + OptionsProcessor(Releaser releaser, ReleaserProperties properties, + ApplicationEventPublisher applicationEventPublisher) { + this(releaser, properties, applicationEventPublisher, + Tasks.ALL_TASKS_PER_PROJECT); } - OptionsProcessor(Releaser releaser, ReleaserProperties properties, ApplicationEventPublisher applicationEventPublisher, List allTasks) { + OptionsProcessor(Releaser releaser, ReleaserProperties properties, + ApplicationEventPublisher applicationEventPublisher, List allTasks) { this.releaser = releaser; this.properties = properties; this.allTasks = allTasks; this.applicationEventPublisher = applicationEventPublisher; } - OptionsProcessor(Releaser releaser, ReleaserProperties properties, List allTasks) { + OptionsProcessor(Releaser releaser, ReleaserProperties properties, + List allTasks) { this.releaser = releaser; this.properties = properties; this.allTasks = allTasks; @@ -53,27 +94,32 @@ class OptionsProcessor { return; } String chosenOption = chosenOption(); - int pickedInteger = StringUtils.hasText(chosenOption) ? - Integer.parseInt(chosenOption) : -1; + int pickedInteger = StringUtils.hasText(chosenOption) + ? Integer.parseInt(chosenOption) : -1; boolean pickedOptionIsComposite = pickedInteger <= 1 && pickedInteger >= 0; - boolean pickedOptionIsFromPostRelease = pickedInteger >= Tasks.ALL_TASKS_PER_PROJECT.size() - - Tasks.DEFAULT_TASKS_PER_RELEASE.size(); + boolean pickedOptionIsFromPostRelease = pickedInteger >= Tasks.ALL_TASKS_PER_PROJECT + .size() - Tasks.DEFAULT_TASKS_PER_RELEASE.size(); if (options.metaRelease || options.fullRelease || pickedOptionIsComposite) { postReleaseTask().execute(args); - } else if (pickedOptionIsFromPostRelease) { + } + else if (pickedOptionIsFromPostRelease) { processNonComposite(options, tasks, args); - } else { - log.info("Picked option [{}] doesn't allow post release steps", pickedInteger); + } + else { + log.info("Picked option [{}] doesn't allow post release steps", + pickedInteger); } return; } if (options.fullRelease && !options.interactive) { log.info("Executing a full release in non-interactive mode"); releaseTask().execute(args); - } else if (options.fullRelease && options.interactive) { + } + else if (options.fullRelease && options.interactive) { log.info("Executing a full release in interactive mode"); releaseVerboseTask().execute(args); - } else { + } + else { processNonComposite(options, tasks, args); } } @@ -81,13 +127,17 @@ class OptionsProcessor { private void processNonComposite(Options options, List tasks, Args args) { if (StringUtils.hasText(options.startFrom)) { startFrom(tasks, options, args); - } else if (StringUtils.hasText(options.range)) { + } + else if (StringUtils.hasText(options.range)) { range(tasks, options.range, args); - } else if (!options.taskNames.isEmpty()) { + } + else if (!options.taskNames.isEmpty()) { tasks(tasks, options.taskNames, args); - } else if (options.interactive) { + } + else if (options.interactive) { interactiveOnly(tasks, args); - } else { + } + else { throw new IllegalStateException("You haven't picked any recognizable option"); } } @@ -136,10 +186,12 @@ class OptionsProcessor { if (sameRange) { break; } - } else if (started && (stop.equals(task.name) || stop.equals(task.shortName))) { + } + else if (started && (stop.equals(task.name) || stop.equals(task.shortName))) { task.execute(defaultArgs); break; - } else if (started) { + } + else if (started) { task.execute(defaultArgs); } } @@ -148,10 +200,12 @@ class OptionsProcessor { private void startFrom(List tasks, Options options, Args defaultArgs) { boolean started = false; for (Task task : tasks) { - if (options.startFrom.equals(task.name) || options.startFrom.equals(task.shortName)) { + if (options.startFrom.equals(task.name) + || options.startFrom.equals(task.shortName)) { started = true; task.execute(defaultArgs); - } else if (started) { + } + else if (started) { task.execute(defaultArgs); } } @@ -161,11 +215,17 @@ class OptionsProcessor { StringBuilder msg = new StringBuilder(); msg.append("\n\n\n=== WHAT DO YOU WANT TO DO? ===\n\n"); for (int i = 0; i < this.allTasks.size(); i++) { - msg.append(i).append(") ").append(this.allTasks.get(i).description).append("\n"); + msg.append(i).append(") ").append(this.allTasks.get(i).description) + .append("\n"); } - msg.append("\n").append("You can pick a range of options by using the hyphen - e.g. '2-4' will execute jobs [2,3,4]\n"); - msg.append("You can execute all tasks starting from a job by using a hyphen and providing only one number - e.g. '8-' will execute jobs [8,9,10]\n"); - msg.append("You can execute given tasks by providing a comma separated list of tasks - e.g. '3,7,8' will execute jobs [3,7,8]\n"); + msg.append("\n").append( + "You can pick a range of options by using the hyphen - e.g. '2-4' will execute jobs [2,3,4]\n"); + msg.append("You can execute all tasks starting from a job " + + "by using a hyphen and providing only one " + + "number - e.g. '8-' will execute jobs [8,9,10]\n"); + msg.append("You can execute given tasks by providing a " + + "comma separated list of tasks - e.g. " + + "'3,7,8' will execute jobs [3,7,8]\n"); msg.append("\n").append("You can press 'q' to quit\n\n"); return msg; } @@ -178,9 +238,11 @@ class OptionsProcessor { default: if (input.contains("-")) { rangeInteractive(tasks, defaultArgs, input); - } else if (input.contains(",")) { + } + else if (input.contains(",")) { tasksInteractive(tasks, defaultArgs, input); - } else { + } + else { singleTask(tasks, defaultArgs, input); } } @@ -222,10 +284,12 @@ class OptionsProcessor { private Args args(Args defaultArgs, boolean interactive) { return new Args(this.releaser, defaultArgs.project, defaultArgs.projects, defaultArgs.originalVersion, defaultArgs.versionFromScRelease, - this.properties, interactive, defaultArgs.taskType, this.applicationEventPublisher); + this.properties, interactive, defaultArgs.taskType, + this.applicationEventPublisher); } String chosenOption() { return System.console() == null ? "-1" : System.console().readLine(); } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java index ab41aa29..abc5679c 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java @@ -1,18 +1,35 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2019 the original author or authors. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import org.springframework.beans.factory.annotation.Autowired; @@ -47,10 +64,10 @@ class ReleaserConfiguration { } @Bean - SpringReleaser springReleaser(Releaser releaser, - ReleaserPropertiesUpdater updater, + SpringReleaser springReleaser(Releaser releaser, ReleaserPropertiesUpdater updater, ApplicationEventPublisher applicationEventPublisher) { - return new SpringReleaser(releaser, this.properties, updater, applicationEventPublisher); + return new SpringReleaser(releaser, this.properties, updater, + applicationEventPublisher); } @Bean @@ -79,14 +96,17 @@ class ReleaserConfiguration { } @Bean - SaganUpdater saganUpdater(SaganClient saganClient, ReleaserProperties releaserProperties) { + SaganUpdater saganUpdater(SaganClient saganClient, + ReleaserProperties releaserProperties) { return new SaganUpdater(saganClient, releaserProperties); } @Bean - PostReleaseActions postReleaseActions(ProjectGitHandler handler, ProjectPomUpdater pomUpdater, - GradleUpdater gradleUpdater, ProjectBuilder projectBuilder, ReleaserProperties releaserProperties) { - return new PostReleaseActions(handler, pomUpdater, gradleUpdater, projectBuilder, releaserProperties); + PostReleaseActions postReleaseActions(ProjectGitHandler handler, + ProjectPomUpdater pomUpdater, GradleUpdater gradleUpdater, + ProjectBuilder projectBuilder, ReleaserProperties releaserProperties) { + return new PostReleaseActions(handler, pomUpdater, gradleUpdater, projectBuilder, + releaserProperties); } @Bean @@ -99,9 +119,11 @@ class ReleaserConfiguration { Releaser releaser(ProjectPomUpdater projectPomUpdater, ProjectBuilder projectBuilder, ProjectGitHandler projectGitHandler, TemplateGenerator templateGenerator, GradleUpdater gradleUpdater, SaganUpdater saganUpdater, - DocumentationUpdater documentationUpdater, PostReleaseActions postReleaseActions) { + DocumentationUpdater documentationUpdater, + PostReleaseActions postReleaseActions) { return new Releaser(projectPomUpdater, projectBuilder, projectGitHandler, - templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, postReleaseActions); + templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, + postReleaseActions); } @Bean @@ -113,4 +135,5 @@ class ReleaserConfiguration { Parser optionsParser() { return new OptionsParser(); } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesUpdater.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesUpdater.java index ee25725c..7cb96c99 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesUpdater.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesUpdater.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.io.File; @@ -7,6 +39,7 @@ import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.context.properties.source.MapConfigurationPropertySource; @@ -20,16 +53,19 @@ import org.springframework.core.io.FileSystemResource; */ class ReleaserPropertiesUpdater { - private static final Logger log = LoggerFactory.getLogger(ReleaserPropertiesUpdater.class); + private static final Logger log = LoggerFactory + .getLogger(ReleaserPropertiesUpdater.class); private final ApplicationContext context; - public ReleaserPropertiesUpdater(ApplicationContext context) { + ReleaserPropertiesUpdater(ApplicationContext context) { this.context = context; } - ReleaserProperties updateProperties(ReleaserProperties properties, File clonedProjectFromOrg) { - ReleaserProperties props = updatePropertiesFromFile(properties, clonedProjectFromOrg); + ReleaserProperties updateProperties(ReleaserProperties properties, + File clonedProjectFromOrg) { + ReleaserProperties props = updatePropertiesFromFile(properties, + clonedProjectFromOrg); log.info("Updated properties [\n\n{}\n\n]", props); updateProperties(props); return props; @@ -50,25 +86,32 @@ class ReleaserPropertiesUpdater { yamlProcessor.setResources(new FileSystemResource(releaserConfig)); Properties properties = yamlProcessor.getObject(); ReleaserProperties releaserProperties = new Binder( - new MapConfigurationPropertySource(properties.entrySet().stream().collect( - Collectors.toMap( - e -> e.getKey().toString(), - e -> e.getValue().toString() - ) - ))).bind("releaser", ReleaserProperties.class).get(); + new MapConfigurationPropertySource(properties.entrySet().stream() + .collect(Collectors.toMap(e -> e.getKey().toString(), + e -> e.getValue().toString())))) + .bind("releaser", + ReleaserProperties.class) + .get(); log.info("config/releaser.yml found. Will update the current properties"); - copy.getMaven().setBuildCommand(releaserProperties.getMaven().getBuildCommand()); - copy.getMaven().setDeployCommand(releaserProperties.getMaven().getDeployCommand()); - copy.getGradle().setGradlePropsSubstitution(releaserProperties.getGradle().getGradlePropsSubstitution()); - copy.getGradle().setIgnoredGradleRegex(releaserProperties.getGradle().getIgnoredGradleRegex()); + copy.getMaven() + .setBuildCommand(releaserProperties.getMaven().getBuildCommand()); + copy.getMaven().setDeployCommand( + releaserProperties.getMaven().getDeployCommand()); + copy.getGradle().setGradlePropsSubstitution( + releaserProperties.getGradle().getGradlePropsSubstitution()); + copy.getGradle().setIgnoredGradleRegex( + releaserProperties.getGradle().getIgnoredGradleRegex()); } catch (Exception e) { throw new IllegalStateException(e); } - } else { - log.info("No config/releaser.yml found. Will NOT update the current properties"); } - log.info("Updating working directory to [{}]", clonedProjectFromOrg.getAbsolutePath()); + else { + log.info( + "No config/releaser.yml found. Will NOT update the current properties"); + } + log.info("Updating working directory to [{}]", + clonedProjectFromOrg.getAbsolutePath()); copy.setWorkingDir(clonedProjectFromOrg.getAbsolutePath()); return copy; } @@ -76,4 +119,5 @@ class ReleaserPropertiesUpdater { File releaserConfig(File clonedProjectFromOrg) { return new File(clonedProjectFromOrg, "config/releaser.yml"); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserTask.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserTask.java index 4f0776b4..6f2e5139 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserTask.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserTask.java @@ -5,7 +5,23 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -19,7 +35,9 @@ package org.springframework.cloud.release.internal.spring; import org.springframework.context.ApplicationEvent; class ReleaserTask extends ApplicationEvent { + ReleaserTask(Object source) { super(source); } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/SpringReleaser.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/SpringReleaser.java index 883f3435..0aaa9d2a 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/SpringReleaser.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/SpringReleaser.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.io.File; @@ -18,26 +50,33 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.util.StringUtils; /** - * Releaser that gets input from console + * Releaser that gets input from console. * * @author Marcin Grzejszczak */ public class SpringReleaser { + private static final Logger log = LoggerFactory.getLogger(SpringReleaser.class); private final Releaser releaser; + private final ReleaserProperties properties; + private final OptionsProcessor optionsProcessor; + private final ReleaserPropertiesUpdater updater; + private final ApplicationEventPublisher applicationEventPublisher; public SpringReleaser(Releaser releaser, ReleaserProperties properties, - ReleaserPropertiesUpdater updater, ApplicationEventPublisher applicationEventPublisher) { + ReleaserPropertiesUpdater updater, + ApplicationEventPublisher applicationEventPublisher) { this.releaser = releaser; this.properties = properties; this.updater = updater; this.applicationEventPublisher = applicationEventPublisher; - this.optionsProcessor = new OptionsProcessor(releaser, properties, applicationEventPublisher); + this.optionsProcessor = new OptionsProcessor(releaser, properties, + applicationEventPublisher); } SpringReleaser(Releaser releaser, ReleaserProperties properties, @@ -51,7 +90,7 @@ public class SpringReleaser { } /** - * Default behaviour - interactive mode + * Default behaviour - interactive mode. */ public void release() { release(new OptionsBuilder().options()); @@ -64,7 +103,8 @@ public class SpringReleaser { } if (this.properties.isPostReleaseTasksOnly()) { log.info("Skipping release process and moving only to post release"); - this.optionsProcessor.postReleaseOptions(options, postReleaseOptionsAgs(options, projectsAndVersion)); + this.optionsProcessor.postReleaseOptions(options, + postReleaseOptionsAgs(options, projectsAndVersion)); buildCompleted(); return; } @@ -76,64 +116,81 @@ public class SpringReleaser { this.applicationEventPublisher.publishEvent(new BuildCompleted(this)); } - private void performReleaseAndPostRelease(Options options, ProjectsAndVersion projectsAndVersion) { + private void performReleaseAndPostRelease(Options options, + ProjectsAndVersion projectsAndVersion) { if (options.metaRelease) { ReleaserProperties original = this.properties.copy(); log.debug("The following properties were found [{}]", original); metaReleaseProjects(options) - .forEach(project -> - processProjectForMetaRelease(original.copy(), options, project)); - } else { - log.info("Single project release picked. Will release only the current project"); + .forEach(project -> processProjectForMetaRelease(original.copy(), + options, project)); + } + else { + log.info( + "Single project release picked. Will release only the current project"); File projectFolder = projectFolder(); projectsAndVersion = processProject(options, projectFolder, TaskType.RELEASE); } - this.optionsProcessor.postReleaseOptions(options, postReleaseOptionsAgs(options, projectsAndVersion)); + this.optionsProcessor.postReleaseOptions(options, + postReleaseOptionsAgs(options, projectsAndVersion)); } private void prepareForMetaRelease(Options options) { - log.info("Meta Release picked. Will iterate over all projects and perform release of each one"); + log.info( + "Meta Release picked. Will iterate over all projects and perform release of each one"); this.properties.getGit().setFetchVersionsFromGit(false); this.properties.getMetaRelease().setEnabled(options.metaRelease); } - void processProjectForMetaRelease(ReleaserProperties copy, Options options, String project) { + void processProjectForMetaRelease(ReleaserProperties copy, Options options, + String project) { log.info("Original properties [\n\n{}\n\n]", copy); File clonedProjectFromOrg = this.releaser.clonedProjectFromOrg(project); updatePropertiesIfCustomConfigPresent(copy, clonedProjectFromOrg); - log.info("Successfully cloned the project [{}] to [{}]", project, clonedProjectFromOrg); + log.info("Successfully cloned the project [{}] to [{}]", project, + clonedProjectFromOrg); try { processProject(options, clonedProjectFromOrg, TaskType.RELEASE); - } catch (Exception e) { - log.error("\n\n\nBUILD FAILED!!!\n\nException occurred for project <" + - project + "> \n\n", e); + } + catch (Exception e) { + log.error("\n\n\nBUILD FAILED!!!\n\nException occurred for project <" + + project + "> \n\n", e); throw e; } } - private ReleaserProperties updatePropertiesIfCustomConfigPresent(ReleaserProperties copy, - File clonedProjectFromOrg) { + private ReleaserProperties updatePropertiesIfCustomConfigPresent( + ReleaserProperties copy, File clonedProjectFromOrg) { return this.updater.updateProperties(copy, clonedProjectFromOrg); } List metaReleaseProjects(Options options) { - List projects = new ArrayList<>(this.properties.getFixedVersions().keySet()); - log.info("List of projects that should not be cloned {}", this.properties.getMetaRelease().getProjectsToSkip()); - List filteredProjects = projects.stream() - .filter(project -> !this.properties.getMetaRelease().getProjectsToSkip().contains(project)) + List projects = new ArrayList<>( + this.properties.getFixedVersions().keySet()); + log.info("List of projects that should not be cloned {}", + this.properties.getMetaRelease().getProjectsToSkip()); + List filteredProjects = projects + .stream().filter(project -> !this.properties.getMetaRelease() + .getProjectsToSkip().contains(project)) .collect(Collectors.toList()); log.info("List of all projects to clone before filtering {}", filteredProjects); if (StringUtils.hasText(options.startFrom)) { log.info("Start from option provided [{}]", options.startFrom); int projectIndex = filteredProjects.indexOf(options.startFrom); - if (projectIndex < 0) throw new IllegalStateException("Project [" + options.startFrom + "] not found"); - if (log.isDebugEnabled()) { - log.debug("Index of project [{}] is [{}]", options.startFrom, projectIndex); + if (projectIndex < 0) { + throw new IllegalStateException( + "Project [" + options.startFrom + "] not found"); } - filteredProjects = filteredProjects.subList(projectIndex, filteredProjects.size()); + if (log.isDebugEnabled()) { + log.debug("Index of project [{}] is [{}]", options.startFrom, + projectIndex); + } + filteredProjects = filteredProjects.subList(projectIndex, + filteredProjects.size()); options.startFrom = ""; enforceFullRelease(options); - } else if (!options.taskNames.isEmpty()) { + } + else if (!options.taskNames.isEmpty()) { log.info("Task names provided {}", options.taskNames); filteredProjects = filteredProjects.stream() .filter(project -> options.taskNames.contains(project)) @@ -141,7 +198,8 @@ public class SpringReleaser { options.taskNames = new ArrayList<>(); enforceFullRelease(options); } - log.info("\n\n\nFor meta-release, will release the projects {}\n\n\n", filteredProjects); + log.info("\n\n\nFor meta-release, will release the projects {}\n\n\n", + filteredProjects); return filteredProjects; } @@ -155,39 +213,46 @@ public class SpringReleaser { } Args postReleaseOptionsAgs(Options options, ProjectsAndVersion projectsAndVersion) { - Projects projects = projectsAndVersion == null ? - projectsToUpdateForFixedVersions() : projectsAndVersion.projectVersions; - ProjectVersion version = projects.containsProject(this.properties.getMetaRelease().getReleaseTrainProjectName()) ? - projects.releaseTrain(this.properties) : versionFromBranch(); + Projects projects = projectsAndVersion == null + ? projectsToUpdateForFixedVersions() : projectsAndVersion.projectVersions; + ProjectVersion version = projects.containsProject( + this.properties.getMetaRelease().getReleaseTrainProjectName()) + ? projects.releaseTrain(this.properties) : versionFromBranch(); if (options.metaRelease) { this.properties.getPom().setBranch(version.version); } - return new Args(this.releaser, projects, version, - this.properties, options.interactive, this.applicationEventPublisher); + return new Args(this.releaser, projects, version, this.properties, + options.interactive, this.applicationEventPublisher); } private ProjectVersion versionFromBranch() { String branch = this.properties.getPom().getBranch(); - return new ProjectVersion(projectFolder().getName(), branch.startsWith("v") ? branch.substring(1) : branch); + return new ProjectVersion(projectFolder().getName(), + branch.startsWith("v") ? branch.substring(1) : branch); } private ProjectsAndVersion projects(File project) { ProjectVersion versionFromScRelease; Projects projectsToUpdate; - log.info("Fetch from git [{}], meta release [{}]", this.properties.getGit().isFetchVersionsFromGit(), + log.info("Fetch from git [{}], meta release [{}]", + this.properties.getGit().isFetchVersionsFromGit(), this.properties.getMetaRelease().isEnabled()); - if (this.properties.getGit().isFetchVersionsFromGit() && !this.properties.getMetaRelease().isEnabled()) { + if (this.properties.getGit().isFetchVersionsFromGit() + && !this.properties.getMetaRelease().isEnabled()) { printVersionRetrieval(); projectsToUpdate = this.releaser.retrieveVersionsFromSCRelease(); versionFromScRelease = projectsToUpdate.forFile(project); - assertNoSnapshotsForANonSnapshotProject(projectsToUpdate, versionFromScRelease); - } else { + assertNoSnapshotsForANonSnapshotProject(projectsToUpdate, + versionFromScRelease); + } + else { ProjectVersion originalVersion = new ProjectVersion(project); String fixedVersionForProject = this.properties.getFixedVersions() .get(project.getName()); - versionFromScRelease = StringUtils.hasText(fixedVersionForProject) ? - new ProjectVersion(originalVersion.projectName, fixedVersionForProject) : - new ProjectVersion(project); + versionFromScRelease = StringUtils.hasText(fixedVersionForProject) + ? new ProjectVersion(originalVersion.projectName, + fixedVersionForProject) + : new ProjectVersion(project); projectsToUpdate = this.properties.getFixedVersions().entrySet().stream() .map(entry -> new ProjectVersion(entry.getKey(), entry.getValue())) .collect(Collectors.toCollection(Projects::new)); @@ -197,21 +262,12 @@ public class SpringReleaser { return new ProjectsAndVersion(projectsToUpdate, versionFromScRelease); } - class ProjectsAndVersion { - final Projects projectVersions; - final ProjectVersion versionFromScRelease; - - ProjectsAndVersion(Projects projectVersions, ProjectVersion versionFromScRelease) { - this.projectVersions = projectVersions; - this.versionFromScRelease = versionFromScRelease; - } - } - ProjectsAndVersion processProject(Options options, File project, TaskType taskType) { ProjectsAndVersion projectsAndVersion = projects(project); ProjectVersion originalVersion = new ProjectVersion(project); - final Args defaultArgs = new Args(this.releaser, project, projectsAndVersion.projectVersions, - originalVersion, projectsAndVersion.versionFromScRelease, this.properties, + final Args defaultArgs = new Args(this.releaser, project, + projectsAndVersion.projectVersions, originalVersion, + projectsAndVersion.versionFromScRelease, this.properties, options.interactive, taskType, this.applicationEventPublisher); log.debug("Processing project [{}] with args [{}]", project, defaultArgs); this.optionsProcessor.processOptions(options, defaultArgs); @@ -225,24 +281,42 @@ public class SpringReleaser { } private void printVersionRetrieval() { - log.info("\n\n\n=== RETRIEVING VERSIONS ===\n\nWill clone Spring Cloud Release" - + " to retrieve all versions for the branch [{}]", this.properties.getPom().getBranch()); + log.info( + "\n\n\n=== RETRIEVING VERSIONS ===\n\nWill clone Spring Cloud Release" + + " to retrieve all versions for the branch [{}]", + this.properties.getPom().getBranch()); } private void printSettingVersionFromFixedVersions(Projects projectsToUpdate) { - log.info("\n\n\n=== RETRIEVED VERSIONS ===\n\nWill use the fixed versions" - + " of projects\n\n{}", projectsToUpdate - .stream().map(p -> p.projectName + " => " + p.version) - .collect(Collectors.joining("\n"))); + log.info( + "\n\n\n=== RETRIEVED VERSIONS ===\n\nWill use the fixed versions" + + " of projects\n\n{}", + projectsToUpdate.stream().map(p -> p.projectName + " => " + p.version) + .collect(Collectors.joining("\n"))); } private void assertNoSnapshotsForANonSnapshotProject(Projects projects, ProjectVersion versionFromScRelease) { if (!versionFromScRelease.isSnapshot() && projects.containsSnapshots()) { throw new IllegalStateException("You are trying to release a non snapshot " - + "version [" + versionFromScRelease + "] of the project [" + versionFromScRelease.projectName + "] but " + + "version [" + versionFromScRelease + "] of the project [" + + versionFromScRelease.projectName + "] but " + "there is at least one SNAPSHOT library version in the Spring Cloud Release project"); } } -} + class ProjectsAndVersion { + + final Projects projectVersions; + + final ProjectVersion versionFromScRelease; + + ProjectsAndVersion(Projects projectVersions, + ProjectVersion versionFromScRelease) { + this.projectVersions = projectVersions; + this.versionFromScRelease = versionFromScRelease; + } + + } + +} diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/StepSkipper.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/StepSkipper.java index dbb04bbe..57eabc46 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/StepSkipper.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/StepSkipper.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; /** @@ -6,5 +38,7 @@ package org.springframework.cloud.release.internal.spring; * @author Marcin Grzejszczak */ interface StepSkipper { + boolean skipStep(); + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Task.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Task.java index 432e378e..cefe706c 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Task.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Task.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.util.function.Consumer; @@ -12,16 +44,21 @@ import org.springframework.cloud.release.internal.tech.MakeBuildUnstableExceptio */ class Task { + private static final Logger log = LoggerFactory.getLogger(Task.class); + + private static final String MSG = "\nPress 'q' to quit, 's' to skip, any key to continue\n\n"; static StepSkipper stepSkipper = new ConsoleInputStepSkipper(); - private static final Logger log = LoggerFactory.getLogger(Task.class); - private static final String MSG = "\nPress 'q' to quit, 's' to skip, any key to continue\n\n"; - final String name; + final String shortName; + final String header; + final String description; + final TaskType taskType; + private final Consumer consumer; Task(String name, String shortName, String header, String description, @@ -41,8 +78,7 @@ class Task { TaskAndException execute(Args args) { TaskAndException taskAndException = doExecute(args); - args.publishEvent(new TaskCompleted(this, - args.projectName(), taskAndException)); + args.publishEvent(new TaskCompleted(this, args.projectName(), taskAndException)); return taskAndException; } @@ -61,12 +97,14 @@ class Task { return runTask(args); } return TaskAndException.skipped(this); - } else { + } + else { return runTask(args); } } catch (MakeBuildUnstableException atTheEnd) { - logError("TASK FAILED - WILL MARK THE BUILD UNSTABLE AT THE END!!!", args, atTheEnd); + logError("TASK FAILED - WILL MARK THE BUILD UNSTABLE AT THE END!!!", args, + atTheEnd); return TaskAndException.failure(this, atTheEnd); } catch (Exception e) { @@ -79,9 +117,9 @@ class Task { } private void logError(String prefix, Args args, Exception e) { - log.error("\n\n\n" + prefix + "\n\nException occurred for project <" + - (args.project != null ? args.project.getName() : "") + "> task <" + - this.name + "> \n\nwith description <" + this.description + ">\n\n", e); + log.error("\n\n\n" + prefix + "\n\nException occurred for project <" + + (args.project != null ? args.project.getName() : "") + "> task <" + + this.name + "> \n\nwith description <" + this.description + ">\n\n", e); } private TaskAndException runTask(Args args) { @@ -90,6 +128,8 @@ class Task { } private void printLog(boolean interactive) { - log.info("\n\n\n=== {} ===\n\n{} {}\n\n", this.header, this.description, interactive ? MSG : ""); + log.info("\n\n\n=== {} ===\n\n{} {}\n\n", this.header, this.description, + interactive ? MSG : ""); } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskAndException.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskAndException.java index b3c3ece2..6d18fa13 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskAndException.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskAndException.java @@ -14,15 +14,33 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; /** * @author Marcin Grzejszczak */ -class TaskAndException { +final class TaskAndException { final Task task; + final TaskState taskState; + final Exception exception; private TaskAndException(Task task, TaskState taskState) { @@ -50,8 +68,9 @@ class TaskAndException { } enum TaskState { + SKIPPED, SUCCESS, FAILURE + } + } - - diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskCollector.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskCollector.java index 1461c5e0..ca09a85a 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskCollector.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskCollector.java @@ -5,7 +5,23 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -53,20 +69,21 @@ class TaskCollector implements ApplicationListener { .filter(table1 -> StringUtils.hasText(table1.thrownException)) .collect(Collectors.toList()); if (!brokenTasks.isEmpty()) { - String brokenBuilds = "\n\n[BUILD UNSTABLE] The following release tasks are failing!\n\n" + - brokenTasks.stream() - .map(table1 -> - String.format("***** Project / Task : <%s/%s> ***** \nTask Description <%s>\nException Stacktrace \n\n%s", - table1.projectName, table1.taskCaption, - table1.taskDescription, table1.exception + "\n" + Arrays - .stream(table1.exception.getStackTrace()) - .map(StackTraceElement::toString) - .collect(Collectors.joining("\n")))) + String brokenBuilds = "\n\n[BUILD UNSTABLE] The following release tasks are failing!\n\n" + + brokenTasks.stream().map(table1 -> String.format( + "***** Project / Task : <%s/%s> ***** \nTask Description <%s>\nException Stacktrace \n\n%s", + table1.projectName, table1.taskCaption, + table1.taskDescription, + table1.exception + "\n" + + Arrays.stream(table1.exception.getStackTrace()) + .map(StackTraceElement::toString) + .collect(Collectors.joining("\n")))) .collect(Collectors.joining("\n\n")); log.warn(string + brokenBuilds); this.completedTasks.clear(); throw new IllegalStateException(brokenBuilds); - } else { + } + else { log.info(string); this.completedTasks.clear(); } @@ -76,27 +93,36 @@ class TaskCollector implements ApplicationListener { public void onApplicationEvent(ReleaserTask event) { if (event instanceof TaskCompleted) { handleTaskCompleted((TaskCompleted) event); - } else if (event instanceof BuildCompleted) { + } + else if (event instanceof BuildCompleted) { handleBuildCompleted((BuildCompleted) event); } } + } class Table { + final String projectName; + final String taskCaption; + final String taskDescription; + final String taskState; + final String thrownException; + Exception exception; Table(String projectName, TaskAndException tae) { - this.projectName = StringUtils.hasText(projectName) ? projectName : "Post Release"; + this.projectName = StringUtils.hasText(projectName) ? projectName + : "Post Release"; this.taskCaption = tae.task.name; this.taskDescription = tae.task.description; this.taskState = tae.taskState.name().toLowerCase(); - this.thrownException = tae.exception == null ? "" : - NestedExceptionUtils.getMostSpecificCause(tae.exception).toString(); + this.thrownException = tae.exception == null ? "" + : NestedExceptionUtils.getMostSpecificCause(tae.exception).toString(); this.exception = tae.exception; } @@ -119,4 +145,5 @@ class Table { public String getThrownException() { return this.thrownException; } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskCompleted.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskCompleted.java index 67c50eed..b762e5a6 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskCompleted.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/TaskCompleted.java @@ -5,7 +5,23 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -19,6 +35,7 @@ package org.springframework.cloud.release.internal.spring; class TaskCompleted extends ReleaserTask { final String projectName; + final TaskAndException taskAndException; /** @@ -33,9 +50,8 @@ class TaskCompleted extends ReleaserTask { @Override public String toString() { - return "TaskCompleted{" + - "projectName='" + this.projectName + '\'' + - ", taskName=" + this.taskAndException.task.name + - '}'; + return "TaskCompleted{" + "projectName='" + this.projectName + '\'' + + ", taskName=" + this.taskAndException.task.name + '}'; } + } diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Tasks.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Tasks.java index 55779398..238a9e0b 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Tasks.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/Tasks.java @@ -1,3 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.util.ArrayList; @@ -7,123 +39,98 @@ import java.util.stream.Collectors; import java.util.stream.Stream; /** - * All tasks that can be executed by the releaser + * All tasks that can be executed by the releaser. * * @author Marcin Grzejszczak */ -class Tasks { - static Task UPDATING_POMS = task("updatePoms", "u", - "UPDATING POMS", +final class Tasks { + + private Tasks() { + throw new IllegalStateException("Can't instantiate a utility class"); + } + + static Task UPDATING_POMS = task("updatePoms", "u", "UPDATING POMS", "Update poms with versions from Spring Cloud Release", - args -> args.releaser.updateProjectFromBom(args.project, args.projects, args.versionFromScRelease)); - static Task BUILD_PROJECT = task("build", "b", - "BUILD PROJECT", - "Build the project", + args -> args.releaser.updateProjectFromBom(args.project, args.projects, + args.versionFromScRelease)); + static Task BUILD_PROJECT = task("build", "b", "BUILD PROJECT", "Build the project", args -> args.releaser.buildProject(args.versionFromScRelease)); static Task COMMIT = task("commit", "c", "COMMITTING (ALL) AND PUSHING TAGS (NON-SNAPSHOTS)", - "Commit, tag and push the tag", - args -> args.releaser.commitAndPushTags(args.project, args.versionFromScRelease)); - static Task DEPLOY = task("deploy", "d", - "ARTIFACT DEPLOYMENT", + "Commit, tag and push the tag", args -> args.releaser + .commitAndPushTags(args.project, args.versionFromScRelease)); + static Task DEPLOY = task("deploy", "d", "ARTIFACT DEPLOYMENT", "Deploy the artifacts", args -> args.releaser.deploy(args.versionFromScRelease)); - static Task PUBLISH_DOCS = task("docs", "o", - "PUBLISHING DOCS", - "Publish the docs", + static Task PUBLISH_DOCS = task("docs", "o", "PUBLISHING DOCS", "Publish the docs", args -> args.releaser.publishDocs(args.versionFromScRelease)); static Task SNAPSHOTS = task("snapshots", "s", "REVERTING CHANGES & BUMPING VERSION (RELEASE ONLY)", "Go back to snapshots and bump originalVersion by patch", - args -> args.releaser.rollbackReleaseVersion(args.project, args.projects, args.versionFromScRelease)); - static Task PUSH = task("push", "p", - "PUSHING CHANGES", - "Push the commits", + args -> args.releaser.rollbackReleaseVersion(args.project, args.projects, + args.versionFromScRelease)); + static Task PUSH = task("push", "p", "PUSHING CHANGES", "Push the commits", args -> args.releaser.pushCurrentBranch(args.project)); - static Task CLOSE_MILESTONE = task("closeMilestone", "m", - "CLOSING MILESTONE", + static Task CLOSE_MILESTONE = task("closeMilestone", "m", "CLOSING MILESTONE", "Close the milestone at Github", args -> args.releaser.closeMilestone(args.versionFromScRelease)); - static Task CREATE_TEMPLATES = task("createTemplates", "t", - "CREATING TEMPLATES", - "Create email / blog / tweet etc. templates", - args -> { + static Task CREATE_TEMPLATES = task("createTemplates", "t", "CREATING TEMPLATES", + "Create email / blog / tweet etc. templates", args -> { args.releaser.createEmail(args.versionFromScRelease, args.projects); args.releaser.createBlog(args.versionFromScRelease, args.projects); args.releaser.createTweet(args.versionFromScRelease, args.projects); - args.releaser.createReleaseNotes(args.versionFromScRelease, args.projects); - },TaskType.POST_RELEASE); - static Task UPDATE_GUIDES = task("updateGuides", "ug", - "UPDATE GUIDES", - "Updating Spring Guides", - args -> { - args.releaser.updateSpringGuides(args.versionFromScRelease, args.projects); - },TaskType.POST_RELEASE); - static Task UPDATE_SAGAN = task("updateSagan", "g", - "UPDATE SAGAN", - "Updating Sagan with release info", - args -> { + args.releaser.createReleaseNotes(args.versionFromScRelease, + args.projects); + }, TaskType.POST_RELEASE); + static Task UPDATE_GUIDES = task("updateGuides", "ug", "UPDATE GUIDES", + "Updating Spring Guides", args -> { + args.releaser.updateSpringGuides(args.versionFromScRelease, + args.projects); + }, TaskType.POST_RELEASE); + static Task UPDATE_SAGAN = task("updateSagan", "g", "UPDATE SAGAN", + "Updating Sagan with release info", args -> { args.releaser.updateSagan(args.project, args.versionFromScRelease); - }); + }); static Task UPDATE_DOCUMENTATION = task("updateDocumentation", "ud", - "UPDATE DOCUMENTATION", - "Updating documentation repository", - args -> { - args.releaser.updateDocumentationRepository(args.properties, args.versionFromScRelease); - },TaskType.POST_RELEASE); + "UPDATE DOCUMENTATION", "Updating documentation repository", args -> { + args.releaser.updateDocumentationRepository(args.properties, + args.versionFromScRelease); + }, TaskType.POST_RELEASE); static Task UPDATE_SPRING_PROJECT_PAGE = task("updateSpringProjectPage", "up", - "UPDATE SPRING PROJECT PAGE", - "Updating Spring Project page", - args -> { + "UPDATE SPRING PROJECT PAGE", "Updating Spring Project page", args -> { args.releaser.updateSpringProjectPage(args.projects); - },TaskType.POST_RELEASE); + }, TaskType.POST_RELEASE); static Task RUN_UPDATED_SAMPLES = task("runUpdatedSample", "ru", "UPDATE AND RUN SAMPLES", - "Updates the sample project with versions and runs samples", - args -> { + "Updates the sample project with versions and runs samples", args -> { args.releaser.runUpdatedSamples(args.projects); - },TaskType.POST_RELEASE); + }, TaskType.POST_RELEASE); static Task UPDATE_RELEASE_TRAIN_DOCUMENTATION = task("updateReleaseTrainDocs", "ur", - "UPDATE RELEASE TRAIN DOCS", - "Update release train documentation", - args -> { + "UPDATE RELEASE TRAIN DOCS", "Update release train documentation", args -> { args.releaser.generateReleaseTrainDocumentation(args.projects); - },TaskType.POST_RELEASE); + }, TaskType.POST_RELEASE); static Task UPDATE_ALL_SAMPLES = task("updateAllSamples", "ua", "UPDATE ALL SAMPLES WITH RELEASE TRAIN BUMPED VERSIONS", - "Update all samples with release train bumped versions", - args -> { + "Update all samples with release train bumped versions", args -> { args.releaser.updateAllSamples(args.projects); - },TaskType.POST_RELEASE); + }, TaskType.POST_RELEASE); static Task UPDATE_RELEASE_TRAIN_WIKI = task("updateReleaseTrainWiki", "uw", - "UPDATE RELEASE TRAIN WIKI", - "Update release train wiki page", - args -> { + "UPDATE RELEASE TRAIN WIKI", "Update release train wiki page", args -> { args.releaser.updateReleaseTrainWiki(args.projects); - },TaskType.POST_RELEASE); + }, TaskType.POST_RELEASE); - static final List DEFAULT_TASKS_PER_PROJECT = Stream.of( - Tasks.UPDATING_POMS, - Tasks.BUILD_PROJECT, - Tasks.COMMIT, - Tasks.DEPLOY, - Tasks.PUBLISH_DOCS, - Tasks.SNAPSHOTS, - Tasks.PUSH, - Tasks.CLOSE_MILESTONE, - Tasks.UPDATE_SAGAN - ).collect(Collectors.toList()); + static final List DEFAULT_TASKS_PER_PROJECT = Stream + .of(Tasks.UPDATING_POMS, Tasks.BUILD_PROJECT, Tasks.COMMIT, Tasks.DEPLOY, + Tasks.PUBLISH_DOCS, Tasks.SNAPSHOTS, Tasks.PUSH, + Tasks.CLOSE_MILESTONE, Tasks.UPDATE_SAGAN) + .collect(Collectors.toList()); - static final List DEFAULT_TASKS_PER_RELEASE = Stream.of( - Tasks.RUN_UPDATED_SAMPLES, - Tasks.CREATE_TEMPLATES, - Tasks.UPDATE_GUIDES, - Tasks.UPDATE_RELEASE_TRAIN_DOCUMENTATION, - Tasks.UPDATE_DOCUMENTATION, - Tasks.UPDATE_SPRING_PROJECT_PAGE, - Tasks.UPDATE_RELEASE_TRAIN_WIKI, - Tasks.UPDATE_ALL_SAMPLES - ).collect(Collectors.toList()); + static final List DEFAULT_TASKS_PER_RELEASE = Stream + .of(Tasks.RUN_UPDATED_SAMPLES, Tasks.CREATE_TEMPLATES, Tasks.UPDATE_GUIDES, + Tasks.UPDATE_RELEASE_TRAIN_DOCUMENTATION, Tasks.UPDATE_DOCUMENTATION, + Tasks.UPDATE_SPRING_PROJECT_PAGE, Tasks.UPDATE_RELEASE_TRAIN_WIKI, + Tasks.UPDATE_ALL_SAMPLES) + .collect(Collectors.toList()); static final List NON_COMPOSITE_TASKS = new ArrayList() { { @@ -132,12 +139,10 @@ class Tasks { } }; - static Task RELEASE = Tasks.task("release", "fr", - "FULL RELEASE", + static Task RELEASE = Tasks.task("release", "fr", "FULL RELEASE", "Perform a full release of this project without interruptions", args -> new CompositeConsumer(DEFAULT_TASKS_PER_PROJECT).accept(args)); - static Task POST_RELEASE = Tasks.task("postRelease", "pr", - "POST RELEASE TASKS", + static Task POST_RELEASE = Tasks.task("postRelease", "pr", "POST RELEASE TASKS", "Perform post release tasks for this release without interruptions", args -> new CompositeConsumer(DEFAULT_TASKS_PER_RELEASE).accept(args), TaskType.POST_RELEASE); @@ -145,23 +150,19 @@ class Tasks { "FULL VERBOSE RELEASE", "Perform a full release of this project in interactive mode (you'll be asked about skipping steps)", args -> new CompositeConsumer(DEFAULT_TASKS_PER_PROJECT).accept(args)); - static Task META_RELEASE = Tasks.task("metaRelease", "x", - "META RELEASE", + static Task META_RELEASE = Tasks.task("metaRelease", "x", "META RELEASE", "Perform a meta release of projects", args -> new CompositeConsumer(DEFAULT_TASKS_PER_PROJECT, (args1 -> args.properties.getMetaRelease().setEnabled(true))) - .accept(args)); + .accept(args)); - static final List COMPOSITE_TASKS = Stream.of( - RELEASE, - RELEASE_VERBOSE, - META_RELEASE, - POST_RELEASE - ).collect(Collectors.toList()); + static final List COMPOSITE_TASKS = Stream + .of(RELEASE, RELEASE_VERBOSE, META_RELEASE, POST_RELEASE) + .collect(Collectors.toList()); - static final List ALL_TASKS_PER_PROJECT = Stream.of( - COMPOSITE_TASKS, DEFAULT_TASKS_PER_PROJECT, DEFAULT_TASKS_PER_RELEASE - ).flatMap(List::stream).collect(Collectors.toList()); + static final List ALL_TASKS_PER_PROJECT = Stream + .of(COMPOSITE_TASKS, DEFAULT_TASKS_PER_PROJECT, DEFAULT_TASKS_PER_RELEASE) + .flatMap(List::stream).collect(Collectors.toList()); static Task task(String name, String shortName, String header, String description, Consumer function) { @@ -174,28 +175,34 @@ class Tasks { } static List forNames(List tasks, List names) { - return tasks.stream() - .filter(task -> names.contains(task.name) || names.contains(task.shortName)) + return tasks.stream().filter( + task -> names.contains(task.name) || names.contains(task.shortName)) .collect(Collectors.toList()); } static String allTasksInOrder() { - return ALL_TASKS_PER_PROJECT.stream().map(task -> task.name).collect(Collectors.joining(",")); + return ALL_TASKS_PER_PROJECT.stream().map(task -> task.name) + .collect(Collectors.joining(",")); } + } enum TaskType { + RELEASE, POST_RELEASE + } class CompositeConsumer implements Consumer { private final List tasks; + private final Consumer setup; CompositeConsumer(List tasks) { this.tasks = tasks; - this.setup = args -> {}; + this.setup = args -> { + }; } CompositeConsumer(List tasks, Consumer setup) { @@ -209,4 +216,4 @@ class CompositeConsumer implements Consumer { this.tasks.forEach(task -> task.execute(args)); } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-spring/src/main/resources/application.yml b/spring-cloud-release-tools-spring/src/main/resources/application.yml index 7a276e8d..c594d756 100644 --- a/spring-cloud-release-tools-spring/src/main/resources/application.yml +++ b/spring-cloud-release-tools-spring/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: main: - web-application-type: none \ No newline at end of file + web-application-type: none diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/docs/TestDocumentationUpdater.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/docs/TestDocumentationUpdater.java index ab837c69..c65f2f03 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/docs/TestDocumentationUpdater.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/docs/TestDocumentationUpdater.java @@ -1,7 +1,22 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.docs; import java.io.File; -import java.io.IOException; import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.git.ProjectGitHandler; @@ -14,13 +29,15 @@ import org.springframework.cloud.release.internal.template.TemplateGenerator; public class TestDocumentationUpdater extends DocumentationUpdater { public TestDocumentationUpdater(ReleaserProperties properties, - TestProjectDocumentationUpdater updater, TestReleaseContentsUpdater testRelease) { + TestProjectDocumentationUpdater updater, + TestReleaseContentsUpdater testRelease) { super(properties, updater, testRelease); } public static class TestReleaseContentsUpdater extends ReleaseTrainContentsUpdater { - public TestReleaseContentsUpdater(ReleaserProperties properties, ProjectGitHandler handler, TemplateGenerator templateGenerator) { + public TestReleaseContentsUpdater(ReleaserProperties properties, + ProjectGitHandler handler, TemplateGenerator templateGenerator) { super(properties, handler, templateGenerator); } @@ -28,13 +45,16 @@ public class TestDocumentationUpdater extends DocumentationUpdater { public File updateProjectRepo(Projects projects) { return super.updateProjectRepo(projects); } + } - public static class TestProjectDocumentationUpdater extends ProjectDocumentationUpdater { + public static class TestProjectDocumentationUpdater + extends ProjectDocumentationUpdater { private final String version; - public TestProjectDocumentationUpdater(ReleaserProperties properties, ProjectGitHandler gitHandler, String version) { + public TestProjectDocumentationUpdater(ReleaserProperties properties, + ProjectGitHandler gitHandler, String version) { super(properties, gitHandler); this.version = version; } @@ -45,21 +65,17 @@ public class TestDocumentationUpdater extends DocumentationUpdater { } private String response() { - return "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "Page Redirection\n" - + "\n" + return "\n" + "\n" + "\n" + + "\n" + "\n" + "\n" + "\n" + + "Page Redirection\n" + "\n" + "\n" - + "If you are not redirected automatically, follow the link to latest release\n"; + + "If you are not redirected automatically, follow the link to latest release\n"; } + } + } - - diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/git/GitTestUtils.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/git/GitTestUtils.java index 6ff8351a..06fbd1b7 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/git/GitTestUtils.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/git/GitTestUtils.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.git; import java.io.File; @@ -17,7 +33,7 @@ public class GitTestUtils { public static void setOriginOnProjectToTmp(File origin, File project) throws GitAPIException, MalformedURLException { - try(Git git = openGitProject(project)) { + try (Git git = openGitProject(project)) { RemoteRemoveCommand remove = git.remoteRemove(); remove.setName("origin"); remove.call(); @@ -33,8 +49,10 @@ public class GitTestUtils { return new GitRepo.JGitFactory().open(project); } - public static File clonedProject(File baseDir, File projectToClone) throws IOException { + public static File clonedProject(File baseDir, File projectToClone) + throws IOException { GitRepo projectRepo = new GitRepo(baseDir); return projectRepo.cloneProject(new URIish(projectToClone.toURI().toURL())); } + } diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/pom/TestPomReader.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/pom/TestPomReader.java index 0918ac99..cac08b41 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/pom/TestPomReader.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/pom/TestPomReader.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -14,4 +30,5 @@ public class TestPomReader { public Model readPom(File pom) { return this.pomReader.readPom(pom); } + } diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/pom/TestUtils.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/pom/TestUtils.java index 36bd3600..95b88ee6 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/pom/TestUtils.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/pom/TestUtils.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.pom; import java.io.File; @@ -11,13 +27,15 @@ public class TestUtils { prepareLocalRepo("target/test-classes/projects/", "spring-cloud"); prepareLocalRepo("target/test-classes/projects/", "spring-cloud-wiki"); prepareLocalRepo("target/test-classes/projects/", "spring-cloud-release"); - prepareLocalRepo("target/test-classes/projects/", "spring-cloud-release-with-snapshot"); + prepareLocalRepo("target/test-classes/projects/", + "spring-cloud-release-with-snapshot"); prepareLocalRepo("target/test-classes/projects/", "spring-cloud-consul"); prepareLocalRepo("target/test-classes/projects/", "spring-cloud-build"); prepareLocalRepo("target/test-classes/projects/", "spring-cloud-static-angel"); } - private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException { + private static void prepareLocalRepo(String buildDir, String repoPath) + throws IOException { File dotGit = new File(buildDir + repoPath + "/.git"); File git = new File(buildDir + repoPath + "/git"); if (git.exists()) { @@ -28,4 +46,4 @@ public class TestUtils { git.renameTo(dotGit); } -} \ No newline at end of file +} diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java index 471eb071..93739ed9 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.io.File; @@ -60,29 +76,51 @@ import static org.mockito.ArgumentMatchers.anyString; */ public class AcceptanceTests { - @Rule public TemporaryFolder tmp = new TemporaryFolder(); - @Rule public OutputCapture capture = new OutputCapture(); + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + @Rule + public OutputCapture capture = new OutputCapture(); + TestPomReader testPomReader = new TestPomReader(); + File springCloudConsulProject; + File temporaryFolder; + File documentationFolder; + File cloudProjectFolder; + TestProjectGitHandler gitHandler; + NonAssertingTestProjectGitHandler nonAssertingGitHandler; + SaganClient saganClient = Mockito.mock(SaganClient.class); + ReleaserProperties releaserProperties; + TemplateGenerator templateGenerator; + SaganUpdater saganUpdater; + DocumentationUpdater documentationUpdater; + ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class); - ReleaserPropertiesUpdater updater = new ReleaserPropertiesUpdater(this.applicationContext); + + ReleaserPropertiesUpdater updater = new ReleaserPropertiesUpdater( + this.applicationContext); + PostReleaseActions postReleaseActions = Mockito.mock(PostReleaseActions.class); - ApplicationEventPublisher applicationEventPublisher = Mockito.mock(ApplicationEventPublisher.class); + + ApplicationEventPublisher applicationEventPublisher = Mockito + .mock(ApplicationEventPublisher.class); @Before public void setup() throws Exception { this.temporaryFolder = this.tmp.newFolder(); - this.springCloudConsulProject = new File(AcceptanceTests.class.getResource("/projects/spring-cloud-consul").toURI()); + this.springCloudConsulProject = new File(AcceptanceTests.class + .getResource("/projects/spring-cloud-consul").toURI()); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder); BDDMockito.given(this.saganClient.getProject(anyString())) @@ -97,12 +135,8 @@ public class AcceptanceTests { private Project newProject() { Project project = new Project(); - project.projectReleases.addAll(Arrays.asList( - release("1.0.0.M8"), - release("1.1.0.M8"), - release("1.2.0.M8"), - release("2.0.0.M8")) - ); + project.projectReleases.addAll(Arrays.asList(release("1.0.0.M8"), + release("1.1.0.M8"), release("1.2.0.M8"), release("2.0.0.M8"))); return project; } @@ -114,33 +148,42 @@ public class AcceptanceTests { } @Test - public void should_fail_to_perform_a_release_of_consul_when_sc_release_contains_snapshots() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudConsulProject); + public void should_fail_to_perform_a_release_of_consul_when_sc_release_contains_snapshots() + throws Exception { + File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), + this.springCloudConsulProject); pomVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); consulPomParentVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); - File project = GitTestUtils.clonedProject(this.tmp.newFolder(), tmpFile("spring-cloud-consul")); + File project = GitTestUtils.clonedProject(this.tmp.newFolder(), + tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - SpringReleaser releaser = releaserWithSnapshotScRelease(project, "spring-cloud-consul", - "vCamden.SR5.BROKEN", "1.1.2.RELEASE"); + SpringReleaser releaser = releaserWithSnapshotScRelease(project, + "spring-cloud-consul", "vCamden.SR5.BROKEN", "1.1.2.RELEASE"); - BDDAssertions.thenThrownBy(releaser::release) - .hasMessageContaining("there is at least one SNAPSHOT library version in the Spring Cloud Release project"); + BDDAssertions.thenThrownBy(releaser::release).hasMessageContaining( + "there is at least one SNAPSHOT library version in the Spring Cloud Release project"); } @Test - public void should_not_clone_when_option_not_to_clone_was_switched_on() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudConsulProject); + public void should_not_clone_when_option_not_to_clone_was_switched_on() + throws Exception { + File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), + this.springCloudConsulProject); pomVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); consulPomParentVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); - File project = GitTestUtils.clonedProject(this.tmp.newFolder(), tmpFile("spring-cloud-consul")); + File project = GitTestUtils.clonedProject(this.tmp.newFolder(), + tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); SpringReleaser releaser = templateOnlyReleaser(project, "spring-cloud-consul", "vCamden.SR5", "1.1.2.RELEASE"); this.releaserProperties.getGit().setFetchVersionsFromGit(false); - this.releaserProperties.getFixedVersions().put("spring-cloud-release", "Finchley.RELEASE"); - this.releaserProperties.getFixedVersions().put("spring-cloud-consul", "2.3.4.RELEASE"); + this.releaserProperties.getFixedVersions().put("spring-cloud-release", + "Finchley.RELEASE"); + this.releaserProperties.getFixedVersions().put("spring-cloud-consul", + "2.3.4.RELEASE"); File temporaryDestination = this.tmp.newFolder(); - this.releaserProperties.getGit().setCloneDestinationDir(temporaryDestination.getAbsolutePath()); + this.releaserProperties.getGit() + .setCloneDestinationDir(temporaryDestination.getAbsolutePath()); releaser.release(); @@ -149,40 +192,43 @@ public class AcceptanceTests { @Test public void should_perform_a_release_of_consul() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudConsulProject); + File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), + this.springCloudConsulProject); pomVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); consulPomParentVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); - File project = GitTestUtils.clonedProject(this.tmp.newFolder(), tmpFile("spring-cloud-consul")); + File project = GitTestUtils.clonedProject(this.tmp.newFolder(), + tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - SpringReleaser releaser = releaser(project, "spring-cloud-consul","vCamden.SR5", "1.1.2.RELEASE"); + SpringReleaser releaser = releaser(project, "spring-cloud-consul", "vCamden.SR5", + "1.1.2.RELEASE"); releaser.release(); Iterable commits = listOfCommits(project); Iterator iterator = commits.iterator(); tagIsPresentInOrigin(origin, "v1.1.2.RELEASE"); - commitIsPresent(iterator, "Bumping versions to 1.2.1.BUILD-SNAPSHOT after release"); + commitIsPresent(iterator, + "Bumping versions to 1.2.1.BUILD-SNAPSHOT after release"); commitIsPresent(iterator, "Going back to snapshots"); commitIsPresent(iterator, "Update SNAPSHOT to 1.1.2.RELEASE"); pomVersionIsEqualTo(project, "1.2.1.BUILD-SNAPSHOT"); consulPomParentVersionIsEqualTo(project, "1.2.1.BUILD-SNAPSHOT"); then(this.gitHandler.closedMilestones).isTrue(); then(emailTemplate()).exists(); - then(emailTemplateContents()) - .contains("Spring Cloud Camden.SR5 available") + then(emailTemplateContents()).contains("Spring Cloud Camden.SR5 available") .contains("Spring Cloud Camden SR5 Train release"); then(blogTemplate()).exists(); then(blogTemplateContents()) .contains("I am pleased to announce that the Service Release 5 (SR5)"); then(releaseNotesTemplate()).exists(); - then(releaseNotesTemplateContents()) - .contains("Camden.SR5") - .contains("- Spring Cloud Config `1.2.2.RELEASE` ([issues](http://foo.bar.com/1.2.2.RELEASE))") - .contains("- Spring Cloud Aws `1.1.3.RELEASE` ([issues](http://foo.bar.com/1.1.3.RELEASE))"); + then(releaseNotesTemplateContents()).contains("Camden.SR5").contains( + "- Spring Cloud Config `1.2.2.RELEASE` ([issues](http://foo.bar.com/1.2.2.RELEASE))") + .contains( + "- Spring Cloud Aws `1.1.3.RELEASE` ([issues](http://foo.bar.com/1.1.3.RELEASE))"); // once for updating GA // second time to update SNAPSHOT - BDDMockito.then(this.saganClient).should(BDDMockito.times(2)).updateRelease(BDDMockito.eq("spring-cloud-consul"), - BDDMockito.anyList()); + BDDMockito.then(this.saganClient).should(BDDMockito.times(2)).updateRelease( + BDDMockito.eq("spring-cloud-consul"), BDDMockito.anyList()); BDDMockito.then(this.saganClient).should().deleteRelease("spring-cloud-consul", "1.1.2.BUILD-SNAPSHOT"); BDDMockito.then(this.saganClient).should().deleteRelease("spring-cloud-consul", @@ -193,13 +239,13 @@ public class AcceptanceTests { .deleteRelease("spring-cloud-build", "2.0.0.M8"); then(this.gitHandler.issueCreatedInSpringGuides).isTrue(); then(text(new File(this.documentationFolder, "current/index.html"))) - .doesNotContain("Angel.SR3") - .contains("Camden.SR5"); + .doesNotContain("Angel.SR3").contains("Camden.SR5"); thenRunUpdatedTestsWereCalled(); } @Test - public void should_perform_a_meta_release_of_sc_release_and_consul() throws Exception { + public void should_perform_a_meta_release_of_sc_release_and_consul() + throws Exception { // simulates an org SpringReleaser releaser = metaReleaser(edgwareSr10()); @@ -213,7 +259,9 @@ public class AcceptanceTests { thenDocumentationWasUpdated(); BDDAssertions.then(clonedProject("spring-cloud-consul").tagList().call()) .extracting("name").contains("refs/tags/v1.3.5.RELEASE"); - BDDAssertions.then(gitProject(this.cloudProjectFolder).log().call().iterator().next().getShortMessage()) + BDDAssertions + .then(gitProject(this.cloudProjectFolder).log().call().iterator().next() + .getShortMessage()) .contains("Updating project page to release train [Edgware.SR10]"); thenRunUpdatedTestsWereCalled(); thenUpdateReleaseTrainDocsWasCalled(); @@ -254,45 +302,48 @@ public class AcceptanceTests { } private Git clonedProject(String name) { - return GitTestUtils - .openGitProject(this.nonAssertingGitHandler.clonedProjects.stream() - .filter(file -> file.getName().equals(name)) - .findFirst().get()); + return GitTestUtils.openGitProject(this.nonAssertingGitHandler.clonedProjects + .stream().filter(file -> file.getName().equals(name)).findFirst().get()); } private Git gitProject(File file) { - return GitTestUtils - .openGitProject(file); + return GitTestUtils.openGitProject(file); } private void thenSaganWasCalled() { - BDDMockito.then(this.saganUpdater).should(BDDMockito.atLeastOnce()) - .updateSagan(BDDMockito.anyString(), - BDDMockito.any(ProjectVersion.class), BDDMockito - .any(ProjectVersion.class)); + BDDMockito.then(this.saganUpdater).should(BDDMockito.atLeastOnce()).updateSagan( + BDDMockito.anyString(), BDDMockito.any(ProjectVersion.class), + BDDMockito.any(ProjectVersion.class)); } private void thenAllStepsWereExecutedForEachProject() { - this.nonAssertingGitHandler.clonedProjects - .stream().filter(f -> !f.getName().contains("angel") && !f.getName().equals("spring-cloud")) + this.nonAssertingGitHandler.clonedProjects.stream() + .filter(f -> !f.getName().contains("angel") + && !f.getName().equals("spring-cloud")) .forEach(project -> { then(Arrays.asList("spring-cloud-starter-build", - "spring-cloud-consul")).contains(pom(project).getArtifactId()); - then(this.capture.toString()).contains("executed_build", "executed_deploy", "executed_docs"); + "spring-cloud-consul")) + .contains(pom(project).getArtifactId()); + then(this.capture.toString()).contains("executed_build", + "executed_deploy", "executed_docs"); }); } @Test - public void should_not_clone_any_projects_when_they_are_on_list_of_projects_to_skip() throws Exception { + public void should_not_clone_any_projects_when_they_are_on_list_of_projects_to_skip() + throws Exception { Map versions = new HashMap<>(); versions.put("spring-cloud-release", "Camden.BUILD-SNAPSHOT"); versions.put("spring-cloud-consul", "1.1.2.BUILD-SNAPSHOT"); SpringReleaser releaser = metaReleaser(versions); - this.releaserProperties.getMetaRelease().getProjectsToSkip().add("spring-cloud-release"); - this.releaserProperties.getMetaRelease().getProjectsToSkip().add("spring-cloud-consul"); + this.releaserProperties.getMetaRelease().getProjectsToSkip() + .add("spring-cloud-release"); + this.releaserProperties.getMetaRelease().getProjectsToSkip() + .add("spring-cloud-consul"); this.releaserProperties.getGit().setUpdateReleaseTrainWiki(false); File temporaryDestination = this.tmp.newFolder(); - this.releaserProperties.getGit().setCloneDestinationDir(temporaryDestination.getAbsolutePath()); + this.releaserProperties.getGit() + .setCloneDestinationDir(temporaryDestination.getAbsolutePath()); releaser.release(new OptionsBuilder().metaRelease(true).options()); @@ -300,7 +351,8 @@ public class AcceptanceTests { } @Test - public void should_perform_a_meta_release_of_consul_only_when_run_from_got_passed() throws Exception { + public void should_perform_a_meta_release_of_consul_only_when_run_from_got_passed() + throws Exception { // simulates an org Map versions = new HashMap<>(); versions.put("spring-cloud-release", "Camden.BUILD-SNAPSHOT"); @@ -309,16 +361,16 @@ public class AcceptanceTests { SpringReleaser releaser = metaReleaser(versions); releaser.release(new OptionsBuilder().metaRelease(true) - .startFrom("spring-cloud-consul") - .options()); + .startFrom("spring-cloud-consul").options()); // consul, cloud then(this.nonAssertingGitHandler.clonedProjects).hasSize(2); - this.nonAssertingGitHandler.clonedProjects - .stream().filter(file -> file.getName().equals("spring-cloud-consul")) + this.nonAssertingGitHandler.clonedProjects.stream() + .filter(file -> file.getName().equals("spring-cloud-consul")) .forEach(project -> { then(pom(project).getArtifactId()).isEqualTo("spring-cloud-consul"); - then(this.capture.toString()).contains("executed_build", "executed_deploy", "executed_docs"); + then(this.capture.toString()).contains("executed_build", + "executed_deploy", "executed_docs"); }); thenSaganWasCalled(); thenDocumentationWasUpdated(); @@ -326,7 +378,8 @@ public class AcceptanceTests { } @Test - public void should_perform_a_meta_release_of_consul_only_when_task_names_got_passed() throws Exception { + public void should_perform_a_meta_release_of_consul_only_when_task_names_got_passed() + throws Exception { // simulates an org Map versions = new HashMap<>(); versions.put("spring-cloud-release", "Camden.BUILD-SNAPSHOT"); @@ -335,18 +388,17 @@ public class AcceptanceTests { SpringReleaser releaser = metaReleaser(versions); releaser.release(new OptionsBuilder().metaRelease(true) - .taskNames(Collections.singletonList("spring-cloud-consul")) - .options()); + .taskNames(Collections.singletonList("spring-cloud-consul")).options()); // consul, cloud then(this.nonAssertingGitHandler.clonedProjects).hasSize(2); - this.nonAssertingGitHandler.clonedProjects - .stream().filter(file -> !file.getName().equals("spring-cloud")) + this.nonAssertingGitHandler.clonedProjects.stream() + .filter(file -> !file.getName().equals("spring-cloud")) .forEach(project -> { then(Collections.singletonList("spring-cloud-consul")) .contains(pom(project).getArtifactId()); - then(this.capture.toString()).contains("executed_build", "executed_deploy", - "executed_docs"); + then(this.capture.toString()).contains("executed_build", + "executed_deploy", "executed_docs"); }); thenSaganWasCalled(); thenDocumentationWasUpdated(); @@ -354,9 +406,8 @@ public class AcceptanceTests { } private void thenDocumentationWasUpdated() { - BDDMockito.then(this.documentationUpdater).should() - .updateDocsRepo(BDDMockito.any(ProjectVersion.class), BDDMockito - .anyString()); + BDDMockito.then(this.documentationUpdater).should().updateDocsRepo( + BDDMockito.any(ProjectVersion.class), BDDMockito.anyString()); } private void thenWikiPageWasUpdated() { @@ -368,13 +419,16 @@ public class AcceptanceTests { @Test public void should_perform_a_release_of_sc_build() throws Exception { File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), - new File(AcceptanceTests.class.getResource("/projects/spring-cloud-build").toURI())); + new File(AcceptanceTests.class.getResource("/projects/spring-cloud-build") + .toURI())); pomVersionIsEqualTo(origin, "1.3.7.BUILD-SNAPSHOT"); - pomParentVersionIsEqualTo(origin, "spring-cloud-build-dependencies", "1.5.9.RELEASE"); - File project = GitTestUtils.clonedProject(this.tmp.newFolder(), tmpFile("spring-cloud-build")); + pomParentVersionIsEqualTo(origin, "spring-cloud-build-dependencies", + "1.5.9.RELEASE"); + File project = GitTestUtils.clonedProject(this.tmp.newFolder(), + tmpFile("spring-cloud-build")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - SpringReleaser releaser = releaser(project, "spring-cloud-build", - "vCamden.SR5", "1.2.2.RELEASE"); + SpringReleaser releaser = releaser(project, "spring-cloud-build", "vCamden.SR5", + "1.2.2.RELEASE"); releaser.release(); @@ -382,47 +436,52 @@ public class AcceptanceTests { Iterator iterator = commits.iterator(); tagIsPresentInOrigin(origin, "v1.2.2.RELEASE"); // we're running against camden sc-release - commitIsPresent(iterator, "Bumping versions to 1.3.8.BUILD-SNAPSHOT after release"); + commitIsPresent(iterator, + "Bumping versions to 1.3.8.BUILD-SNAPSHOT after release"); commitIsPresent(iterator, "Going back to snapshots"); commitIsPresent(iterator, "Update SNAPSHOT to 1.2.2.RELEASE"); pomVersionIsEqualTo(project, "1.3.8.BUILD-SNAPSHOT"); - pomParentVersionIsEqualTo(project, "spring-cloud-build-dependencies", "1.4.4.RELEASE"); + pomParentVersionIsEqualTo(project, "spring-cloud-build-dependencies", + "1.4.4.RELEASE"); then(this.gitHandler.closedMilestones).isTrue(); then(emailTemplate()).exists(); then(blogTemplate()).exists(); then(releaseNotesTemplate()).exists(); // once for updating GA // second time to update SNAPSHOT - BDDMockito.then(this.saganClient).should(BDDMockito.times(2)).updateRelease(BDDMockito.eq("spring-cloud-build"), - BDDMockito.anyList()); - BDDMockito.then(this.saganClient).should() - .deleteRelease("spring-cloud-build", "1.2.2.BUILD-SNAPSHOT"); - BDDMockito.then(this.saganClient).should() - .deleteRelease("spring-cloud-build", "1.2.0.M8"); + BDDMockito.then(this.saganClient).should(BDDMockito.times(2)) + .updateRelease(BDDMockito.eq("spring-cloud-build"), BDDMockito.anyList()); + BDDMockito.then(this.saganClient).should().deleteRelease("spring-cloud-build", + "1.2.2.BUILD-SNAPSHOT"); + BDDMockito.then(this.saganClient).should().deleteRelease("spring-cloud-build", + "1.2.0.M8"); BDDMockito.then(this.saganClient).should(BDDMockito.never()) .deleteRelease("spring-cloud-build", "1.1.0.M8"); BDDMockito.then(this.saganClient).should(BDDMockito.never()) .deleteRelease("spring-cloud-build", "2.0.0.M8"); then(this.gitHandler.issueCreatedInSpringGuides).isTrue(); then(text(new File(this.documentationFolder, "current/index.html"))) - .doesNotContain("Angel.SR3") - .contains("Camden.SR5"); + .doesNotContain("Angel.SR3").contains("Camden.SR5"); } @Test public void should_perform_a_release_of_consul_rc1() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudConsulProject); + File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), + this.springCloudConsulProject); pomVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); consulPomParentVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); - File project = GitTestUtils.clonedProject(this.tmp.newFolder(), tmpFile("spring-cloud-consul")); + File project = GitTestUtils.clonedProject(this.tmp.newFolder(), + tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - SpringReleaser releaser = releaser(project, "spring-cloud-consul", "Dalston.RC1", "1.2.0.RC1"); + SpringReleaser releaser = releaser(project, "spring-cloud-consul", "Dalston.RC1", + "1.2.0.RC1"); releaser.release(); Iterable commits = listOfCommits(project); tagIsPresentInOrigin(origin, "v1.2.0.RC1"); - commitIsNotPresent(commits, "Bumping versions to 1.2.1.BUILD-SNAPSHOT after release"); + commitIsNotPresent(commits, + "Bumping versions to 1.2.1.BUILD-SNAPSHOT after release"); Iterator iterator = listOfCommits(project).iterator(); commitIsPresent(iterator, "Going back to snapshots"); commitIsPresent(iterator, "Update SNAPSHOT to 1.2.0.RC1"); @@ -430,8 +489,7 @@ public class AcceptanceTests { consulPomParentVersionIsEqualTo(project, "1.2.0.BUILD-SNAPSHOT"); then(this.gitHandler.closedMilestones).isTrue(); then(emailTemplate()).exists(); - then(emailTemplateContents()) - .contains("Spring Cloud Dalston.RC1 available") + then(emailTemplateContents()).contains("Spring Cloud Dalston.RC1 available") .contains("Spring Cloud Dalston RC1 Train release"); then(blogTemplate()).exists(); then(blogTemplateContents()) @@ -440,38 +498,39 @@ public class AcceptanceTests { then(tweetTemplateContents()) .contains("The Dalston.RC1 version of @springcloud has been released!"); then(releaseNotesTemplate()).exists(); - then(releaseNotesTemplateContents()) - .contains("Dalston.RC1") - .contains("- Spring Cloud Build `1.3.1.RELEASE` ([issues](http://foo.bar.com/1.3.1.RELEASE))") - .contains("- Spring Cloud Bus `1.3.0.M1` ([issues](http://foo.bar.com/1.3.0.M1))"); - BDDMockito.then(this.saganClient).should().updateRelease(BDDMockito.eq("spring-cloud-consul"), - BDDMockito.anyList()); - BDDMockito.then(this.saganClient).should() - .deleteRelease("spring-cloud-consul","1.2.0.M8"); - BDDMockito.then(this.saganClient).should() - .deleteRelease("spring-cloud-consul","1.2.0.RC1"); + then(releaseNotesTemplateContents()).contains("Dalston.RC1").contains( + "- Spring Cloud Build `1.3.1.RELEASE` ([issues](http://foo.bar.com/1.3.1.RELEASE))") + .contains( + "- Spring Cloud Bus `1.3.0.M1` ([issues](http://foo.bar.com/1.3.0.M1))"); + BDDMockito.then(this.saganClient).should().updateRelease( + BDDMockito.eq("spring-cloud-consul"), BDDMockito.anyList()); + BDDMockito.then(this.saganClient).should().deleteRelease("spring-cloud-consul", + "1.2.0.M8"); + BDDMockito.then(this.saganClient).should().deleteRelease("spring-cloud-consul", + "1.2.0.RC1"); // we update guides only for SR / RELEASE then(this.gitHandler.issueCreatedInSpringGuides).isFalse(); // haven't even checked out the branch - then(new File(this.documentationFolder, "current/index.html")) - .doesNotExist(); + then(new File(this.documentationFolder, "current/index.html")).doesNotExist(); } @Test public void should_generate_templates_only() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudConsulProject); + File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), + this.springCloudConsulProject); pomVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); consulPomParentVersionIsEqualTo(origin, "1.2.0.BUILD-SNAPSHOT"); - File project = GitTestUtils.clonedProject(this.tmp.newFolder(), tmpFile("spring-cloud-consul")); + File project = GitTestUtils.clonedProject(this.tmp.newFolder(), + tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - SpringReleaser releaser = templateOnlyReleaser(project, "spring-cloud-consul","Dalston.RC1", "1.2.0.RC1"); + SpringReleaser releaser = templateOnlyReleaser(project, "spring-cloud-consul", + "Dalston.RC1", "1.2.0.RC1"); releaser.release(); then(this.gitHandler.closedMilestones).isFalse(); then(emailTemplate()).exists(); - then(emailTemplateContents()) - .contains("Spring Cloud Dalston.RC1 available") + then(emailTemplateContents()).contains("Spring Cloud Dalston.RC1 available") .contains("Spring Cloud Dalston RC1 Train release"); then(blogTemplate()).exists(); then(blogTemplateContents()) @@ -480,12 +539,12 @@ public class AcceptanceTests { then(tweetTemplateContents()) .contains("The Dalston.RC1 version of @springcloud has been released!"); then(releaseNotesTemplate()).exists(); - then(releaseNotesTemplateContents()) - .contains("Dalston.RC1") - .contains("- Spring Cloud Build `1.3.1.RELEASE` ([issues](http://foo.bar.com/1.3.1.RELEASE))") - .contains("- Spring Cloud Bus `1.3.0.M1` ([issues](http://foo.bar.com/1.3.0.M1)"); - BDDMockito.then(this.saganClient).should(BDDMockito.never()).updateRelease( - BDDMockito.anyString(), BDDMockito.anyList()); + then(releaseNotesTemplateContents()).contains("Dalston.RC1").contains( + "- Spring Cloud Build `1.3.1.RELEASE` ([issues](http://foo.bar.com/1.3.1.RELEASE))") + .contains( + "- Spring Cloud Bus `1.3.0.M1` ([issues](http://foo.bar.com/1.3.0.M1)"); + BDDMockito.then(this.saganClient).should(BDDMockito.never()) + .updateRelease(BDDMockito.anyString(), BDDMockito.anyList()); then(this.gitHandler.issueCreatedInSpringGuides).isFalse(); } @@ -494,8 +553,7 @@ public class AcceptanceTests { } private void pomParentVersionIsEqualTo(File project, String child, String expected) { - then(pom(new File(project, child)).getParent() - .getVersion()).isEqualTo(expected); + then(pom(new File(project, child)).getParent().getVersion()).isEqualTo(expected); } private void consulPomParentVersionIsEqualTo(File project, String expected) { @@ -506,22 +564,21 @@ public class AcceptanceTests { then(pom(project).getVersion()).isEqualTo(expected); } - private void commitIsPresent(Iterator iterator, - String expected) { + private void commitIsPresent(Iterator iterator, String expected) { RevCommit commit = iterator.next(); then(commit.getShortMessage()).isEqualTo(expected); } - private void commitIsNotPresent(Iterable commits, - String expected) { + private void commitIsNotPresent(Iterable commits, String expected) { for (RevCommit commit : commits) { then(commit.getShortMessage()).isNotEqualTo(expected); } } - private void tagIsPresentInOrigin(File origin, String expectedTag) throws GitAPIException { - then(GitTestUtils.openGitProject(origin).tagList() - .call().iterator().next().getName()).endsWith(expectedTag); + private void tagIsPresentInOrigin(File origin, String expectedTag) + throws GitAPIException { + then(GitTestUtils.openGitProject(origin).tagList().call().iterator().next() + .getName()).endsWith(expectedTag); } private Model pom(File dir) { @@ -560,8 +617,8 @@ public class AcceptanceTests { return new String(Files.readAllBytes(releaseNotesTemplate().toPath())); } - private SpringReleaser releaser(File projectFile, String projectName, - String branch, String expectedVersion) throws Exception { + private SpringReleaser releaser(File projectFile, String projectName, String branch, + String expectedVersion) throws Exception { ReleaserProperties properties = releaserProperties(projectFile, branch); return releaserWithFullDeployment(expectedVersion, projectName, properties); } @@ -574,47 +631,59 @@ public class AcceptanceTests { private SpringReleaser releaserWithFullDeployment(String expectedVersion, String projectName, ReleaserProperties properties) throws Exception { Releaser releaser = defaultReleaser(expectedVersion, projectName, properties); - return new SpringReleaser(releaser, properties, new OptionsProcessor(releaser, properties, this.applicationEventPublisher) { - @Override String chosenOption() { + return new SpringReleaser(releaser, properties, new OptionsProcessor(releaser, + properties, this.applicationEventPublisher) { + @Override + String chosenOption() { return "0"; } - @Override void postReleaseOptions(Options options, Args defaultArgs) { + @Override + void postReleaseOptions(Options options, Args defaultArgs) { options.interactive = false; super.postReleaseOptions(options, defaultArgs); } }, this.updater, this.applicationEventPublisher); } - private SpringReleaser metaReleaserWithFullDeployment(ReleaserProperties properties) throws Exception { + private SpringReleaser metaReleaserWithFullDeployment(ReleaserProperties properties) + throws Exception { Releaser releaser = defaultMetaReleaser(properties); - return new SpringReleaser(releaser, properties, new OptionsProcessor(releaser, properties, this.applicationEventPublisher) { - @Override String chosenOption() { + return new SpringReleaser(releaser, properties, new OptionsProcessor(releaser, + properties, this.applicationEventPublisher) { + @Override + String chosenOption() { return "0"; } - @Override void postReleaseOptions(Options options, Args defaultArgs) { + @Override + void postReleaseOptions(Options options, Args defaultArgs) { options.interactive = false; super.postReleaseOptions(options, defaultArgs); } }, this.updater, this.applicationEventPublisher); } - private SpringReleaser releaserWithSnapshotScRelease(File projectFile, String projectName, - String branch, String expectedVersion) throws Exception { - ReleaserProperties properties = snapshotScReleaseReleaserProperties(projectFile, branch); + private SpringReleaser releaserWithSnapshotScRelease(File projectFile, + String projectName, String branch, String expectedVersion) throws Exception { + ReleaserProperties properties = snapshotScReleaseReleaserProperties(projectFile, + branch); return releaserWithFullDeployment(expectedVersion, projectName, properties); } - private SpringReleaser templateOnlyReleaser(File projectFile, String projectName, String branch, String expectedVersion) throws Exception { + private SpringReleaser templateOnlyReleaser(File projectFile, String projectName, + String branch, String expectedVersion) throws Exception { ReleaserProperties properties = releaserProperties(projectFile, branch); Releaser releaser = defaultReleaser(expectedVersion, projectName, properties); - return new SpringReleaser(releaser, properties, new OptionsProcessor(releaser, properties, this.applicationEventPublisher) { - @Override String chosenOption() { + return new SpringReleaser(releaser, properties, new OptionsProcessor(releaser, + properties, this.applicationEventPublisher) { + @Override + String chosenOption() { return "13"; } - @Override void postReleaseOptions(Options options, Args defaultArgs) { + @Override + void postReleaseOptions(Options options, Args defaultArgs) { options.interactive = true; super.postReleaseOptions(options, defaultArgs); } @@ -629,19 +698,25 @@ public class AcceptanceTests { expectedVersion, projectName); TemplateGenerator templateGenerator = new TemplateGenerator(properties, handler); GradleUpdater gradleUpdater = new GradleUpdater(properties); - SaganUpdater saganUpdater = new SaganUpdater(this.saganClient, this.releaserProperties); - DocumentationUpdater documentationUpdater = new TestDocumentationUpdater(properties, - new TestDocumentationUpdater.TestProjectDocumentationUpdater(properties, handler, "Brixton.SR1"), - new TestDocumentationUpdater.TestReleaseContentsUpdater(properties, handler, templateGenerator)) { - @Override public File updateDocsRepo(ProjectVersion currentProject, - String springCloudReleaseBranch) { - File file = super.updateDocsRepo(currentProject, springCloudReleaseBranch); + SaganUpdater saganUpdater = new SaganUpdater(this.saganClient, + this.releaserProperties); + DocumentationUpdater documentationUpdater = new TestDocumentationUpdater( + properties, + new TestDocumentationUpdater.TestProjectDocumentationUpdater(properties, + handler, "Brixton.SR1"), + new TestDocumentationUpdater.TestReleaseContentsUpdater(properties, + handler, templateGenerator)) { + @Override + public File updateDocsRepo(ProjectVersion currentProject, + String bomReleaseBranch) { + File file = super.updateDocsRepo(currentProject, bomReleaseBranch); AcceptanceTests.this.documentationFolder = file; return file; } }; Releaser releaser = new Releaser(pomUpdater, projectBuilder, handler, - templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, this.postReleaseActions); + templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, + this.postReleaseActions); this.gitHandler = handler; return releaser; } @@ -649,29 +724,38 @@ public class AcceptanceTests { private Releaser defaultMetaReleaser(ReleaserProperties properties) { ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties); ProjectBuilder projectBuilder = new ProjectBuilder(properties); - NonAssertingTestProjectGitHandler handler = new NonAssertingTestProjectGitHandler(properties); - TemplateGenerator templateGenerator = Mockito.spy(new TemplateGenerator(properties, handler)); + NonAssertingTestProjectGitHandler handler = new NonAssertingTestProjectGitHandler( + properties); + TemplateGenerator templateGenerator = Mockito + .spy(new TemplateGenerator(properties, handler)); GradleUpdater gradleUpdater = new GradleUpdater(properties); - SaganUpdater saganUpdater = Mockito.spy(new SaganUpdater(this.saganClient, this.releaserProperties)); - DocumentationUpdater documentationUpdater = Mockito.spy(new TestDocumentationUpdater(properties, - new TestDocumentationUpdater.TestProjectDocumentationUpdater(properties, handler, "Brixton.SR1"), - new TestDocumentationUpdater.TestReleaseContentsUpdater(properties, handler, templateGenerator) { + SaganUpdater saganUpdater = Mockito + .spy(new SaganUpdater(this.saganClient, this.releaserProperties)); + DocumentationUpdater documentationUpdater = Mockito + .spy(new TestDocumentationUpdater(properties, + new TestDocumentationUpdater.TestProjectDocumentationUpdater( + properties, handler, "Brixton.SR1"), + new TestDocumentationUpdater.TestReleaseContentsUpdater( + properties, handler, templateGenerator) { + @Override + public File updateProjectRepo(Projects projects) { + File file = super.updateProjectRepo(projects); + AcceptanceTests.this.cloudProjectFolder = file; + return file; + } + }) { @Override - public File updateProjectRepo(Projects projects) { - File file = super.updateProjectRepo(projects); - AcceptanceTests.this.cloudProjectFolder = file; + public File updateDocsRepo(ProjectVersion currentProject, + String bomReleaseBranch) { + File file = super.updateDocsRepo(currentProject, + bomReleaseBranch); + AcceptanceTests.this.documentationFolder = file; return file; } - }) { - @Override public File updateDocsRepo(ProjectVersion currentProject, - String springCloudReleaseBranch) { - File file = super.updateDocsRepo(currentProject, springCloudReleaseBranch); - AcceptanceTests.this.documentationFolder = file; - return file; - } - }); + }); Releaser releaser = Mockito.spy(new Releaser(pomUpdater, projectBuilder, handler, - templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, this.postReleaseActions)); + templateGenerator, gradleUpdater, saganUpdater, documentationUpdater, + this.postReleaseActions)); this.nonAssertingGitHandler = handler; this.templateGenerator = templateGenerator; this.saganUpdater = saganUpdater; @@ -679,7 +763,8 @@ public class AcceptanceTests { return releaser; } - private ReleaserProperties releaserProperties(File project, String branch) throws URISyntaxException { + private ReleaserProperties releaserProperties(File project, String branch) + throws URISyntaxException { ReleaserProperties releaserProperties = new ReleaserProperties(); releaserProperties.getGit().setReleaseTrainBomUrl( file("/projects/spring-cloud-release/").toURI().toString()); @@ -687,34 +772,40 @@ public class AcceptanceTests { file("/projects/spring-cloud-static-angel/").toURI().toString()); releaserProperties.getMaven().setBuildCommand("echo build"); releaserProperties.getMaven().setDeployCommand("echo deploy"); - releaserProperties.getMaven().setPublishDocsCommands(new String[] { "echo docs"} ); + releaserProperties.getMaven() + .setPublishDocsCommands(new String[] { "echo docs" }); releaserProperties.setWorkingDir(project.getPath()); releaserProperties.getPom().setBranch(branch); - releaserProperties.getGit().setSpringProjectUrl( - tmpFile("spring-cloud").getAbsolutePath() + "/"); + releaserProperties.getGit() + .setSpringProjectUrl(tmpFile("spring-cloud").getAbsolutePath() + "/"); releaserProperties.getGit().setReleaseTrainWikiUrl( tmpFile("spring-cloud-wiki").getAbsolutePath() + "/"); this.releaserProperties = releaserProperties; return releaserProperties; } - private ReleaserProperties metaReleaserProperties(Map versions) throws URISyntaxException { + private ReleaserProperties metaReleaserProperties(Map versions) + throws URISyntaxException { ReleaserProperties releaserProperties = new ReleaserProperties(); Arrays.asList("spring-cloud-build", "spring-cloud-commons", "spring-cloud-stream", "spring-cloud-task", "spring-cloud-function", "spring-cloud-aws", "spring-cloud-bus", "spring-cloud-config", "spring-cloud-netflix", - "spring-cloud-cloudfoundry", "spring-cloud-gateway", "spring-cloud-security", - "spring-cloud-zookeeper", "spring-cloud-sleuth", + "spring-cloud-cloudfoundry", "spring-cloud-gateway", + "spring-cloud-security", "spring-cloud-zookeeper", "spring-cloud-sleuth", "spring-cloud-contract", "spring-cloud-vault") - .forEach(s -> releaserProperties.getMetaRelease().getProjectsToSkip().add(s)); - releaserProperties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static-angel/").toURI().toString()); + .forEach(s -> releaserProperties.getMetaRelease().getProjectsToSkip() + .add(s)); + releaserProperties.getGit().setDocumentationUrl( + file("/projects/spring-cloud-static-angel/").toURI().toString()); releaserProperties.getMaven().setBuildCommand("echo executed_build"); releaserProperties.getMaven().setDeployCommand("echo executed_deploy"); - releaserProperties.getMaven().setPublishDocsCommands(new String[] { "echo executed_docs"} ); - releaserProperties.getMetaRelease().setGitOrgUrl("file://" + this.temporaryFolder.getAbsolutePath()); + releaserProperties.getMaven() + .setPublishDocsCommands(new String[] { "echo executed_docs" }); + releaserProperties.getMetaRelease() + .setGitOrgUrl("file://" + this.temporaryFolder.getAbsolutePath()); releaserProperties.getMetaRelease().setEnabled(true); - releaserProperties.getGit().setSpringProjectUrl( - tmpFile("spring-cloud").getAbsolutePath() + "/"); + releaserProperties.getGit() + .setSpringProjectUrl(tmpFile("spring-cloud").getAbsolutePath() + "/"); releaserProperties.getGit().setReleaseTrainWikiUrl( tmpFile("spring-cloud-wiki").getAbsolutePath() + "/"); releaserProperties.setFixedVersions(versions); @@ -722,74 +813,101 @@ public class AcceptanceTests { return releaserProperties; } - private ReleaserProperties snapshotScReleaseReleaserProperties(File project, String branch) throws URISyntaxException { + private ReleaserProperties snapshotScReleaseReleaserProperties(File project, + String branch) throws URISyntaxException { ReleaserProperties releaserProperties = releaserProperties(project, branch); - releaserProperties.getGit().setReleaseTrainBomUrl(file("/projects/spring-cloud-release-with-snapshot/").toURI().toString()); - releaserProperties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString()); + releaserProperties.getGit().setReleaseTrainBomUrl( + file("/projects/spring-cloud-release-with-snapshot/").toURI().toString()); + releaserProperties.getGit().setDocumentationUrl( + file("/projects/spring-cloud-static/").toURI().toString()); this.releaserProperties = releaserProperties; return releaserProperties; } + private File tmpFile(String relativePath) { + return new File(this.temporaryFolder, relativePath); + } + + private File file(String relativePath) throws URISyntaxException { + return new File(AcceptanceTests.class.getResource(relativePath).toURI()); + } + + private String text(File file) throws IOException { + return new String(Files.readAllBytes(file.toPath())); + } + class TestProjectGitHandler extends ProjectGitHandler { - boolean closedMilestones = false; - boolean issueCreatedInSpringGuides = false; final String expectedVersion; + final String projectName; - public TestProjectGitHandler(ReleaserProperties properties, - String expectedVersion, String projectName) { + boolean closedMilestones = false; + + boolean issueCreatedInSpringGuides = false; + + TestProjectGitHandler(ReleaserProperties properties, String expectedVersion, + String projectName) { super(properties); this.expectedVersion = expectedVersion; this.projectName = projectName; } - @Override public void closeMilestone(ProjectVersion releaseVersion) { + @Override + public void closeMilestone(ProjectVersion releaseVersion) { then(releaseVersion.projectName).isEqualTo(this.projectName); then(releaseVersion.version).isEqualTo(this.expectedVersion); this.closedMilestones = true; } - @Override public void createIssueInSpringGuides(Projects projects, - ProjectVersion version) { + @Override + public void createIssueInSpringGuides(Projects projects, ProjectVersion version) { this.issueCreatedInSpringGuides = true; } - @Override public String milestoneUrl(ProjectVersion releaseVersion) { + @Override + public String milestoneUrl(ProjectVersion releaseVersion) { return "http://foo.bar.com/" + releaseVersion.toString(); } + } class NonAssertingTestProjectGitHandler extends ProjectGitHandler { boolean closedMilestones = false; + boolean issueCreatedInSpringGuides = false; + List clonedProjects = new ArrayList<>(); - public NonAssertingTestProjectGitHandler(ReleaserProperties properties) { + NonAssertingTestProjectGitHandler(ReleaserProperties properties) { super(properties); } - @Override public void closeMilestone(ProjectVersion releaseVersion) { + @Override + public void closeMilestone(ProjectVersion releaseVersion) { this.closedMilestones = true; } - @Override public void createIssueInSpringGuides(Projects projects, - ProjectVersion version) { + @Override + public void createIssueInSpringGuides(Projects projects, ProjectVersion version) { this.issueCreatedInSpringGuides = true; } - @Override public String milestoneUrl(ProjectVersion releaseVersion) { + @Override + public String milestoneUrl(ProjectVersion releaseVersion) { return "http://foo.bar.com/" + releaseVersion.toString(); } - @Override public File cloneReleaseTrainProject() { + @Override + public File cloneReleaseTrainProject() { File file = super.cloneReleaseTrainProject(); this.clonedProjects.add(file); return file; } - @Override public File cloneDocumentationProject() { + @Override + public File cloneDocumentationProject() { File file = super.cloneDocumentationProject(); this.clonedProjects.add(file); return file; @@ -809,22 +927,13 @@ public class AcceptanceTests { return file; } - @Override public File cloneProjectFromOrg(String projectName) { + @Override + public File cloneProjectFromOrg(String projectName) { File file = super.cloneProjectFromOrg(projectName); this.clonedProjects.add(file); return file; } + } - private File tmpFile(String relativePath) { - return new File(this.temporaryFolder, relativePath); - } - - private File file(String relativePath) throws URISyntaxException { - return new File(AcceptanceTests.class.getResource(relativePath).toURI()); - } - - private String text(File file) throws IOException { - return new String(Files.readAllBytes(file.toPath())); - } } diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/CompositeConsumerTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/CompositeConsumerTests.java index 221b742c..6f2490f6 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/CompositeConsumerTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/CompositeConsumerTests.java @@ -14,6 +14,22 @@ * limitations under the License. */ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.util.Arrays; @@ -28,17 +44,19 @@ public class CompositeConsumerTests { @Test public void should_throw_exception_for_a_release_task() { - CompositeConsumer compositeConsumer = new CompositeConsumer(Arrays.asList( - new Task("foo", "foo", "foo", "foo", - (args -> {})), - new Task("bar", "bar", "bar", "bar", - (args -> { throw new MyException(); })) - )); + CompositeConsumer compositeConsumer = new CompositeConsumer( + Arrays.asList(new Task("foo", "foo", "foo", "foo", (args -> { + })), new Task("bar", "bar", "bar", "bar", (args -> { + throw new MyException(); + })))); - BDDAssertions.thenThrownBy(() -> - compositeConsumer.accept(new Args(TaskType.RELEASE))) + BDDAssertions + .thenThrownBy(() -> compositeConsumer.accept(new Args(TaskType.RELEASE))) .isInstanceOf(MyException.class); } + } -class MyException extends RuntimeException {} \ No newline at end of file +class MyException extends RuntimeException { + +} diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/OptionsParserTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/OptionsParserTests.java index 3e6b4eda..06643844 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/OptionsParserTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/OptionsParserTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.util.ArrayList; @@ -13,32 +29,31 @@ import org.junit.Test; */ public class OptionsParserTests { - @Test public void should_filter_provided_task_names() { + @Test + public void should_filter_provided_task_names() { OptionsParser optionsParser = new OptionsParser(); - List taskNames = optionsParser.filterProvidedTaskNames( - providedTaskNames(), allTaskNames(), true - ); + List taskNames = optionsParser + .filterProvidedTaskNames(providedTaskNames(), allTaskNames(), true); BDDAssertions.then(taskNames).isEqualTo(providedTaskNames()); } private List providedTaskNames() { - return new ArrayList<>( - Arrays.asList("spring-cloud-config", "spring-cloud-netflix", - "spring-cloud-cloudfoundry", "spring-cloud-openfeign", - "spring-cloud-gateway", "spring-cloud-security", - "spring-cloud-sleuth", "spring-cloud-contract", - "spring-cloud-vault", "spring-cloud-release")); + return new ArrayList<>(Arrays.asList("spring-cloud-config", + "spring-cloud-netflix", "spring-cloud-cloudfoundry", + "spring-cloud-openfeign", "spring-cloud-gateway", "spring-cloud-security", + "spring-cloud-sleuth", "spring-cloud-contract", "spring-cloud-vault", + "spring-cloud-release")); } private List allTaskNames() { - return new ArrayList<>( - Arrays.asList("spring-cloud-config", "spring-cloud-netflix", - "spring-cloud-cloudfoundry", "spring-cloud-openfeign", - "spring-cloud-gateway", "spring-cloud-security", - "spring-cloud-sleuth", "spring-cloud-contract", - "spring-cloud-vault", "spring-cloud-release", - "spring-cloud-1", "spring-cloud-2", "spring-cloud-3")); + return new ArrayList<>(Arrays.asList("spring-cloud-config", + "spring-cloud-netflix", "spring-cloud-cloudfoundry", + "spring-cloud-openfeign", "spring-cloud-gateway", "spring-cloud-security", + "spring-cloud-sleuth", "spring-cloud-contract", "spring-cloud-vault", + "spring-cloud-release", "spring-cloud-1", "spring-cloud-2", + "spring-cloud-3")); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/OptionsProcessorTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/OptionsProcessorTests.java index 58942232..233d3cd5 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/OptionsProcessorTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/OptionsProcessorTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.util.Arrays; @@ -10,6 +26,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; + import org.springframework.cloud.release.internal.Releaser; import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.options.Options; @@ -25,22 +42,32 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; @SuppressWarnings("unchecked") public class OptionsProcessorTests { - @Mock Releaser releaser; + @Mock + Releaser releaser; + FirstConsumer first = new FirstConsumer(); + SecondConsumer second = new SecondConsumer(); + ThirdConsumer third = new ThirdConsumer(); + Task firstTask = task("first", "1", "", "", this.first); - List tasks = Arrays.asList(new Task[] { - this.firstTask, - task("second", "2", "", "", this.second), - task("third", "3", "", "", this.third) - }); + + List tasks = Arrays + .asList(new Task[] { this.firstTask, task("second", "2", "", "", this.second), + task("third", "3", "", "", this.third) }); OptionsProcessor optionsProcessor; + static Task task(String name, String shortName, String header, String description, + Consumer function) { + return new Task(name, shortName, header, description, function); + } + @Before public void setup() { - this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks); + this.optionsProcessor = new OptionsProcessor(this.releaser, + new ReleaserProperties(), this.tasks); Task.stepSkipper = () -> false; } @@ -54,7 +81,7 @@ public class OptionsProcessorTests { Options options = nonInteractiveOpts().options(); thenThrownBy(() -> this.optionsProcessor.processOptions(options, args())) - .hasMessageContaining("You haven't picked any recognizable option"); + .hasMessageContaining("You haven't picked any recognizable option"); } @Test @@ -68,7 +95,6 @@ public class OptionsProcessorTests { then(this.third.executed).isTrue(); } - @Test public void should_execute_only_tasks_after_the_provided_one_using_short_name() { Options options = nonInteractiveOpts().startFrom("2").options(); @@ -126,7 +152,8 @@ public class OptionsProcessorTests { @Test public void should_execute_only_tasks_from_multi_using_full_name() { - Options options = nonInteractiveOpts().taskNames(list("first", "third")).options(); + Options options = nonInteractiveOpts().taskNames(list("first", "third")) + .options(); this.optionsProcessor.processOptions(options, args()); @@ -148,8 +175,10 @@ public class OptionsProcessorTests { @Test public void should_execute_interactively_only_single_task() { - this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks) { - @Override String chosenOption() { + this.optionsProcessor = new OptionsProcessor(this.releaser, + new ReleaserProperties(), this.tasks) { + @Override + String chosenOption() { return "0"; } }; @@ -164,8 +193,10 @@ public class OptionsProcessorTests { @Test public void should_execute_interactively_range_of_tasks() { - this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks) { - @Override String chosenOption() { + this.optionsProcessor = new OptionsProcessor(this.releaser, + new ReleaserProperties(), this.tasks) { + @Override + String chosenOption() { return "0-1"; } }; @@ -180,8 +211,10 @@ public class OptionsProcessorTests { @Test public void should_execute_interactively_start_from() { - this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks) { - @Override String chosenOption() { + this.optionsProcessor = new OptionsProcessor(this.releaser, + new ReleaserProperties(), this.tasks) { + @Override + String chosenOption() { return "1-"; } }; @@ -196,8 +229,10 @@ public class OptionsProcessorTests { @Test public void should_execute_interactively_multi() { - this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks) { - @Override String chosenOption() { + this.optionsProcessor = new OptionsProcessor(this.releaser, + new ReleaserProperties(), this.tasks) { + @Override + String chosenOption() { return "0,2"; } }; @@ -212,12 +247,15 @@ public class OptionsProcessorTests { @Test public void should_execute_full_release() { - this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks) { - @Override Task releaseTask() { + this.optionsProcessor = new OptionsProcessor(this.releaser, + new ReleaserProperties(), this.tasks) { + @Override + Task releaseTask() { return OptionsProcessorTests.this.firstTask; } - @Override String chosenOption() { + @Override + String chosenOption() { return "0"; } }; @@ -232,12 +270,15 @@ public class OptionsProcessorTests { @Test public void should_execute_full_verbose_release() { - this.optionsProcessor = new OptionsProcessor(this.releaser, new ReleaserProperties(), this.tasks) { - @Override Task releaseVerboseTask() { + this.optionsProcessor = new OptionsProcessor(this.releaser, + new ReleaserProperties(), this.tasks) { + @Override + Task releaseVerboseTask() { return OptionsProcessorTests.this.firstTask; } - @Override String chosenOption() { + @Override + String chosenOption() { return "0"; } }; @@ -252,11 +293,8 @@ public class OptionsProcessorTests { @Test public void should_remove_single_quotes() { - Options options = interactiveOpts().fullRelease(true) - .range("'1-2'") - .startFrom("'c'") - .taskNames(Arrays.asList("'a'", "'b'")) - .options(); + Options options = interactiveOpts().fullRelease(true).range("'1-2'") + .startFrom("'c'").taskNames(Arrays.asList("'a'", "'b'")).options(); then(options.range).isEqualTo("1-2"); then(options.startFrom).isEqualTo("c"); @@ -272,42 +310,45 @@ public class OptionsProcessorTests { } private Args args() { - return new Args(null, null, null, null, null, null, false, TaskType.RELEASE, null); + return new Args(null, null, null, null, null, null, false, TaskType.RELEASE, + null); } private List list(String... list) { return Arrays.asList(list); } - static Task task(String name, String shortName, String header, String description, Consumer function) { - return new Task(name, shortName, header, description, function); - } - } class FirstConsumer implements Consumer { boolean executed; - @Override public void accept(Args o) { + @Override + public void accept(Args o) { this.executed = true; } + } class SecondConsumer implements Consumer { boolean executed; - @Override public void accept(Args o) { + @Override + public void accept(Args o) { this.executed = true; } + } class ThirdConsumer implements Consumer { boolean executed; - @Override public void accept(Args o) { + @Override + public void accept(Args o) { this.executed = true; } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserApplicationEventTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserApplicationEventTests.java index 6776648d..65d241ac 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserApplicationEventTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserApplicationEventTests.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.cloud.release.internal.spring; import org.assertj.core.api.BDDAssertions; @@ -28,8 +29,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(classes = ReleaserApplicationEventTests.Config.class, - properties = "releaser.git.oauth-token=some-fake-token") +@SpringBootTest(classes = ReleaserApplicationEventTests.Config.class, properties = "releaser.git.oauth-token=some-fake-token") public class ReleaserApplicationEventTests { @Autowired @@ -37,9 +37,12 @@ public class ReleaserApplicationEventTests { @Test public void should_throw_exceptions_when_at_least_one_task_is_failing() { - this.publisher.publishEvent(new TaskCompleted(this, "foo", TaskAndException.skipped(Tasks.PUSH))); - this.publisher.publishEvent(new TaskCompleted(this, "foo", TaskAndException.success(Tasks.CLOSE_MILESTONE))); - this.publisher.publishEvent(new TaskCompleted(this, "foo", TaskAndException.failure(Tasks.DEPLOY, new RuntimeException("boom!")))); + this.publisher.publishEvent( + new TaskCompleted(this, "foo", TaskAndException.skipped(Tasks.PUSH))); + this.publisher.publishEvent(new TaskCompleted(this, "foo", + TaskAndException.success(Tasks.CLOSE_MILESTONE))); + this.publisher.publishEvent(new TaskCompleted(this, "foo", + TaskAndException.failure(Tasks.DEPLOY, new RuntimeException("boom!")))); BDDAssertions.thenThrownBy(() -> { this.publisher.publishEvent(new BuildCompleted(this)); @@ -48,20 +51,21 @@ public class ReleaserApplicationEventTests { @Test public void should_not_fail_when_all_tasks_not_failing() { - this.publisher.publishEvent(new TaskCompleted(this, "foo", TaskAndException.skipped(Tasks.PUSH))); - this.publisher.publishEvent(new TaskCompleted(this, "foo", TaskAndException.success(Tasks.CLOSE_MILESTONE))); + this.publisher.publishEvent( + new TaskCompleted(this, "foo", TaskAndException.skipped(Tasks.PUSH))); + this.publisher.publishEvent(new TaskCompleted(this, "foo", + TaskAndException.success(Tasks.CLOSE_MILESTONE))); this.publisher.publishEvent(new BuildCompleted(this)); } @Configuration @EnableAutoConfiguration - @ComponentScan({ - "org.springframework.cloud.release.internal.options", + @ComponentScan({ "org.springframework.cloud.release.internal.options", "org.springframework.cloud.release.internal.sagan", - "org.springframework.cloud.release.internal.spring", - }) + "org.springframework.cloud.release.internal.spring" }) static class Config { } + } diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesIntegrationTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesIntegrationTests.java index b1727c89..ef453323 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesIntegrationTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesIntegrationTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.io.File; @@ -7,6 +23,7 @@ import java.util.List; import org.assertj.core.api.BDDAssertions; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.ReleaserPropertiesAware; @@ -23,23 +40,28 @@ import org.springframework.test.context.junit4.SpringRunner; @Import(ReleaserPropertiesIntegrationTests.Config.class) public class ReleaserPropertiesIntegrationTests { - @Autowired List propertiesAware; - @Autowired ApplicationContext context; - - @Test public void should_update_properties() { + @Autowired + List propertiesAware; + + @Autowired + ApplicationContext context; + + @Test + public void should_update_properties() { ReleaserProperties properties = new ReleaserProperties(); properties.getPom().setBranch("fooooo"); - + new ReleaserPropertiesUpdater(this.context).updateProperties(properties, new File(".")); BDDAssertions.then(this.propertiesAware).hasSize(2); - this.propertiesAware.forEach(aware -> - BDDAssertions.then(((ReleaserPropertiesHaving) aware) - .properties.getPom().getBranch()).isEqualTo("fooooo")); + this.propertiesAware.forEach(aware -> BDDAssertions + .then(((ReleaserPropertiesHaving) aware).properties.getPom().getBranch()) + .isEqualTo("fooooo")); } - @Test public void should_update_properties_including_existing_releaser_config() { + @Test + public void should_update_properties_including_existing_releaser_config() { ReleaserProperties properties = new ReleaserProperties(); properties.getPom().setBranch("barrrr"); URL resource = ReleaserPropertiesIntegrationTests.class @@ -51,12 +73,15 @@ public class ReleaserPropertiesIntegrationTests { BDDAssertions.then(this.propertiesAware).hasSize(2); this.propertiesAware.forEach(aware -> { ReleaserPropertiesHaving having = ((ReleaserPropertiesHaving) aware); - BDDAssertions.then(having.properties.getPom().getBranch()).isEqualTo("barrrr"); - BDDAssertions.then(having.properties.getMaven().getBuildCommand()).isEqualTo("./scripts/noIntegration.sh"); + BDDAssertions.then(having.properties.getPom().getBranch()) + .isEqualTo("barrrr"); + BDDAssertions.then(having.properties.getMaven().getBuildCommand()) + .isEqualTo("./scripts/noIntegration.sh"); }); } - @Test public void should_update_properties_including_existing_releaser_config_for_netflix() { + @Test + public void should_update_properties_including_existing_releaser_config_for_netflix() { ReleaserProperties properties = new ReleaserProperties(); properties.getPom().setBranch("bazzzz"); URL resource = ReleaserPropertiesIntegrationTests.class @@ -68,31 +93,41 @@ public class ReleaserPropertiesIntegrationTests { BDDAssertions.then(this.propertiesAware).hasSize(2); this.propertiesAware.forEach(aware -> { ReleaserPropertiesHaving having = ((ReleaserPropertiesHaving) aware); - BDDAssertions.then(having.properties.getPom().getBranch()).isEqualTo("bazzzz"); - BDDAssertions.then(having.properties.getMaven().getBuildCommand()).isEqualTo("./scripts/build.sh {{systemProps}}"); + BDDAssertions.then(having.properties.getPom().getBranch()) + .isEqualTo("bazzzz"); + BDDAssertions.then(having.properties.getMaven().getBuildCommand()) + .isEqualTo("./scripts/build.sh {{systemProps}}"); }); } @Configuration static class Config { - @Bean ReleaserPropertiesAware aware1() { + + @Bean + ReleaserPropertiesAware aware1() { return new ReleaserPropertiesHaving(); } - @Bean ReleaserPropertiesAware aware2() { + + @Bean + ReleaserPropertiesAware aware2() { return new ReleaserPropertiesHaving(); } + } static class ReleaserPropertiesHaving implements ReleaserPropertiesAware { ReleaserProperties properties; - @Override public void setReleaserProperties(ReleaserProperties properties) { + @Override + public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; } ReleaserProperties getProps() { return this.properties; } + } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesUpdaterTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesUpdaterTests.java index dd377023..b04cc88a 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesUpdaterTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/ReleaserPropertiesUpdaterTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.io.File; @@ -8,6 +24,7 @@ import java.util.Map; import org.assertj.core.api.BDDAssertions; import org.junit.Test; import org.mockito.BDDMockito; + import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.ReleaserPropertiesAware; import org.springframework.context.ApplicationContext; @@ -18,6 +35,7 @@ import org.springframework.context.ApplicationContext; public class ReleaserPropertiesUpdaterTests { ApplicationContext context = BDDMockito.mock(ApplicationContext.class); + File relaserUpdater; public ReleaserPropertiesUpdaterTests() throws URISyntaxException { @@ -25,15 +43,16 @@ public class ReleaserPropertiesUpdaterTests { .getResource("/projects/releaser-updater/").toURI()); } - @Test public void should_update_properties() { + @Test + public void should_update_properties() { ReleaserProperties original = originalReleaserProperties(); Aware aware = new Aware(); BDDMockito.given(this.context.getBeansOfType(BDDMockito.any(Class.class))) .willReturn(beansOfType(aware)); ReleaserPropertiesUpdater updater = new ReleaserPropertiesUpdater(this.context); - ReleaserProperties props = updater - .updateProperties(original, this.relaserUpdater); + ReleaserProperties props = updater.updateProperties(original, + this.relaserUpdater); BDDAssertions.then(aware.properties).isNotNull(); BDDAssertions.then(props.getMaven().getSystemProperties()).isEqualTo("-Dfoo=bar"); @@ -55,8 +74,11 @@ public class ReleaserPropertiesUpdaterTests { ReleaserProperties properties; - @Override public void setReleaserProperties(ReleaserProperties properties) { + @Override + public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; } + } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/SpringReleaserTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/SpringReleaserTests.java index 1fa5bf40..005b9267 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/SpringReleaserTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/SpringReleaserTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.io.File; @@ -35,14 +51,26 @@ public class SpringReleaserTests { private static final Logger log = LoggerFactory.getLogger(SpringReleaserTests.class); - @Mock Releaser releaser; + @Mock + Releaser releaser; + ReleaserProperties properties = properties(); - @Mock OptionsProcessor optionsProcessor; - @Mock ApplicationContext context; + + @Mock + OptionsProcessor optionsProcessor; + + @Mock + ApplicationContext context; + Aware1 aware1 = new Aware1(); + Aware2 aware2 = new Aware2(); + ReleaserPropertiesUpdater updater; - @Mock ApplicationEventPublisher applicationEventPublisher; + + @Mock + ApplicationEventPublisher applicationEventPublisher; + File releaserUpdater = new File(ReleaserPropertiesUpdaterTests.class .getResource("/projects/releaser-updater/config/releaser.yml").toURI()); @@ -102,8 +130,8 @@ public class SpringReleaserTests { private void thenOnlyCallsPostRelease() { BDDMockito.then(this.optionsProcessor).should().postReleaseOptions( BDDMockito.any(Options.class), BDDMockito.any(Args.class)); - BDDMockito.then(this.optionsProcessor).should(BDDMockito.never()) - .processOptions(BDDMockito.any(Options.class), BDDMockito.any(Args.class)); + BDDMockito.then(this.optionsProcessor).should(BDDMockito.never()).processOptions( + BDDMockito.any(Options.class), BDDMockito.any(Args.class)); } private void assertBuildCommand(Queue properties) { @@ -114,11 +142,12 @@ public class SpringReleaserTests { } private SpringReleaser stubbedSpringReleaser() { - return new SpringReleaser(this.releaser, this.properties, - this.optionsProcessor, this.updater, applicationEventPublisher) { + return new SpringReleaser(this.releaser, this.properties, this.optionsProcessor, + this.updater, this.applicationEventPublisher) { @Override - Args postReleaseOptionsAgs(Options options, ProjectsAndVersion projectsAndVersion) { + Args postReleaseOptionsAgs(Options options, + ProjectsAndVersion projectsAndVersion) { return new Args(TaskType.RELEASE); } @@ -128,7 +157,8 @@ public class SpringReleaserTests { } @Override - ProjectsAndVersion processProject(Options options, File project, TaskType taskType) { + ProjectsAndVersion processProject(Options options, File project, + TaskType taskType) { return null; } }; @@ -139,6 +169,7 @@ public class SpringReleaserTests { properties.getMaven().setBuildCommand("build"); return properties; } + } class Aware1 implements ReleaserPropertiesAware { @@ -149,6 +180,7 @@ class Aware1 implements ReleaserPropertiesAware { public void setReleaserProperties(ReleaserProperties properties) { this.properties.add(properties); } + } class Aware2 implements ReleaserPropertiesAware { @@ -159,4 +191,5 @@ class Aware2 implements ReleaserPropertiesAware { public void setReleaserProperties(ReleaserProperties properties) { this.properties.add(properties); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/TaskTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/TaskTests.java index 8e31bb56..083ad55c 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/TaskTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/TaskTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.release.internal.spring; import java.util.concurrent.atomic.AtomicBoolean; @@ -16,12 +32,15 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; */ public class TaskTests { - @Rule public OutputCapture capture = new OutputCapture(); + @Rule + public OutputCapture capture = new OutputCapture(); - @Test public void should_successfully_execute_task() { + @Test + public void should_successfully_execute_task() { final AtomicBoolean someBool = new AtomicBoolean(); Task task = new Task("foo", "bar", "baz", "descr", new Consumer() { - @Override public void accept(Args args) { + @Override + public void accept(Args args) { someBool.set(true); } }); @@ -31,7 +50,8 @@ public class TaskTests { then(someBool.get()).isTrue(); } - @Test public void should_fail_with_nice_text_on_exception() { + @Test + public void should_fail_with_nice_text_on_exception() { final AtomicBoolean someBool = new AtomicBoolean(); Task task = new Task("foo", "bar", "baz", "descr", args -> { someBool.set(true); @@ -41,9 +61,9 @@ public class TaskTests { thenThrownBy(() -> task.execute(new Args(TaskType.RELEASE))) .isInstanceOf(RuntimeException.class); then(someBool.get()).isTrue(); - then(this.capture.toString()) - .contains("BUILD FAILED!!!") + then(this.capture.toString()).contains("BUILD FAILED!!!") .contains("Exception occurred for project <> task ") .contains("with description "); } -} \ No newline at end of file + +} diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/project-with-config/config/releaser.yml b/spring-cloud-release-tools-spring/src/test/resources/projects/project-with-config/config/releaser.yml index 6d9c27b1..d599d075 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/project-with-config/config/releaser.yml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/project-with-config/config/releaser.yml @@ -1,4 +1,4 @@ releaser.maven.buildCommand: ./scripts/noIntegration.sh releaser.gradle.gradlePropsSubstitution: verifierVersion: spring-cloud-contract - bootVersion: spring-boot \ No newline at end of file + bootVersion: spring-boot diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/project-with-netflix-config/config/releaser.yml b/spring-cloud-release-tools-spring/src/test/resources/projects/project-with-netflix-config/config/releaser.yml index 304529b2..26e5e8c2 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/project-with-netflix-config/config/releaser.yml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/project-with-netflix-config/config/releaser.yml @@ -1,3 +1,3 @@ releaser: maven: - buildCommand: ./scripts/build.sh {{systemProps}} \ No newline at end of file + buildCommand: ./scripts/build.sh {{systemProps}} diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/releaser-updater/config/releaser.yml b/spring-cloud-release-tools-spring/src/test/resources/projects/releaser-updater/config/releaser.yml index 6d9c27b1..d599d075 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/releaser-updater/config/releaser.yml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/releaser-updater/config/releaser.yml @@ -1,4 +1,4 @@ releaser.maven.buildCommand: ./scripts/noIntegration.sh releaser.gradle.gradlePropsSubstitution: verifierVersion: spring-cloud-contract - bootVersion: spring-boot \ No newline at end of file + bootVersion: spring-boot diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/.settings.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/.settings.xml index 6c355129..6f542c94 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/.settings.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/.settings.xml @@ -1,66 +1,68 @@ - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - true - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - http://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - - + + + repo.spring.io + ${env.CI_DEPLOY_USERNAME} + ${env.CI_DEPLOY_PASSWORD} + + + + + + spring + + true + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + http://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/.travis.yml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/.travis.yml index f8d83069..391e47cd 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/.travis.yml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/.travis.yml @@ -8,19 +8,19 @@ before_install: - echo "https://$GH_TOKEN:@github.com" > .git/credentials - gem install asciidoctor install: -- ./mvnw install -P docs -q -U -DskipTests=true -Dmaven.test.redirectTestOutputToFile=true -- '[ "${MVN_GOAL}" == "deploy" ] && ./docs/src/main/asciidoc/ghpages.sh || echo "Not updating docs"' + - ./mvnw install -P docs -q -U -DskipTests=true -Dmaven.test.redirectTestOutputToFile=true + - '[ "${MVN_GOAL}" == "deploy" ] && ./docs/src/main/asciidoc/ghpages.sh || echo "Not updating docs"' script: -- './mvnw -s .settings.xml $MVN_GOAL $MVN_PROFILE -nsu -Dmaven.test.redirectTestOutputToFile=true' + - './mvnw -s .settings.xml $MVN_GOAL $MVN_PROFILE -nsu -Dmaven.test.redirectTestOutputToFile=true' env: global: - - GIT_NAME="Dave Syer" - - GIT_EMAIL=dsyer@pivotal.io - - CI_DEPLOY_USERNAME=buildmaster - - FEATURE_BRANCH=$(echo ${TRAVIS_BRANCH} | grep "^.*/.*$" && echo true || echo false) - - SPRING_CLOUD_BUILD=$(echo ${TRAVIS_REPO_SLUG} | grep -q "^spring-cloud/.*$" && echo true || echo false) - - MVN_GOAL=$([ "${TRAVIS_PULL_REQUEST}" == "false" -a "${TRAVIS_TAG}" == "" -a "${FEATURE_BRANCH}" == "false" -a "${SPRING_CLOUD_BUILD}" == "true" ] && echo deploy || echo install) - - VERSION=$(mvn validate | grep Building | head -1 | sed -e 's/.* //') - - MILESTONE=$(echo ${VERSION} | egrep 'M|RC' && echo true || echo false) - - MVN_PROFILE=$([ "${MILESTONE}" == "true" ] && echo -P milestone) - - secure: "KRJQg6soMWudREJ11ocGK8I4OuhIehvy/ehTjBxvyATEwL6rXA9dKPGfb0OAscEgIpNxW1cezH8vUSaSZGFhx6LF5VnJ9Mh39pi9uYm9GMjQ61B4d5GaRjbGj/fXBd8kGubDO8kmjkDGGgkjWXfYZa/WIQ4kVWCIB5dVV9XJ0Lw=" + - GIT_NAME="Dave Syer" + - GIT_EMAIL=dsyer@pivotal.io + - CI_DEPLOY_USERNAME=buildmaster + - FEATURE_BRANCH=$(echo ${TRAVIS_BRANCH} | grep "^.*/.*$" && echo true || echo false) + - SPRING_CLOUD_BUILD=$(echo ${TRAVIS_REPO_SLUG} | grep -q "^spring-cloud/.*$" && echo true || echo false) + - MVN_GOAL=$([ "${TRAVIS_PULL_REQUEST}" == "false" -a "${TRAVIS_TAG}" == "" -a "${FEATURE_BRANCH}" == "false" -a "${SPRING_CLOUD_BUILD}" == "true" ] && echo deploy || echo install) + - VERSION=$(mvn validate | grep Building | head -1 | sed -e 's/.* //') + - MILESTONE=$(echo ${VERSION} | egrep 'M|RC' && echo true || echo false) + - MVN_PROFILE=$([ "${MILESTONE}" == "true" ] && echo -P milestone) + - secure: "KRJQg6soMWudREJ11ocGK8I4OuhIehvy/ehTjBxvyATEwL6rXA9dKPGfb0OAscEgIpNxW1cezH8vUSaSZGFhx6LF5VnJ9Mh39pi9uYm9GMjQ61B4d5GaRjbGj/fXBd8kGubDO8kmjkDGGgkjWXfYZa/WIQ4kVWCIB5dVV9XJ0Lw=" diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/pom.xml index ae5b14c7..d6ebc32b 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 spring-cloud-build-docs spring-cloud-build-docs diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/highlight.css b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/highlight.css index ffefef72..3850f8b9 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/highlight.css +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/highlight.css @@ -4,32 +4,32 @@ */ .hl-keyword { - color: #7F0055; - font-weight: bold; + color: #7F0055; + font-weight: bold; } .hl-comment { - color: #3F5F5F; - font-style: italic; + color: #3F5F5F; + font-style: italic; } .hl-multiline-comment { - color: #3F5FBF; - font-style: italic; + color: #3F5FBF; + font-style: italic; } .hl-tag { - color: #3F7F7F; + color: #3F7F7F; } .hl-attribute { - color: #7F007F; + color: #7F007F; } .hl-value { - color: #2A00FF; + color: #2A00FF; } .hl-string { - color: #2A00FF; + color: #2A00FF; } \ No newline at end of file diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual-multipage.css b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual-multipage.css index 0c484531..b790654b 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual-multipage.css +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual-multipage.css @@ -1,7 +1,7 @@ @IMPORT url("manual.css"); body.firstpage { - background: url("../images/background.png") no-repeat center top; + background: url("../images/background.png") no-repeat center top; } div.part h1 { diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual-singlepage.css b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual-singlepage.css index 4a7fd140..303192a8 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual-singlepage.css +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual-singlepage.css @@ -1,6 +1,6 @@ @IMPORT url("manual.css"); body { - background: url("../images/background.png") no-repeat center top; + background: url("../images/background.png") no-repeat center top; } diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual.css b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual.css index 0ecbe2e8..20cf07da 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual.css +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/css/manual.css @@ -1,344 +1,342 @@ @IMPORT url("highlight.css"); html { - padding: 0pt; - margin: 0pt; + padding: 0pt; + margin: 0pt; } body { - color: #333333; - margin: 15px 30px; - font-family: Helvetica, Arial, Freesans, Clean, Sans-serif; - line-height: 1.6; - -webkit-font-smoothing: antialiased; + color: #333333; + margin: 15px 30px; + font-family: Helvetica, Arial, Freesans, Clean, Sans-serif; + line-height: 1.6; + -webkit-font-smoothing: antialiased; } code { - font-size: 16px; - font-family: Consolas, "Liberation Mono", Courier, monospace; + font-size: 16px; + font-family: Consolas, "Liberation Mono", Courier, monospace; } -:not(a)>code { - color: #6D180B; +:not(a) > code { + color: #6D180B; } -:not(pre)>code { - background-color: #F2F2F2; - border: 1px solid #CCCCCC; - border-radius: 4px; - padding: 1px 3px 0; - text-shadow: none; - white-space: nowrap; +:not(pre) > code { + background-color: #F2F2F2; + border: 1px solid #CCCCCC; + border-radius: 4px; + padding: 1px 3px 0; + text-shadow: none; + white-space: nowrap; } -body>*:first-child { - margin-top: 0 !important; +body > *:first-child { + margin-top: 0 !important; } div { - margin: 0pt; + margin: 0pt; } hr { - border: 1px solid #CCCCCC; - background: #CCCCCC; + border: 1px solid #CCCCCC; + background: #CCCCCC; } -h1,h2,h3,h4,h5,h6 { - color: #000000; - cursor: text; - font-weight: bold; - margin: 30px 0 10px; - padding: 0; +h1, h2, h3, h4, h5, h6 { + color: #000000; + cursor: text; + font-weight: bold; + margin: 30px 0 10px; + padding: 0; } -h1,h2,h3 { - margin: 40px 0 10px; +h1, h2, h3 { + margin: 40px 0 10px; } h1 { - margin: 70px 0 30px; - padding-top: 20px; + margin: 70px 0 30px; + padding-top: 20px; } div.part h1 { - border-top: 1px dotted #CCCCCC; + border-top: 1px dotted #CCCCCC; } -h1,h1 code { - font-size: 32px; +h1, h1 code { + font-size: 32px; } -h2,h2 code { - font-size: 24px; +h2, h2 code { + font-size: 24px; } -h3,h3 code { - font-size: 20px; +h3, h3 code { + font-size: 20px; } -h4,h1 code,h5,h5 code,h6,h6 code { - font-size: 18px; +h4, h1 code, h5, h5 code, h6, h6 code { + font-size: 18px; } -div.book,div.chapter,div.appendix,div.part,div.preface { - min-width: 300px; - max-width: 1200px; - margin: 0 auto; +div.book, div.chapter, div.appendix, div.part, div.preface { + min-width: 300px; + max-width: 1200px; + margin: 0 auto; } p.releaseinfo { - font-weight: bold; - margin-bottom: 40px; - margin-top: 40px; + font-weight: bold; + margin-bottom: 40px; + margin-top: 40px; } div.authorgroup { - line-height: 1; + line-height: 1; } p.copyright { - line-height: 1; - margin-bottom: -5px; + line-height: 1; + margin-bottom: -5px; } .legalnotice p { - font-style: italic; - font-size: 14px; - line-height: 1; + font-style: italic; + font-size: 14px; + line-height: 1; } -div.titlepage+p,div.titlepage+p { - margin-top: 0; +div.titlepage + p, div.titlepage + p { + margin-top: 0; } pre { - line-height: 1.0; - color: black; + line-height: 1.0; + color: black; } a { - color: #4183C4; - text-decoration: none; + color: #4183C4; + text-decoration: none; } p { - margin: 15px 0; - text-align: left; + margin: 15px 0; + text-align: left; } -ul,ol { - padding-left: 30px; +ul, ol { + padding-left: 30px; } li p { - margin: 0; + margin: 0; } div.table { - margin: 1em; - padding: 0.5em; - text-align: center; + margin: 1em; + padding: 0.5em; + text-align: center; } -div.table table,div.informaltable table { - display: table; - width: 100%; +div.table table, div.informaltable table { + display: table; + width: 100%; } div.table td { - padding-left: 7px; - padding-right: 7px; + padding-left: 7px; + padding-right: 7px; } .sidebar { - line-height: 1.4; - padding: 0 20px; - background-color: #F8F8F8; - border: 1px solid #CCCCCC; - border-radius: 3px 3px 3px 3px; + line-height: 1.4; + padding: 0 20px; + background-color: #F8F8F8; + border: 1px solid #CCCCCC; + border-radius: 3px 3px 3px 3px; } .sidebar p.title { - color: #6D180B; + color: #6D180B; } -pre.programlisting,pre.screen { - font-size: 15px; - padding: 6px 10px; - background-color: #F8F8F8; - border: 1px solid #CCCCCC; - border-radius: 3px 3px 3px 3px; - clear: both; - overflow: auto; - line-height: 1.4; - font-family: Consolas, "Liberation Mono", Courier, monospace; +pre.programlisting, pre.screen { + font-size: 15px; + padding: 6px 10px; + background-color: #F8F8F8; + border: 1px solid #CCCCCC; + border-radius: 3px 3px 3px 3px; + clear: both; + overflow: auto; + line-height: 1.4; + font-family: Consolas, "Liberation Mono", Courier, monospace; } table { - border-collapse: collapse; - border-spacing: 0; - border: 1px solid #DDDDDD !important; - border-radius: 4px !important; - border-collapse: separate !important; - line-height: 1.6; + border-collapse: collapse; + border-spacing: 0; + border: 1px solid #DDDDDD !important; + border-radius: 4px !important; + border-collapse: separate !important; + line-height: 1.6; } table thead { - background: #F5F5F5; + background: #F5F5F5; } table tr { - border: none; - border-bottom: none; + border: none; + border-bottom: none; } table th { - font-weight: bold; + font-weight: bold; } -table th,table td { - border: none !important; - padding: 6px 13px; +table th, table td { + border: none !important; + padding: 6px 13px; } table tr:nth-child(2n) { - background-color: #F8F8F8; + background-color: #F8F8F8; } td p { - margin: 0 0 15px 0; + margin: 0 0 15px 0; } div.table-contents td p { - margin: 0; + margin: 0; } -div.important *,div.note *,div.tip *,div.warning *,div.navheader *,div.navfooter *,div.calloutlist * - { - border: none !important; - background: none !important; - margin: 0; +div.important *, div.note *, div.tip *, div.warning *, div.navheader *, div.navfooter *, div.calloutlist * { + border: none !important; + background: none !important; + margin: 0; } -div.important p,div.note p,div.tip p,div.warning p { - color: #6F6F6F; - line-height: 1.6; +div.important p, div.note p, div.tip p, div.warning p { + color: #6F6F6F; + line-height: 1.6; } -div.important code,div.note code,div.tip code,div.warning code { - background-color: #F2F2F2 !important; - border: 1px solid #CCCCCC !important; - border-radius: 4px !important; - padding: 1px 3px 0 !important; - text-shadow: none !important; - white-space: nowrap !important; +div.important code, div.note code, div.tip code, div.warning code { + background-color: #F2F2F2 !important; + border: 1px solid #CCCCCC !important; + border-radius: 4px !important; + padding: 1px 3px 0 !important; + text-shadow: none !important; + white-space: nowrap !important; } -.note th,.tip th,.warning th { - display: none; +.note th, .tip th, .warning th { + display: none; } -.note tr:first-child td,.tip tr:first-child td,.warning tr:first-child td - { - border-right: 1px solid #CCCCCC !important; - padding-top: 10px; +.note tr:first-child td, .tip tr:first-child td, .warning tr:first-child td { + border-right: 1px solid #CCCCCC !important; + padding-top: 10px; } -div.calloutlist p,div.calloutlist td { - padding: 0; - margin: 0; +div.calloutlist p, div.calloutlist td { + padding: 0; + margin: 0; } -div.calloutlist>table>tbody>tr>td:first-child { - padding-left: 10px; - width: 30px !important; +div.calloutlist > table > tbody > tr > td:first-child { + padding-left: 10px; + width: 30px !important; } -div.important,div.note,div.tip,div.warning { - margin-left: 0px !important; - margin-right: 20px !important; - margin-top: 20px; - margin-bottom: 20px; - padding-top: 10px; - padding-bottom: 10px; +div.important, div.note, div.tip, div.warning { + margin-left: 0px !important; + margin-right: 20px !important; + margin-top: 20px; + margin-bottom: 20px; + padding-top: 10px; + padding-bottom: 10px; } div.toc { - line-height: 1.2; + line-height: 1.2; } -dl,dt { - margin-top: 1px; - margin-bottom: 0; +dl, dt { + margin-top: 1px; + margin-bottom: 0; } -div.toc>dl>dt { - font-size: 32px; - font-weight: bold; - margin: 30px 0 10px 0; - display: block; +div.toc > dl > dt { + font-size: 32px; + font-weight: bold; + margin: 30px 0 10px 0; + display: block; } -div.toc>dl>dd>dl>dt { - font-size: 24px; - font-weight: bold; - margin: 20px 0 10px 0; - display: block; +div.toc > dl > dd > dl > dt { + font-size: 24px; + font-weight: bold; + margin: 20px 0 10px 0; + display: block; } -div.toc>dl>dd>dl>dd>dl>dt { - font-weight: bold; - font-size: 20px; - margin: 10px 0 0 0; +div.toc > dl > dd > dl > dd > dl > dt { + font-weight: bold; + font-size: 20px; + margin: 10px 0 0 0; } tbody.footnotes * { - border: none !important; + border: none !important; } div.footnote p { - margin: 0; - line-height: 1; + margin: 0; + line-height: 1; } div.footnote p sup { - margin-right: 6px; - vertical-align: middle; + margin-right: 6px; + vertical-align: middle; } div.navheader { - border-bottom: 1px solid #CCCCCC; + border-bottom: 1px solid #CCCCCC; } div.navfooter { - border-top: 1px solid #CCCCCC; + border-top: 1px solid #CCCCCC; } .title { - margin-left: -1em; - padding-left: 1em; + margin-left: -1em; + padding-left: 1em; } -.title>a { - position: absolute; - visibility: hidden; - display: block; - font-size: 0.85em; - margin-top: 0.05em; - margin-left: -1em; - vertical-align: text-top; - color: black; +.title > a { + position: absolute; + visibility: hidden; + display: block; + font-size: 0.85em; + margin-top: 0.05em; + margin-left: -1em; + vertical-align: text-top; + color: black; } -.title>a:before { - content: "\00A7"; +.title > a:before { + content: "\00A7"; } -.title:hover>a,.title>a:hover,.title:hover>a:hover { - visibility: visible; +.title:hover > a, .title > a:hover, .title:hover > a:hover { + visibility: visible; } -.title:focus>a,.title>a:focus,.title:focus>a:focus { - outline: 0; +.title:focus > a, .title > a:focus, .title:focus > a:focus { + outline: 0; } diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/common.xsl b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/common.xsl index 157bf9d8..c921d3c3 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/common.xsl +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/common.xsl @@ -20,10 +20,10 @@ --> + xmlns:xslthl="http://xslthl.sf.net" + xmlns:d="http://docbook.org/ns/docbook" + exclude-result-prefixes="xslthl d" + version='1.0'> 1 diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/epub.xsl b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/epub.xsl index 031406ca..c83cbf95 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/epub.xsl +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/epub.xsl @@ -20,10 +20,10 @@ under the License. --> + xmlns:xslthl="http://xslthl.sf.net" + xmlns:d="http://docbook.org/ns/docbook" + exclude-result-prefixes="xslthl d" + version='1.0'> diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/html-multipage.xsl b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/html-multipage.xsl index be9cc52d..2fe13e12 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/html-multipage.xsl +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/html-multipage.xsl @@ -39,12 +39,12 @@ under the License. - + - - + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/html.xsl b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/html.xsl index fd96f9a7..a1ac81d6 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/html.xsl +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/html.xsl @@ -20,10 +20,10 @@ under the License. --> + xmlns:xslthl="http://xslthl.sf.net" + xmlns:d="http://docbook.org/ns/docbook" + exclude-result-prefixes="xslthl" + version='1.0'> @@ -35,7 +35,7 @@ under the License. 1 - + 120 images/callouts/ .png @@ -68,35 +68,51 @@ under the License. - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/pdf.xsl b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/pdf.xsl index 77360a7b..a0d36dec 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/pdf.xsl +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/pdf.xsl @@ -69,9 +69,9 @@ under the License. @@ -308,9 +308,9 @@ under the License. Let's remove it, so this sucker can use our attribute-set only... --> + xsl:use-attribute-sets="chapter.titlepage.recto.style"> - + @@ -524,7 +524,7 @@ under the License. 1.5em - + 10pt bold false @@ -549,34 +549,46 @@ under the License. - - - + + + - + + + - + + + - + + + - + + + - + + + - + + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl-config.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl-config.xml index e4d677fc..1dce4071 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl-config.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl-config.xml @@ -1,23 +1,23 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/asciidoc-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/asciidoc-hl.xml index 5478b1d6..959434e1 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/asciidoc-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/asciidoc-hl.xml @@ -5,37 +5,37 @@ Syntax highlighting definition for AsciiDoc files --> - - //// - //// - - - // - - - - ^(={1,6} .+)$ - - MULTILINE - - - ^(\.[^\.\s].+)$ - - MULTILINE - - - ^(:!?\w.*?:) - - MULTILINE - - - ^(-|\*{1,5}|\d*\.{1,5})(?= .+$) - - MULTILINE - - - ^(\[.+\])$ - - MULTILINE - + + //// + //// + + + // + + + + ^(={1,6} .+)$ + + MULTILINE + + + ^(\.[^\.\s].+)$ + + MULTILINE + + + ^(:!?\w.*?:) + + MULTILINE + + + ^(-|\*{1,5}|\d*\.{1,5})(?= .+$) + + MULTILINE + + + ^(\[.+\])$ + + MULTILINE + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/bourne-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/bourne-hl.xml index e2cd98d8..518fdb86 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/bourne-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/bourne-hl.xml @@ -31,8 +31,8 @@ freely, subject to the following restrictions: ' " - - - + + " @@ -41,16 +41,16 @@ freely, subject to the following restrictions: ' \ - + 0x - + . - - + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/c-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/c-hl.xml index 176cc379..0c994db7 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/c-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/c-hl.xml @@ -46,7 +46,7 @@ Michiel Hendriks # \ - + " @@ -62,18 +62,18 @@ Michiel Hendriks lu u l - + . - + e ul lu u f l - + auto diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/cpp-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/cpp-hl.xml index ef83c4f5..a9f7d0de 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/cpp-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/cpp-hl.xml @@ -64,18 +64,18 @@ Michiel Hendriks lu u l - + . - + e ul lu u f l - + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/csharp-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/csharp-hl.xml index d57e6310..e21a1258 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/csharp-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/csharp-hl.xml @@ -62,7 +62,7 @@ Michiel Hendriks @" " \ - + " @@ -78,11 +78,11 @@ Michiel Hendriks lu u l - + . - + e ul lu @@ -91,7 +91,7 @@ Michiel Hendriks d m l - + abstract diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/css-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/css-hl.xml index 164c48c3..e5a14286 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/css-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/css-hl.xml @@ -30,147 +30,147 @@ Reference: http://www.w3.org/TR/CSS21/propidx.html --> - - /* - */ - - + + /* + */ + + " - \ - - - + \ + + + ' \ - - - - . - - - - @charset - @import - @media - @page - - - - - - azimuth - background-attachment - background-color - background-image - background-position - background-repeat - background - border-collapse - border-color - border-spacing - border-style - border-top - border-right - border-bottom - border-left - border-top-color - border-right-color - border-bottom-color - border-left-color - border-top-style - border-right-style - border-bottom-style - border-left-style - border-top-width - border-right-width - border-bottom-width - border-left-width - border-width - border - bottom - caption-side - clear - clip - color - content - counter-increment - counter-reset - cue-after - cue-before - cue - cursor - direction - display - elevation - empty-cells - float - font-family - font-size - font-style - font-variant - font-weight - font - height - left - letter-spacing - line-height - list-style-image - list-style-position - list-style-type - list-style - margin-right - margin-left - margin-top - margin-bottom - margin - max-height - max-width - min-height - min-width - orphans - outline-color - outline-style - outline-width - outline - overflow - padding-top - padding-right - padding-bottom - padding-left - padding - page-break-after - page-break-before - page-break-inside - pause-after - pause-before - pause - pitch-range - pitch - play-during - position - quotes - richness - right - speak-header - speak-numeral - speak-punctuation - speak - speech-rate - stress - table-layout - text-align - text-decoration - text-indent - text-transform - top - unicode-bidi - vertical-align - visibility - voice-family - volume - white-space - widows - width - word-spacing - z-index - + + + + . + + + + @charset + @import + @media + @page + + + + - + azimuth + background-attachment + background-color + background-image + background-position + background-repeat + background + border-collapse + border-color + border-spacing + border-style + border-top + border-right + border-bottom + border-left + border-top-color + border-right-color + border-bottom-color + border-left-color + border-top-style + border-right-style + border-bottom-style + border-left-style + border-top-width + border-right-width + border-bottom-width + border-left-width + border-width + border + bottom + caption-side + clear + clip + color + content + counter-increment + counter-reset + cue-after + cue-before + cue + cursor + direction + display + elevation + empty-cells + float + font-family + font-size + font-style + font-variant + font-weight + font + height + left + letter-spacing + line-height + list-style-image + list-style-position + list-style-type + list-style + margin-right + margin-left + margin-top + margin-bottom + margin + max-height + max-width + min-height + min-width + orphans + outline-color + outline-style + outline-width + outline + overflow + padding-top + padding-right + padding-bottom + padding-left + padding + page-break-after + page-break-before + page-break-inside + pause-after + pause-before + pause + pitch-range + pitch + play-during + position + quotes + richness + right + speak-header + speak-numeral + speak-punctuation + speak + speech-rate + stress + table-layout + text-align + text-decoration + text-indent + text-transform + top + unicode-bidi + vertical-align + visibility + voice-family + volume + white-space + widows + width + word-spacing + z-index + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/html-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/html-hl.xml index 5b6761ba..fd48f118 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/html-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/html-hl.xml @@ -10,113 +10,113 @@ This file has been customized for the Asciidoctor project (http://asciidoctor.org). --> - - - - a - abbr - address - area - article - aside - audio - b - base - bdi - blockquote - body - br - button - caption - canvas - cite - code - command - col - colgroup - dd - del - dialog - div - dl - dt - em - embed - fieldset - figcaption - figure - font - form - footer - h1 - h2 - h3 - h4 - h5 - h6 - head - header - hr - html - i - iframe - img - input - ins - kbd - label - legend - li - link - map - mark - menu - menu - meta - nav - noscript - object - ol - optgroup - option - p - param - pre - q - samp - script - section - select - small - source - span - strong - style - sub - summary - sup - table - tbody - td - textarea - tfoot - th - thead - time - title - tr - track - u - ul - var - video - wbr - xmp - - - - - xsl: - - + + + + a + abbr + address + area + article + aside + audio + b + base + bdi + blockquote + body + br + button + caption + canvas + cite + code + command + col + colgroup + dd + del + dialog + div + dl + dt + em + embed + fieldset + figcaption + figure + font + form + footer + h1 + h2 + h3 + h4 + h5 + h6 + head + header + hr + html + i + iframe + img + input + ins + kbd + label + legend + li + link + map + mark + menu + menu + meta + nav + noscript + object + ol + optgroup + option + p + param + pre + q + samp + script + section + select + small + source + span + strong + style + sub + summary + sup + table + tbody + td + textarea + tfoot + th + thead + time + title + tr + track + u + ul + var + video + wbr + xmp + + + + + xsl: + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/java-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/java-hl.xml index f7bb1641..96ef3da7 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/java-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/java-hl.xml @@ -54,7 +54,7 @@ Michiel Hendriks 0x - + . @@ -62,7 +62,7 @@ Michiel Hendriks f d l - + abstract diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/javascript-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/javascript-hl.xml index 99b8a71e..f74807f3 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/javascript-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/javascript-hl.xml @@ -44,12 +44,12 @@ Michiel Hendriks 0x - + . e - + break diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/json-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/json-hl.xml index 59b9c481..c13923c2 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/json-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/json-hl.xml @@ -20,7 +20,7 @@ f d l - + true diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/perl-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/perl-hl.xml index 73d71cc0..adf7b094 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/perl-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/perl-hl.xml @@ -47,12 +47,12 @@ Michiel Hendriks 0x - + . - - + + if diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/php-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/php-hl.xml index 1da25b8c..1060ae4d 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/php-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/php-hl.xml @@ -47,24 +47,24 @@ Michiel Hendriks " \ - + ' \ - + <<< 0x - + . e - + and @@ -142,7 +142,7 @@ Michiel Hendriks __NAMESPACE__ goto __DIR__ - + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/python-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/python-hl.xml index a4674432..fd6db57b 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/python-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/python-hl.xml @@ -38,11 +38,11 @@ Michiel Hendriks # """ - + ''' - + " @@ -55,14 +55,14 @@ Michiel Hendriks 0x l - + . - + e l - + and diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/ruby-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/ruby-hl.xml index d105640e..5bf3473d 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/ruby-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/ruby-hl.xml @@ -59,12 +59,12 @@ Michiel Hendriks 0x - + . e - + alias diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/sql2003-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/sql2003-hl.xml index ac1d5d04..bb561c64 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/sql2003-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/sql2003-hl.xml @@ -32,36 +32,36 @@ freely, subject to the following restrictions: ' - + U' ' - + B' ' - + N' ' - + X' ' - + . - + e - + - + A ABS diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/yaml-hl.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/yaml-hl.xml index a28008ec..e678bad6 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/yaml-hl.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/docs/src/main/docbook/xsl/xslthl/yaml-hl.xml @@ -20,7 +20,7 @@ f d l - + true diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/pom.xml index 63c6a454..74d8f0b1 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/pom.xml @@ -1,5 +1,5 @@ - 4.0.0 org.springframework.cloud @@ -57,21 +57,21 @@ Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 -Copyright 2014-2015 the original author or authors. + Copyright 2014-2015 the original author or authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. -See the License for the specific language governing permissions and -limitations under the License. + See the License for the specific language governing permissions and + limitations under the License. @@ -275,33 +275,33 @@ limitations under the License. false - - org.apache.maven.plugins - maven-checkstyle-plugin - ${checkstyle.version} - - - org.springframework.cloud - spring-cloud-build-tools - ${spring-cloud-build.version} - - - - checkstyle.xml - LICENSE.txt - true - true - - - - validate - validate - - check - - - - + + org.apache.maven.plugins + maven-checkstyle-plugin + ${checkstyle.version} + + + org.springframework.cloud + spring-cloud-build-tools + ${spring-cloud-build.version} + + + + checkstyle.xml + LICENSE.txt + true + true + + + + validate + validate + + check + + + + pl.project13.maven git-commit-id-plugin @@ -317,7 +317,8 @@ limitations under the License. true yyyy-MM-dd'T'HH:mm:ssZ true - ${project.build.outputDirectory}/git.properties + ${project.build.outputDirectory}/git.properties + @@ -370,17 +371,22 @@ limitations under the License. - + META-INF/spring.handlers - + META-INF/spring.factories - + META-INF/spring.schemas - - + + ${start-class} @@ -445,7 +451,9 @@ limitations under the License. https://github.com/spring-cloud spring-docs - scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} + + scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} + sonatype-nexus-staging @@ -756,7 +764,8 @@ limitations under the License. ${docs.resources.dir}/docbook/xsl/pdf.xsl 1 1 - ${docs.resources.dir}/docbook/xsl/xslthl-config.xml + ${docs.resources.dir}/docbook/xsl/xslthl-config.xml + @@ -781,20 +790,21 @@ limitations under the License. prepare-package - ${docs.resources.dir}/docbook/xsl/html-singlepage.xsl + ${docs.resources.dir}/docbook/xsl/html-singlepage.xsl + ${basedir}/target/docbook/htmlsingle - + - - - - + + + + @@ -807,7 +817,8 @@ limitations under the License. prepare-package - ${docs.resources.dir}/docbook/xsl/html-multipage.xsl + ${docs.resources.dir}/docbook/xsl/html-multipage.xsl + ${basedir}/target/docbook/html multi_ @@ -815,15 +826,15 @@ limitations under the License. - + - - - - + + + + @@ -916,19 +927,19 @@ limitations under the License. -:nofooter: -:linkcss: -:stylesdir: css -:stylesheet: manual-singlepage.css + :nofooter: + :linkcss: + :stylesdir: css + :stylesheet: manual-singlepage.css -= {docs-main} + = {docs-main} -{spring-cloud-version} + {spring-cloud-version} -== Pick The Documentation Option + == Pick The Documentation Option -- link:single/{docs-main}.html[Single HTML] -- link:multi/multi_{docs-main}.html[Multi HTML] + - link:single/{docs-main}.html[Single HTML] + - link:multi/multi_{docs-main}.html[Multi HTML] @@ -964,22 +975,22 @@ limitations under the License. + replace="\1"/> + replace="MILESTONE"/> + replace="MILESTONE"/> + replace="SNAPSHOT"/> + input="${github-tag}" regexp=".*SNAPSHOT" replace="master"/> diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-dependencies/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-dependencies/pom.xml index 17e2ccf4..53350938 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-dependencies/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-dependencies/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 org.springframework.cloud @@ -8,7 +8,9 @@ 1.3.7.BUILD-SNAPSHOT spring-cloud-build-tools pom - Spring Cloud Build Dependencies: an internal BOM for use with Spring Cloud projects. Use as a BOM or by inheriting from the spring-cloud build parent. + Spring Cloud Build Dependencies: an internal BOM for use with Spring Cloud projects. Use as a BOM or by + inheriting from the spring-cloud build parent. + org.springframework.boot spring-boot-dependencies @@ -43,8 +45,9 @@ https://github.com/spring-cloud spring-docs - scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} - + + scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} + repo.spring.io diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-tools/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-tools/pom.xml index 118a963f..8eb86045 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-tools/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-tools/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 org.springframework.cloud @@ -20,5 +20,5 @@ 7.6 - + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-tools/src/main/resources/checkstyle.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-tools/src/main/resources/checkstyle.xml index 79233ddb..8cb5aed3 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-tools/src/main/resources/checkstyle.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-build-tools/src/main/resources/checkstyle.xml @@ -15,10 +15,10 @@ - + - + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-dependencies-parent/eclipse-code-formatter.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-dependencies-parent/eclipse-code-formatter.xml index b6057671..1a73d56f 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-dependencies-parent/eclipse-code-formatter.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-dependencies-parent/eclipse-code-formatter.xml @@ -1,296 +1,398 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-dependencies-parent/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-dependencies-parent/pom.xml index 748525c5..379566d5 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-dependencies-parent/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-build/spring-cloud-dependencies-parent/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud 1.3.7.BUILD-SNAPSHOT @@ -18,21 +18,21 @@ Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 -Copyright 2014-2015 the original author or authors. + Copyright 2014-2015 the original author or authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. -See the License for the specific language governing permissions and -limitations under the License. + See the License for the specific language governing permissions and + limitations under the License. @@ -74,8 +74,9 @@ limitations under the License. https://github.com/spring-cloud spring-docs - scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} - + + scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} + repo.spring.io diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/.gitignore b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/.gitignore index 8db262c5..bd9bb4ce 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/.gitignore +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/.gitignore @@ -13,4 +13,4 @@ _site/ *.ipr .factorypath *.swp -/consul \ No newline at end of file +/consul diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/pom.xml index 14e930a3..8b094250 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/spring-cloud-starter-consul/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/spring-cloud-starter-consul/pom.xml index 3fe60ad8..36326190 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/spring-cloud-starter-consul/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-consul/spring-cloud-starter-consul/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.mvn/jvm.config b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.mvn/jvm.config index 0e7dabef..23acc6ad 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.mvn/jvm.config +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.mvn/jvm.config @@ -1 +1 @@ --Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom \ No newline at end of file +-Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.mvn/wrapper/maven-wrapper.properties b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.mvn/wrapper/maven-wrapper.properties index 6637cedb..d60b0061 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.mvn/wrapper/maven-wrapper.properties +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,2 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip \ No newline at end of file +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.settings.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.settings.xml index 6c355129..6f542c94 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.settings.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.settings.xml @@ -1,66 +1,68 @@ - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - true - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - http://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - - + + + repo.spring.io + ${env.CI_DEPLOY_USERNAME} + ${env.CI_DEPLOY_PASSWORD} + + + + + + spring + + true + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + http://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.travis.yml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.travis.yml index 87c1ea4b..17d08479 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.travis.yml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/.travis.yml @@ -6,4 +6,4 @@ language: java before_install: - gem install asciidoctor script: -- ./mvnw clean install -P docs -q -U -Dmaven.test.redirectTestOutputToFile=true + - ./mvnw clean install -P docs -q -U -Dmaven.test.redirectTestOutputToFile=true diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/README.adoc b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/README.adoc index 19ece70a..64504e53 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/README.adoc +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/README.adoc @@ -82,4 +82,4 @@ and for Maven Central use $ mvn install -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). \ No newline at end of file +(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). diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/pom.xml index 608e99c0..34b696e2 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud spring-cloud-starter-docs diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/src/main/asciidoc/ghpages.sh b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/src/main/asciidoc/ghpages.sh index a51d13c3..d94feff7 100755 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/src/main/asciidoc/ghpages.sh +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/src/main/asciidoc/ghpages.sh @@ -327,4 +327,4 @@ build_docs_if_applicable retrieve_doc_properties stash_changes add_docs_from_target -checkout_previous_branch \ No newline at end of file +checkout_previous_branch diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/src/main/asciidoc/intro.adoc b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/src/main/asciidoc/intro.adoc index 5ae66a35..9a93848f 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/src/main/asciidoc/intro.adoc +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/docs/src/main/asciidoc/intro.adoc @@ -4,4 +4,4 @@ spring-cloud-dependencies POM to manage dependencies in Maven or Gradle. The release trains have names, not versions, to avoid confusion with the sub-projects. The names are an alphabetic sequence (so you can sort them chronologically) with names of London Tube -stations ("Angel" is the first release, "Brixton" is the second). \ No newline at end of file +stations ("Angel" is the first release, "Brixton" is the second). diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/pom.xml index 0946dce6..cde0f9b0 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 spring-cloud-starter-build pom @@ -11,7 +11,7 @@ org.springframework.cloud spring-cloud-build 1.2.2.RELEASE - + @@ -28,7 +28,7 @@ spring-cloud-dependencies spring-cloud-starter-parent - docs + docs diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-dependencies/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-dependencies/pom.xml index 749fbf3d..22efdba3 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-dependencies/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-dependencies/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud @@ -31,7 +31,7 @@ - + org.springframework.cloud spring-cloud-commons-dependencies diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-dependencies/src/main/resources/META-INF/spring.provides b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-dependencies/src/main/resources/META-INF/spring.provides index 3628be6e..7ab18867 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-dependencies/src/main/resources/META-INF/spring.provides +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-dependencies/src/main/resources/META-INF/spring.provides @@ -1 +1 @@ -provides: spring-cloud-config-client \ No newline at end of file +provides: spring-cloud-config-client diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-starter-parent/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-starter-parent/pom.xml index d0f0ae8c..d6ed10ac 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-starter-parent/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-starter-parent/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.boot @@ -37,8 +37,9 @@ https://github.com/spring-cloud spring-docs - scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} - + + scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} + repo.spring.io diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-starter-parent/src/main/resources/META-INF/spring.provides b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-starter-parent/src/main/resources/META-INF/spring.provides index 3628be6e..7ab18867 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-starter-parent/src/main/resources/META-INF/spring.provides +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release-with-snapshot/spring-cloud-starter-parent/src/main/resources/META-INF/spring.provides @@ -1 +1 @@ -provides: spring-cloud-config-client \ No newline at end of file +provides: spring-cloud-config-client diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/.settings.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/.settings.xml index 6c355129..6f542c94 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/.settings.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/.settings.xml @@ -1,66 +1,68 @@ - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - true - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - http://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - http://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - http://repo.spring.io/libs-milestone-local - - false - - - - - + + + repo.spring.io + ${env.CI_DEPLOY_USERNAME} + ${env.CI_DEPLOY_PASSWORD} + + + + + + spring + + true + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + http://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + http://repo.spring.io/libs-snapshot-local + + true + + + + spring-milestones + Spring Milestones + http://repo.spring.io/libs-milestone-local + + false + + + + + diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/.travis.yml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/.travis.yml index 87c1ea4b..17d08479 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/.travis.yml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/.travis.yml @@ -6,4 +6,4 @@ language: java before_install: - gem install asciidoctor script: -- ./mvnw clean install -P docs -q -U -Dmaven.test.redirectTestOutputToFile=true + - ./mvnw clean install -P docs -q -U -Dmaven.test.redirectTestOutputToFile=true diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/README.adoc b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/README.adoc index 19ece70a..64504e53 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/README.adoc +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/README.adoc @@ -82,4 +82,4 @@ and for Maven Central use $ mvn install -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). \ No newline at end of file +(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). diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/pom.xml index 34780916..7b7c7381 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud spring-cloud-starter-docs diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/src/main/asciidoc/ghpages.sh b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/src/main/asciidoc/ghpages.sh index a51d13c3..d94feff7 100755 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/src/main/asciidoc/ghpages.sh +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/src/main/asciidoc/ghpages.sh @@ -327,4 +327,4 @@ build_docs_if_applicable retrieve_doc_properties stash_changes add_docs_from_target -checkout_previous_branch \ No newline at end of file +checkout_previous_branch diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/src/main/asciidoc/intro.adoc b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/src/main/asciidoc/intro.adoc index 5ae66a35..9a93848f 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/src/main/asciidoc/intro.adoc +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/docs/src/main/asciidoc/intro.adoc @@ -4,4 +4,4 @@ spring-cloud-dependencies POM to manage dependencies in Maven or Gradle. The release trains have names, not versions, to avoid confusion with the sub-projects. The names are an alphabetic sequence (so you can sort them chronologically) with names of London Tube -stations ("Angel" is the first release, "Brixton" is the second). \ No newline at end of file +stations ("Angel" is the first release, "Brixton" is the second). diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/pom.xml index b4d75d7a..400e56d4 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 spring-cloud-starter-build pom @@ -11,7 +11,7 @@ org.springframework.cloud spring-cloud-build 1.3.1.BUILD-SNAPSHOT - + @@ -28,7 +28,7 @@ spring-cloud-dependencies spring-cloud-starter-parent - docs + docs diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/pom.xml index a136f9eb..febccf0c 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.cloud @@ -32,7 +32,7 @@ - + org.springframework.cloud spring-cloud-commons-dependencies diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/src/main/resources/META-INF/spring.provides b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/src/main/resources/META-INF/spring.provides index 3628be6e..7ab18867 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/src/main/resources/META-INF/spring.provides +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-dependencies/src/main/resources/META-INF/spring.provides @@ -1 +1 @@ -provides: spring-cloud-config-client \ No newline at end of file +provides: spring-cloud-config-client diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/pom.xml b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/pom.xml index 578e1504..4d82b00a 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/pom.xml +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/pom.xml @@ -1,6 +1,6 @@ - + 4.0.0 org.springframework.boot @@ -37,8 +37,9 @@ https://github.com/spring-cloud spring-docs - scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} - + + scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-cloud/docs/${project.artifactId}/${project.version} + repo.spring.io diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/src/main/resources/META-INF/spring.provides b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/src/main/resources/META-INF/spring.provides index 3628be6e..7ab18867 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/src/main/resources/META-INF/spring.provides +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-release/spring-cloud-starter-parent/src/main/resources/META-INF/spring.provides @@ -1 +1 @@ -provides: spring-cloud-config-client \ No newline at end of file +provides: spring-cloud-config-client diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-static-angel/current/index.html b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-static-angel/current/index.html index 8ee4dcbf..efef4293 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-static-angel/current/index.html +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-static-angel/current/index.html @@ -4,10 +4,11 @@ Page Redirection -If you are not redirected automatically, follow the link to latest release +If you are not redirected automatically, follow the link + to latest release diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-static/current/index.html b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-static/current/index.html index 8ee4dcbf..efef4293 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-static/current/index.html +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-static/current/index.html @@ -4,10 +4,11 @@ Page Redirection -If you are not redirected automatically, follow the link to latest release +If you are not redirected automatically, follow the link + to latest release diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Home.asciidoc b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Home.asciidoc index c8da8450..95165170 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Home.asciidoc +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Home.asciidoc @@ -25,4 +25,4 @@ See the following release notes for upgrade instructions and "new and noteworthy - link:Spring-Cloud-Edgware-Release-Notes[Edgware] -- link:Spring-Cloud-Finchley-Release-Notes[Finchley] \ No newline at end of file +- link:Spring-Cloud-Finchley-Release-Notes[Finchley] diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Spring-Cloud-Angel-Release-Notes.asciidoc b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Spring-Cloud-Angel-Release-Notes.asciidoc index a133b0ae..8c106ed2 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Spring-Cloud-Angel-Release-Notes.asciidoc +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Spring-Cloud-Angel-Release-Notes.asciidoc @@ -35,4 +35,4 @@ Spring Boot-style starter projects to ease dependency management for consumers o === Spring Cloud CLI Spring Boot CLI plugin for creating Spring Cloud component applications quickly in Groovy -Spring Cloud Angel builds on Spring Boot 1.2.x, and parts of it (notably the OAuth2 support that moved to Spring Boot) does not work with Spring Boot 1.3.x. \ No newline at end of file +Spring Cloud Angel builds on Spring Boot 1.2.x, and parts of it (notably the OAuth2 support that moved to Spring Boot) does not work with Spring Boot 1.3.x. diff --git a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Spring-Cloud-Brixton-Release-Notes.asciidoc b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Spring-Cloud-Brixton-Release-Notes.asciidoc index f14acbe8..1ac55f7c 100644 --- a/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Spring-Cloud-Brixton-Release-Notes.asciidoc +++ b/spring-cloud-release-tools-spring/src/test/resources/projects/spring-cloud-wiki/Spring-Cloud-Brixton-Release-Notes.asciidoc @@ -92,4 +92,4 @@ NOTE: There is still a `spring-cloud-netflix-hystrix-amqp` in the Brixton releas - 2016/11/24 - Sleuth version `1.0.11.RELEASE` https://github.com/spring-cloud/spring-cloud-sleuth/milestone/17?closed=1[(issues)] - 2016/11/23 - Config version `1.1.3.RELEASE` https://github.com/spring-cloud/spring-cloud-config/milestone/21?closed=1[(issues)] -Note: There was an XXE vulnerability in xstream (which is used by Eureka), so please upgrade to Brixton.SR7 to pull in the latest version of that library which fixed the issue (https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-3674). \ No newline at end of file +Note: There was an XXE vulnerability in xstream (which is used by Eureka), so please upgrade to Brixton.SR7 to pull in the latest version of that library which fixed the issue (https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-3674). diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml new file mode 100644 index 00000000..a978fad6 --- /dev/null +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + +