├── .cfignore ├── .gitattributes ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── CODE_OF_CONDUCT.adoc ├── CONTRIBUTING.adoc ├── LICENSE.txt ├── README.adoc ├── ci ├── images │ └── initializr-ci-image │ │ └── Dockerfile ├── parameters.yml ├── pipeline.yml ├── scripts │ ├── build-project.sh │ ├── common.sh │ ├── generate-release-notes.sh │ ├── promote.sh │ └── stage.sh └── tasks │ ├── build-pr-project.yml │ ├── build-project.yml │ ├── generate-release-notes.yml │ ├── promote.yml │ └── stage.yml ├── eclipse ├── eclipse-code-formatter.xml ├── org.eclipse.jdt.core.prefs └── org.eclipse.jdt.ui.prefs ├── initializr-actuator ├── pom.xml └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── spring │ │ │ └── initializr │ │ │ └── actuate │ │ │ ├── autoconfigure │ │ │ ├── InitializrActuatorEndpointsAutoConfiguration.java │ │ │ ├── InitializrMetricsAutoConfiguration.java │ │ │ └── InitializrStatsAutoConfiguration.java │ │ │ ├── info │ │ │ ├── BomRangesInfoContributor.java │ │ │ └── DependencyRangesInfoContributor.java │ │ │ ├── metric │ │ │ └── ProjectGenerationMetricsListener.java │ │ │ └── stat │ │ │ ├── ProjectGenerationStatPublisher.java │ │ │ ├── ProjectRequestDocument.java │ │ │ ├── ProjectRequestDocumentFactory.java │ │ │ └── StatsProperties.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── io │ │ └── spring │ │ └── initializr │ │ └── actuate │ │ ├── ActuatorIntegrationTests.java │ │ ├── autoconfigure │ │ ├── InitializrActuatorEndpointsAutoConfigurationTests.java │ │ ├── InitializrMetricsAutoConfigurationTests.java │ │ └── InitializrStatsAutoConfigurationTests.java │ │ ├── info │ │ ├── BomRangesInfoContributorTests.java │ │ └── DependencyRangesInfoContributorTests.java │ │ ├── metric │ │ └── ProjectGenerationMetricsListenerTests.java │ │ ├── stat │ │ ├── AbstractInitializrStatTests.java │ │ ├── MainControllerStatsIntegrationTests.java │ │ ├── ProjectGenerationStatPublisherTests.java │ │ ├── ProjectRequestDocumentFactoryTests.java │ │ └── StatsPropertiesTests.java │ │ └── test │ │ └── MetricsAssert.java │ └── resources │ ├── application-test-custom-stats.yml │ └── stat │ ├── request-invalid-dependencies.json │ ├── request-invalid-java-version.json │ ├── request-invalid-language.json │ ├── request-invalid-type.json │ ├── request-no-client.json │ └── request-simple.json ├── initializr-docs ├── pom.xml └── src │ ├── main │ ├── asciidoc │ │ ├── api-guide.adoc │ │ ├── configuration-format.adoc │ │ ├── configuration-guide.adoc │ │ ├── documentation-overview.adoc │ │ ├── images │ │ │ └── web-selected.png │ │ ├── index.adoc │ │ ├── metadata-format.adoc │ │ ├── user-guide.adoc │ │ └── using-the-stubs.adoc │ └── javadoc │ │ └── spring-javadoc.css │ └── test │ ├── java │ └── io │ │ └── spring │ │ └── initializr │ │ └── stub │ │ ├── ClientApplicationTests.java │ │ └── SampleApp.java │ └── resources │ └── logback-test.xml ├── initializr-generator ├── pom.xml └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── spring │ │ │ └── initializr │ │ │ ├── InitializrException.java │ │ │ ├── generator │ │ │ ├── BasicProjectRequest.java │ │ │ ├── BuildProperties.java │ │ │ ├── CommandLineHelpGenerator.java │ │ │ ├── InvalidProjectRequestException.java │ │ │ ├── ProjectFailedEvent.java │ │ │ ├── ProjectGeneratedEvent.java │ │ │ ├── ProjectGenerator.java │ │ │ ├── ProjectRequest.java │ │ │ ├── ProjectRequestEvent.java │ │ │ ├── ProjectRequestPostProcessor.java │ │ │ ├── ProjectRequestResolver.java │ │ │ └── ProjectResourceLocator.java │ │ │ ├── metadata │ │ │ ├── BillOfMaterials.java │ │ │ ├── DefaultMetadataElement.java │ │ │ ├── Defaultable.java │ │ │ ├── DependenciesCapability.java │ │ │ ├── Dependency.java │ │ │ ├── DependencyGroup.java │ │ │ ├── DependencyMetadata.java │ │ │ ├── DependencyMetadataProvider.java │ │ │ ├── Describable.java │ │ │ ├── InitializrConfiguration.java │ │ │ ├── InitializrMetadata.java │ │ │ ├── InitializrMetadataBuilder.java │ │ │ ├── InitializrMetadataCustomizer.java │ │ │ ├── InitializrMetadataProvider.java │ │ │ ├── InitializrProperties.java │ │ │ ├── InvalidInitializrMetadataException.java │ │ │ ├── Link.java │ │ │ ├── MetadataElement.java │ │ │ ├── Repository.java │ │ │ ├── ServiceCapability.java │ │ │ ├── ServiceCapabilityType.java │ │ │ ├── SimpleInitializrMetadataProvider.java │ │ │ ├── SingleSelectCapability.java │ │ │ ├── TextCapability.java │ │ │ ├── Type.java │ │ │ └── TypeCapability.java │ │ │ └── util │ │ │ ├── Agent.java │ │ │ ├── InvalidVersionException.java │ │ │ ├── TemplateRenderer.java │ │ │ ├── Version.java │ │ │ ├── VersionParser.java │ │ │ ├── VersionProperty.java │ │ │ └── VersionRange.java │ └── resources │ │ ├── project │ │ ├── gradle3 │ │ │ ├── gradle │ │ │ │ └── wrapper │ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── gradlew │ │ │ └── gradlew.bat │ │ ├── gradle4 │ │ │ ├── gradle │ │ │ │ └── wrapper │ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── gradlew │ │ │ └── gradlew.bat │ │ └── maven │ │ │ ├── mvnw │ │ │ ├── mvnw.cmd │ │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ │ └── templates │ │ ├── Application.groovy │ │ ├── Application.java │ │ ├── Application.kt │ │ ├── ApplicationTests.groovy │ │ ├── ApplicationTests.java │ │ ├── ApplicationTests.kt │ │ ├── ServletInitializer.groovy │ │ ├── ServletInitializer.java │ │ ├── ServletInitializer.kt │ │ ├── boot-cli-capabilities.txt │ │ ├── cli-capabilities.txt │ │ ├── curl-examples.txt │ │ ├── gitignore.tmpl │ │ ├── httpie-examples.txt │ │ ├── starter-build.gradle │ │ ├── starter-pom.xml │ │ └── starter-settings.gradle │ └── test │ ├── java │ └── io │ │ └── spring │ │ └── initializr │ │ ├── generator │ │ ├── AbstractProjectGeneratorTests.java │ │ ├── CommandLineHelpGeneratorTests.java │ │ ├── CustomProjectGeneratorTests.java │ │ ├── ProjectGeneratorBuildTests.java │ │ ├── ProjectGeneratorLanguageTests.java │ │ ├── ProjectGeneratorTests.java │ │ ├── ProjectRequestResolverTests.java │ │ └── ProjectRequestTests.java │ │ ├── metadata │ │ ├── BillOfMaterialsTests.java │ │ ├── DependenciesCapabilityTests.java │ │ ├── DependencyTests.java │ │ ├── InitializrConfigurationTests.java │ │ ├── InitializrMetadataBuilderTests.java │ │ ├── InitializrMetadataTests.java │ │ ├── LinkTests.java │ │ ├── SingleSelectCapabilityTests.java │ │ ├── TextCapabilityTests.java │ │ ├── TypeCapabilityTests.java │ │ └── TypeTests.java │ │ ├── test │ │ ├── generator │ │ │ ├── GradleBuildAssert.java │ │ │ ├── GradleSettingsAssert.java │ │ │ ├── PomAssert.java │ │ │ ├── ProjectAssert.java │ │ │ └── SourceCodeAssert.java │ │ └── metadata │ │ │ └── InitializrMetadataTestBuilder.java │ │ └── util │ │ ├── AgentTests.java │ │ ├── VersionParserTests.java │ │ ├── VersionPropertyTests.java │ │ ├── VersionRangeTests.java │ │ └── VersionTests.java │ └── resources │ ├── application-test-custom-defaults.yml │ ├── application-test-custom-env.yml │ ├── application-test-default.yml │ ├── application-test-ssl.yml │ ├── logback-test.xml │ ├── metadata │ ├── config │ │ ├── test-bom.json │ │ ├── test-min.json │ │ └── test-repository.json │ └── sagan │ │ ├── spring-boot-no-default.json │ │ └── spring-boot.json │ ├── project │ ├── custom │ │ └── custom.txt │ ├── gradle │ │ ├── annotation-processor-dependency-build.gradle.gen │ │ ├── bom-ordering-build.gradle.gen │ │ ├── bom-property-build.gradle.gen │ │ ├── compile-only-dependency-build.gradle.gen │ │ ├── gitignore.gen │ │ ├── kotlin-java11-build.gradle.gen │ │ ├── repositories-build.gradle.gen │ │ ├── repositories-milestone-build.gradle.gen │ │ └── version-override-build.gradle.gen │ ├── groovy │ │ ├── previous │ │ │ ├── DemoApplication.groovy.gen │ │ │ ├── ServletInitializer.groovy.gen │ │ │ ├── build.gradle.gen │ │ │ └── pom.xml.gen │ │ └── standard │ │ │ ├── DemoApplication.groovy.gen │ │ │ ├── DemoApplicationTests.groovy.gen │ │ │ ├── DemoApplicationTestsWeb.groovy.gen │ │ │ ├── ServletInitializer.groovy.gen │ │ │ ├── build.gradle.gen │ │ │ ├── pom.xml.gen │ │ │ ├── war-build.gradle.gen │ │ │ └── war-pom.xml.gen │ ├── java │ │ ├── previous │ │ │ ├── DemoApplication.java.gen │ │ │ ├── ServletInitializer.java.gen │ │ │ ├── build.gradle.gen │ │ │ └── pom.xml.gen │ │ └── standard │ │ │ ├── DemoApplication.java.gen │ │ │ ├── DemoApplicationTests.java.gen │ │ │ ├── DemoApplicationTestsWeb.java.gen │ │ │ ├── ServletInitializer.java.gen │ │ │ ├── build.gradle.gen │ │ │ ├── pom.xml.gen │ │ │ ├── war-build.gradle.gen │ │ │ └── war-pom.xml.gen │ ├── kotlin │ │ ├── previous │ │ │ ├── DemoApplication.kt.gen │ │ │ ├── ServletInitializer.kt.gen │ │ │ ├── build.gradle.gen │ │ │ └── pom.xml.gen │ │ └── standard │ │ │ ├── DemoApplication.kt.gen │ │ │ ├── DemoApplicationTests.kt.gen │ │ │ ├── DemoApplicationTestsWeb.kt.gen │ │ │ ├── ServletInitializer.kt.gen │ │ │ ├── build.gradle.gen │ │ │ ├── pom.xml.gen │ │ │ ├── war-build.gradle.gen │ │ │ └── war-pom.xml.gen │ └── maven │ │ ├── annotation-processor-dependency-pom.xml.gen │ │ ├── bom-ordering-pom.xml.gen │ │ ├── bom-property-pom.xml.gen │ │ ├── compile-only-dependency-pom.xml.gen │ │ ├── gitignore.gen │ │ ├── kotlin-java11-pom.xml.gen │ │ ├── repositories-milestone-pom.xml.gen │ │ ├── repositories-pom.xml.gen │ │ └── version-override-pom.xml.gen │ └── templates │ └── custom.txt ├── initializr-web ├── pom.xml └── src │ ├── assembly │ ├── snippets.xml │ └── stub.xml │ ├── main │ ├── java │ │ └── io │ │ │ └── spring │ │ │ └── initializr │ │ │ └── web │ │ │ ├── autoconfigure │ │ │ ├── CloudfoundryEnvironmentPostProcessor.java │ │ │ ├── InitializrAutoConfiguration.java │ │ │ └── InitializrWebConfig.java │ │ │ ├── mapper │ │ │ ├── DependencyMetadataJsonMapper.java │ │ │ ├── DependencyMetadataV21JsonMapper.java │ │ │ ├── InitializrMetadataJsonMapper.java │ │ │ ├── InitializrMetadataV21JsonMapper.java │ │ │ ├── InitializrMetadataV2JsonMapper.java │ │ │ ├── InitializrMetadataVersion.java │ │ │ └── LinkMapper.java │ │ │ ├── project │ │ │ ├── AbstractInitializrController.java │ │ │ └── MainController.java │ │ │ ├── support │ │ │ ├── DefaultDependencyMetadataProvider.java │ │ │ ├── DefaultInitializrMetadataProvider.java │ │ │ └── SpringBootMetadataReader.java │ │ │ └── ui │ │ │ └── UiController.java │ └── resources │ │ ├── META-INF │ │ └── spring.factories │ │ ├── static │ │ ├── config.json │ │ ├── css │ │ │ ├── bootstrap-sts.min.css │ │ │ ├── bootstrap-theme.min.css │ │ │ ├── bootstrap.min.css │ │ │ └── spring.css │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── img │ │ │ ├── favicon.png │ │ │ └── platform-bg.png │ │ ├── install.sh │ │ └── js │ │ │ ├── jquery-3.1.1.min.js │ │ │ ├── mousetrap.min.js │ │ │ ├── start.js │ │ │ └── typeahead.bundle.min.js │ │ └── templates │ │ ├── gs.mustache │ │ └── home.mustache │ └── test │ ├── java │ └── io │ │ └── spring │ │ └── initializr │ │ └── web │ │ ├── AbstractFullStackInitializrIntegrationTests.java │ │ ├── AbstractInitializrControllerIntegrationTests.java │ │ ├── AbstractInitializrIntegrationTests.java │ │ ├── autoconfigure │ │ ├── CloudfoundryEnvironmentPostProcessorTests.java │ │ └── InitializrAutoConfigurationTests.java │ │ ├── mapper │ │ ├── DependencyMetadataJsonMapperTests.java │ │ ├── InitializrMetadataJsonMapperTests.java │ │ └── LinkMapperTests.java │ │ ├── project │ │ ├── CommandLineExampleIntegrationTests.java │ │ ├── HomePage.java │ │ ├── MainControllerDefaultsIntegrationTests.java │ │ ├── MainControllerDependenciesTests.java │ │ ├── MainControllerEnvIntegrationTests.java │ │ ├── MainControllerIntegrationTests.java │ │ ├── MainControllerServiceMetadataIntegrationTests.java │ │ ├── MainControllerSslIntegrationTests.java │ │ ├── ProjectGenerationPostProcessorTests.java │ │ └── ProjectGenerationSmokeTests.java │ │ ├── support │ │ ├── DefaultDependencyMetadataProviderTests.java │ │ ├── DefaultInitializrMetadataProviderTests.java │ │ └── SpringBootMetadataReaderTests.java │ │ ├── test │ │ ├── JsonFieldPath.java │ │ ├── JsonFieldProcessor.java │ │ ├── MockMvcClientHttpRequestFactory.java │ │ ├── MockMvcClientHttpRequestFactoryTestExecutionListener.java │ │ └── ResponseFieldSnippet.java │ │ └── ui │ │ └── UiControllerIntegrationTests.java │ └── resources │ ├── metadata │ ├── config │ │ └── test-default.json │ ├── dependencies │ │ ├── test-dependencies-2.1.4.json │ │ └── test-dependencies-2.2.1.json │ ├── test-default-2.0.0-ssl.json │ ├── test-default-2.0.0.json │ ├── test-default-2.1.0-ssl.json │ ├── test-default-2.1.0.json │ └── ui │ │ ├── test-dependencies-1.1.2.json │ │ └── test-dependencies-all.json │ └── org │ └── springframework │ └── restdocs │ └── templates │ └── asciidoctor │ └── default-response-fields.snippet ├── mvnw ├── mvnw.cmd └── pom.xml /.cfignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | *.sw? 3 | .#* 4 | *# 5 | *~ 6 | .classpath 7 | .project 8 | .settings 9 | build 10 | target 11 | .springBeans 12 | tmp* 13 | spring.zip 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | !.mvn/wrapper/maven-wrapper.jar 2 | .flattened-pom.xml 3 | .gradle 4 | *.sw? 5 | .#* 6 | *# 7 | *~ 8 | .classpath 9 | .project 10 | .settings 11 | .gitignore 12 | .idea 13 | .factorypath 14 | *.iml 15 | bin 16 | build 17 | target 18 | .springBeans 19 | .vscode/ 20 | .sts4-cache/ 21 | tmp* 22 | grapes 23 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.adoc: -------------------------------------------------------------------------------- 1 | = Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of fostering an open 4 | and welcoming community, we pledge to respect all people who contribute through reporting 5 | issues, posting feature requests, updating documentation, submitting pull requests or 6 | patches, and other activities. 7 | 8 | We are committed to making participation in this project a harassment-free experience for 9 | everyone, regardless of level of experience, gender, gender identity and expression, 10 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, 11 | religion, or nationality. 12 | 13 | Examples of unacceptable behavior by participants include: 14 | 15 | * The use of sexualized language or imagery 16 | * Personal attacks 17 | * Trolling or insulting/derogatory comments 18 | * Public or private harassment 19 | * Publishing other's private information, such as physical or electronic addresses, 20 | without explicit permission 21 | * Other unethical or unprofessional conduct 22 | 23 | Project maintainers have the right and responsibility to remove, edit, or reject comments, 24 | commits, code, wiki edits, issues, and other contributions that are not aligned to this 25 | Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors 26 | that they deem inappropriate, threatening, offensive, or harmful. 27 | 28 | By adopting this Code of Conduct, project maintainers commit themselves to fairly and 29 | consistently applying these principles to every aspect of managing this project. Project 30 | maintainers who do not follow or enforce the Code of Conduct may be permanently removed 31 | from the project team. 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an 34 | individual is representing the project or its community. 35 | 36 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 37 | contacting a project maintainer at spring-code-of-conduct@pivotal.io . All complaints will 38 | be reviewed and investigated and will result in a response that is deemed necessary and 39 | appropriate to the circumstances. Maintainers are obligated to maintain confidentiality 40 | with regard to the reporter of an incident. 41 | 42 | This Code of Conduct is adapted from the 43 | http://contributor-covenant.org[Contributor Covenant], version 1.3.0, available at 44 | http://contributor-covenant.org/version/1/3/0/[contributor-covenant.org/version/1/3/0/] -------------------------------------------------------------------------------- /ci/images/initializr-ci-image/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic-20181018 2 | 3 | ENV JAVA_HOME /opt/openjdk 4 | ENV PATH $JAVA_HOME/bin:$PATH 5 | RUN apt-get update && \ 6 | apt-get install --no-install-recommends -y ca-certificates net-tools libxml2-utils git curl libudev1 libxml2-utils iptables iproute2 jq 7 | RUN mkdir -p /opt/openjdk && \ 8 | cd /opt/openjdk && \ 9 | curl https://java-buildpack.cloudfoundry.org/openjdk/bionic/x86_64/openjdk-1.8.0_192.tar.gz | tar xz 10 | 11 | ADD https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.2/concourse-java.sh /opt/ -------------------------------------------------------------------------------- /ci/parameters.yml: -------------------------------------------------------------------------------- 1 | github-repo: "https://github.com/spring-io/initializr.git" 2 | github-repo-name: "spring-io/initializr" 3 | docker-hub-organization: "springci" 4 | artifactory-server: "https://repo.spring.io" 5 | branch: "master" 6 | build-name: "initializr" 7 | pipeline-name: "initializr" 8 | concourse-url: "https://ci.spring.io" 9 | -------------------------------------------------------------------------------- /ci/scripts/build-project.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | source $(dirname $0)/common.sh 5 | repository=$(pwd)/distribution-repository 6 | 7 | pushd git-repo > /dev/null 8 | ./mvnw clean deploy -U -Pfull -DaltDeploymentRepository=distribution::default::file://${repository} 9 | popd > /dev/null 10 | -------------------------------------------------------------------------------- /ci/scripts/common.sh: -------------------------------------------------------------------------------- 1 | source /opt/concourse-java.sh 2 | 3 | setup_symlinks 4 | cleanup_maven_repo "io.spring.initializr" 5 | -------------------------------------------------------------------------------- /ci/scripts/generate-release-notes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | version=$( cat version/version ) 5 | 6 | milestone=${version%.RELEASE} 7 | 8 | java -jar /github-release-notes-generator.jar \ 9 | --releasenotes.github.username=${GITHUB_USERNAME} \ 10 | --releasenotes.github.password=${GITHUB_TOKEN} \ 11 | --releasenotes.github.organization=${GITHUB_ORGANIZATION} \ 12 | --releasenotes.github.repository=${GITHUB_REPO} \ 13 | ${milestone} generated-release-notes/release-notes.md 14 | 15 | echo ${version} > generated-release-notes/version 16 | echo v${version} > generated-release-notes/tag 17 | -------------------------------------------------------------------------------- /ci/scripts/promote.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | source $(dirname $0)/common.sh 5 | 6 | buildName=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.name' ) 7 | buildNumber=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.number' ) 8 | groupId=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' ) 9 | version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) 10 | 11 | targetRepo="libs-release-local" 12 | 13 | echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}" 14 | 15 | curl \ 16 | -s \ 17 | --connect-timeout 240 \ 18 | --max-time 900 \ 19 | -u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \ 20 | -H "Content-type:application/json" \ 21 | -d "{\"status\": \"staged\", \"sourceRepo\": \"libs-staging-local\", \"targetRepo\": \"${targetRepo}\"}" \ 22 | -f \ 23 | -X \ 24 | POST "${ARTIFACTORY_SERVER}/api/build/promote/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to promote" >&2; exit 1; } 25 | 26 | echo "Promotion complete" 27 | echo $version > version/version -------------------------------------------------------------------------------- /ci/scripts/stage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | source $(dirname $0)/common.sh 5 | repository=$(pwd)/distribution-repository 6 | 7 | pushd git-repo > /dev/null 8 | git fetch --tags --all > /dev/null 9 | popd > /dev/null 10 | 11 | git clone git-repo stage-git-repo > /dev/null 12 | 13 | pushd stage-git-repo > /dev/null 14 | 15 | snapshotVersion=$( get_revision_from_pom ) 16 | stageVersion=$( get_next_release $snapshotVersion) 17 | nextVersion=$( bump_version_number $snapshotVersion) 18 | echo "Staging $stageVersion (next version will be $nextVersion)" 19 | 20 | set_revision_to_pom "$stageVersion" 21 | git config user.name "Spring Buildmaster" > /dev/null 22 | git config user.email "buildmaster@springframework.org" > /dev/null 23 | git add pom.xml > /dev/null 24 | git commit -m"Release v$stageVersion" > /dev/null 25 | git tag -a "v$stageVersion" -m"Release v$stageVersion" > /dev/null 26 | 27 | ./mvnw clean deploy -U -Pfull -DaltDeploymentRepository=distribution::default::file://${repository} 28 | 29 | git reset --hard HEAD^ > /dev/null 30 | if [[ $nextVersion != $snapshotVersion ]]; then 31 | echo "Setting next development version (v$nextVersion)" 32 | set_revision_to_pom "$nextVersion" 33 | git add pom.xml > /dev/null 34 | git commit -m"Next development version (v$nextVersion)" > /dev/null 35 | fi; 36 | 37 | echo "DONE" 38 | 39 | popd > /dev/null 40 | -------------------------------------------------------------------------------- /ci/tasks/build-pr-project.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | inputs: 4 | - name: git-repo 5 | outputs: 6 | - name: distribution-repository 7 | caches: 8 | - path: maven 9 | run: 10 | path: git-repo/ci/scripts/build-project.sh -------------------------------------------------------------------------------- /ci/tasks/build-project.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | inputs: 4 | - name: git-repo 5 | outputs: 6 | - name: distribution-repository 7 | caches: 8 | - path: maven 9 | run: 10 | path: git-repo/ci/scripts/build-project.sh 11 | -------------------------------------------------------------------------------- /ci/tasks/generate-release-notes.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | image_resource: 4 | type: docker-image 5 | source: 6 | repository: springio/github-release-notes-generator 7 | tag: '0.0.2' 8 | inputs: 9 | - name: git-repo 10 | - name: version 11 | outputs: 12 | - name: generated-release-notes 13 | params: 14 | GITHUB_ORGANIZATION: 15 | GITHUB_REPO: 16 | GITHUB_USERNAME: 17 | GITHUB_TOKEN: 18 | run: 19 | path: git-repo/ci/scripts/generate-release-notes.sh -------------------------------------------------------------------------------- /ci/tasks/promote.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | inputs: 4 | - name: git-repo 5 | - name: artifactory-repo 6 | outputs: 7 | - name: version 8 | params: 9 | ARTIFACTORY_SERVER: 10 | ARTIFACTORY_USERNAME: 11 | ARTIFACTORY_PASSWORD: 12 | run: 13 | path: git-repo/ci/scripts/promote.sh 14 | -------------------------------------------------------------------------------- /ci/tasks/stage.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | inputs: 4 | - name: git-repo 5 | outputs: 6 | - name: stage-git-repo 7 | - name: distribution-repository 8 | caches: 9 | - path: maven 10 | run: 11 | path: git-repo/ci/scripts/stage.sh 12 | -------------------------------------------------------------------------------- /initializr-actuator/src/main/java/io/spring/initializr/actuate/autoconfigure/InitializrActuatorEndpointsAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.actuate.autoconfigure; 18 | 19 | import io.spring.initializr.actuate.info.BomRangesInfoContributor; 20 | import io.spring.initializr.actuate.info.DependencyRangesInfoContributor; 21 | import io.spring.initializr.metadata.InitializrMetadataProvider; 22 | 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.context.annotation.Configuration; 25 | 26 | /** 27 | * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration 28 | * Auto-configuration} to improve actuator endpoints with initializr specific information. 29 | * 30 | * @author Stephane Nicoll 31 | */ 32 | @Configuration 33 | public class InitializrActuatorEndpointsAutoConfiguration { 34 | 35 | @Bean 36 | public BomRangesInfoContributor bomRangesInfoContributor( 37 | InitializrMetadataProvider metadataProvider) { 38 | return new BomRangesInfoContributor(metadataProvider); 39 | } 40 | 41 | @Bean 42 | public DependencyRangesInfoContributor dependencyRangesInfoContributor( 43 | InitializrMetadataProvider metadataProvider) { 44 | return new DependencyRangesInfoContributor(metadataProvider); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /initializr-actuator/src/main/java/io/spring/initializr/actuate/autoconfigure/InitializrMetricsAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.actuate.autoconfigure; 18 | 19 | import io.micrometer.core.instrument.MeterRegistry; 20 | import io.spring.initializr.actuate.metric.ProjectGenerationMetricsListener; 21 | 22 | import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration; 23 | import org.springframework.boot.autoconfigure.AutoConfigureAfter; 24 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 25 | import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; 26 | import org.springframework.context.annotation.Bean; 27 | import org.springframework.context.annotation.Configuration; 28 | 29 | /** 30 | * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration 31 | * Auto-configuration} to handle the metrics of an initializr instance. 32 | * 33 | * @author Dave Syer 34 | */ 35 | @Configuration 36 | @ConditionalOnClass(MeterRegistry.class) 37 | @AutoConfigureAfter(CompositeMeterRegistryAutoConfiguration.class) 38 | public class InitializrMetricsAutoConfiguration { 39 | 40 | @Bean 41 | @ConditionalOnSingleCandidate(MeterRegistry.class) 42 | public ProjectGenerationMetricsListener metricsListener(MeterRegistry meterRegistry) { 43 | return new ProjectGenerationMetricsListener(meterRegistry); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /initializr-actuator/src/main/java/io/spring/initializr/actuate/info/BomRangesInfoContributor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.actuate.info; 18 | 19 | import java.util.LinkedHashMap; 20 | import java.util.Map; 21 | 22 | import io.spring.initializr.metadata.InitializrMetadataProvider; 23 | 24 | import org.springframework.boot.actuate.info.Info; 25 | import org.springframework.boot.actuate.info.InfoContributor; 26 | 27 | /** 28 | * An {@link InfoContributor} that exposes the actual ranges used by each bom defined in 29 | * the project. 30 | * 31 | * @author Stephane Nicoll 32 | */ 33 | public class BomRangesInfoContributor implements InfoContributor { 34 | 35 | private final InitializrMetadataProvider metadataProvider; 36 | 37 | public BomRangesInfoContributor(InitializrMetadataProvider metadataProvider) { 38 | this.metadataProvider = metadataProvider; 39 | } 40 | 41 | @Override 42 | public void contribute(Info.Builder builder) { 43 | Map details = new LinkedHashMap<>(); 44 | this.metadataProvider.get().getConfiguration().getEnv().getBoms() 45 | .forEach((k, v) -> { 46 | if (v.getMappings() != null && !v.getMappings().isEmpty()) { 47 | Map bom = new LinkedHashMap<>(); 48 | v.getMappings().forEach((it) -> { 49 | String requirement = "Spring Boot " 50 | + it.determineVersionRangeRequirement(); 51 | bom.put(it.getVersion(), requirement); 52 | }); 53 | details.put(k, bom); 54 | } 55 | }); 56 | if (!details.isEmpty()) { 57 | builder.withDetail("bom-ranges", details); 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /initializr-actuator/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | io.spring.initializr.actuate.autoconfigure.InitializrActuatorEndpointsAutoConfiguration,\ 3 | io.spring.initializr.actuate.autoconfigure.InitializrStatsAutoConfiguration,\ 4 | io.spring.initializr.actuate.autoconfigure.InitializrMetricsAutoConfiguration -------------------------------------------------------------------------------- /initializr-actuator/src/test/java/io/spring/initializr/actuate/autoconfigure/InitializrActuatorEndpointsAutoConfigurationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.actuate.autoconfigure; 18 | 19 | import io.spring.initializr.actuate.info.BomRangesInfoContributor; 20 | import io.spring.initializr.actuate.info.DependencyRangesInfoContributor; 21 | import io.spring.initializr.web.autoconfigure.InitializrAutoConfiguration; 22 | import org.junit.jupiter.api.Test; 23 | 24 | import org.springframework.boot.autoconfigure.AutoConfigurations; 25 | import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; 26 | import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; 27 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; 28 | 29 | import static org.assertj.core.api.Assertions.assertThat; 30 | 31 | /** 32 | * Tests for {@link InitializrActuatorEndpointsAutoConfiguration}. 33 | * 34 | * @author Madhura Bhave 35 | */ 36 | class InitializrActuatorEndpointsAutoConfigurationTests { 37 | 38 | private ApplicationContextRunner contextRunner = new ApplicationContextRunner() 39 | .withConfiguration(AutoConfigurations.of(JacksonAutoConfiguration.class, 40 | InitializrAutoConfiguration.class, 41 | RestTemplateAutoConfiguration.class, 42 | InitializrActuatorEndpointsAutoConfiguration.class)); 43 | 44 | @Test 45 | void autoConfigRegistersBomRangesInfoContributor() { 46 | this.contextRunner.run((context) -> assertThat(context) 47 | .hasSingleBean(BomRangesInfoContributor.class)); 48 | } 49 | 50 | @Test 51 | void autoConfigRegistersDependencyRangesInfoContributor() { 52 | this.contextRunner.run((context) -> assertThat(context) 53 | .hasSingleBean(DependencyRangesInfoContributor.class)); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /initializr-actuator/src/test/java/io/spring/initializr/actuate/autoconfigure/InitializrMetricsAutoConfigurationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.actuate.autoconfigure; 18 | 19 | import io.micrometer.core.instrument.MeterRegistry; 20 | import io.spring.initializr.actuate.metric.ProjectGenerationMetricsListener; 21 | import org.junit.jupiter.api.Test; 22 | 23 | import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration; 24 | import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; 25 | import org.springframework.boot.autoconfigure.AutoConfigurations; 26 | import org.springframework.boot.test.context.FilteredClassLoader; 27 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; 28 | 29 | import static org.assertj.core.api.Assertions.assertThat; 30 | 31 | /** 32 | * Tests for {@link InitializrMetricsAutoConfiguration}. 33 | * 34 | * @author Madhura Bhave 35 | */ 36 | class InitializrMetricsAutoConfigurationTests { 37 | 38 | private ApplicationContextRunner contextRunner = new ApplicationContextRunner() 39 | .withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class, 40 | CompositeMeterRegistryAutoConfiguration.class, 41 | InitializrMetricsAutoConfiguration.class)); 42 | 43 | @Test 44 | void autoConfigRegistersProjectGenerationMetricsListenerBean() { 45 | this.contextRunner.run((context) -> assertThat(context) 46 | .hasSingleBean(ProjectGenerationMetricsListener.class)); 47 | } 48 | 49 | @Test 50 | void autoConfigConditionalOnMeterRegistryClass() { 51 | this.contextRunner.withClassLoader(new FilteredClassLoader(MeterRegistry.class)) 52 | .run((context) -> assertThat(context) 53 | .doesNotHaveBean(ProjectGenerationMetricsListener.class)); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /initializr-actuator/src/test/java/io/spring/initializr/actuate/stat/AbstractInitializrStatTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.actuate.stat; 18 | 19 | import io.spring.initializr.generator.ProjectRequest; 20 | import io.spring.initializr.metadata.InitializrMetadata; 21 | import io.spring.initializr.metadata.InitializrMetadataProvider; 22 | import io.spring.initializr.metadata.SimpleInitializrMetadataProvider; 23 | import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder; 24 | 25 | /** 26 | * @author Stephane Nicoll 27 | */ 28 | abstract class AbstractInitializrStatTests { 29 | 30 | private final InitializrMetadata metadata = InitializrMetadataTestBuilder 31 | .withDefaults().addDependencyGroup("core", "security", "validation", "aop") 32 | .addDependencyGroup("web", "web", "data-rest", "jersey") 33 | .addDependencyGroup("data", "data-jpa", "jdbc") 34 | .addDependencyGroup("database", "h2", "mysql").build(); 35 | 36 | protected InitializrMetadataProvider createProvider(InitializrMetadata metadata) { 37 | return new SimpleInitializrMetadataProvider(metadata); 38 | } 39 | 40 | protected ProjectRequest createProjectRequest() { 41 | ProjectRequest request = new ProjectRequest(); 42 | request.initialize(this.metadata); 43 | return request; 44 | } 45 | 46 | public InitializrMetadata getMetadata() { 47 | return this.metadata; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /initializr-actuator/src/test/java/io/spring/initializr/actuate/stat/StatsPropertiesTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.actuate.stat; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | /** 24 | * Tests for {@link StatsProperties}. 25 | * 26 | * @author Stephane Nicoll 27 | */ 28 | class StatsPropertiesTests { 29 | 30 | private final StatsProperties properties = new StatsProperties(); 31 | 32 | @Test 33 | void cleanTrailingSlash() { 34 | this.properties.getElastic().setUri("http://example.com/"); 35 | assertThat(this.properties.getElastic().getUri()).isEqualTo("http://example.com"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /initializr-actuator/src/test/java/io/spring/initializr/actuate/test/MetricsAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.actuate.test; 18 | 19 | import java.util.Arrays; 20 | 21 | import io.micrometer.core.instrument.MeterRegistry; 22 | import io.micrometer.core.instrument.search.Search; 23 | 24 | import static org.assertj.core.api.Assertions.assertThat; 25 | 26 | /** 27 | * Metrics assertion based on {@link MeterRegistry}. 28 | * 29 | * @author Stephane Nicoll 30 | */ 31 | public class MetricsAssert { 32 | 33 | private final MeterRegistry meterRegistry; 34 | 35 | public MetricsAssert(MeterRegistry meterRegistry) { 36 | this.meterRegistry = meterRegistry; 37 | } 38 | 39 | public MetricsAssert hasValue(long value, String... metrics) { 40 | Arrays.asList(metrics).forEach( 41 | (metric) -> assertThat(this.meterRegistry.get(metric).counter().count()) 42 | .isEqualTo(value)); 43 | return this; 44 | } 45 | 46 | public MetricsAssert hasNoValue(String... metrics) { 47 | Arrays.asList(metrics).forEach((metric) -> assertThat( 48 | Search.in(this.meterRegistry).name((n) -> n.startsWith(metric)).counter()) 49 | .isNull()); 50 | return this; 51 | } 52 | 53 | public MetricsAssert metricsCount(int count) { 54 | assertThat(Search.in(this.meterRegistry).meters()).hasSize(count); 55 | return this; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /initializr-actuator/src/test/resources/application-test-custom-stats.yml: -------------------------------------------------------------------------------- 1 | initializr: 2 | stats: 3 | elastic: 4 | uri: http://localhost/elastic 5 | username: test-user 6 | password: test-password 7 | max-attempts: 1 -------------------------------------------------------------------------------- /initializr-actuator/src/test/resources/stat/request-invalid-dependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "generationTimestamp": 0, 3 | "type": "gradle-project", 4 | "buildSystem": "gradle", 5 | "groupId": "com.example.acme", 6 | "artifactId": "test", 7 | "javaVersion": "1.8", 8 | "language": "java", 9 | "packaging": "jar", 10 | "packageName": "com.example.acme.test", 11 | "version": { 12 | "id": "2.1.0.RELEASE", 13 | "major": "2", 14 | "minor": "2.1" 15 | }, 16 | "dependencies": { 17 | "id": "web", 18 | "values": [ 19 | "web" 20 | ], 21 | "count": 1 22 | }, 23 | "errorState": { 24 | "invalid": true, 25 | "dependencies": { 26 | "invalid": true, 27 | "values": [ 28 | "invalid-2", 29 | "invalid-1" 30 | ] 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /initializr-actuator/src/test/resources/stat/request-invalid-java-version.json: -------------------------------------------------------------------------------- 1 | { 2 | "generationTimestamp": 0, 3 | "type": "gradle-project", 4 | "buildSystem": "gradle", 5 | "groupId": "com.example.acme", 6 | "artifactId": "test", 7 | "javaVersion": "1.2", 8 | "language": "java", 9 | "packaging": "jar", 10 | "packageName": "com.example.acme.test", 11 | "version": { 12 | "id": "2.1.0.RELEASE", 13 | "major": "2", 14 | "minor": "2.1" 15 | }, 16 | "dependencies": { 17 | "id": "data-jpa web", 18 | "values": [ 19 | "web", 20 | "data-jpa" 21 | ], 22 | "count": 2 23 | }, 24 | "errorState": { 25 | "invalid": true, 26 | "javaVersion": true 27 | } 28 | } -------------------------------------------------------------------------------- /initializr-actuator/src/test/resources/stat/request-invalid-language.json: -------------------------------------------------------------------------------- 1 | { 2 | "generationTimestamp": 0, 3 | "type": "gradle-project", 4 | "buildSystem": "gradle", 5 | "groupId": "com.example.acme", 6 | "artifactId": "test", 7 | "javaVersion": "1.8", 8 | "language": "c", 9 | "packaging": "jar", 10 | "packageName": "com.example.acme.test", 11 | "version": { 12 | "id": "2.1.0.RELEASE", 13 | "major": "2", 14 | "minor": "2.1" 15 | }, 16 | "dependencies": { 17 | "id": "data-jpa web", 18 | "values": [ 19 | "web", 20 | "data-jpa" 21 | ], 22 | "count": 2 23 | }, 24 | "errorState": { 25 | "invalid": true, 26 | "language": true 27 | } 28 | } -------------------------------------------------------------------------------- /initializr-actuator/src/test/resources/stat/request-invalid-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "generationTimestamp": 0, 3 | "type": "not-a-type", 4 | "groupId": "com.example.acme", 5 | "artifactId": "test", 6 | "javaVersion": "1.8", 7 | "language": "java", 8 | "packaging": "jar", 9 | "packageName": "com.example.acme.test", 10 | "version": { 11 | "id": "2.1.0.RELEASE", 12 | "major": "2", 13 | "minor": "2.1" 14 | }, 15 | "dependencies": { 16 | "id": "data-jpa web", 17 | "values": [ 18 | "web", 19 | "data-jpa" 20 | ], 21 | "count": 2 22 | }, 23 | "errorState": { 24 | "invalid": true, 25 | "type": true 26 | } 27 | } -------------------------------------------------------------------------------- /initializr-actuator/src/test/resources/stat/request-no-client.json: -------------------------------------------------------------------------------- 1 | { 2 | "generationTimestamp": 0, 3 | "type": "gradle-project", 4 | "buildSystem": "gradle", 5 | "groupId": "com.example.acme", 6 | "artifactId": "test", 7 | "javaVersion": "1.8", 8 | "language": "java", 9 | "packaging": "jar", 10 | "packageName": "com.example.acme.test", 11 | "version": { 12 | "id": "2.1.0.RELEASE", 13 | "major": "2", 14 | "minor": "2.1" 15 | }, 16 | "dependencies": { 17 | "id": "data-jpa web", 18 | "values": [ 19 | "web", 20 | "data-jpa" 21 | ], 22 | "count": 2 23 | } 24 | } -------------------------------------------------------------------------------- /initializr-actuator/src/test/resources/stat/request-simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "generationTimestamp": 0, 3 | "type": "maven-project", 4 | "buildSystem": "maven", 5 | "groupId": "com.example.acme", 6 | "artifactId": "project", 7 | "javaVersion": "1.8", 8 | "language": "java", 9 | "packaging": "jar", 10 | "packageName": "com.example.acme.project", 11 | "version": { 12 | "id": "2.1.1.RELEASE", 13 | "major": "2", 14 | "minor": "2.1" 15 | }, 16 | "client": { 17 | "id": "curl", 18 | "version": "1.2.4", 19 | "ip": "10.0.0.42", 20 | "country": "BE" 21 | }, 22 | "dependencies": { 23 | "id": "data-jpa web", 24 | "values": [ 25 | "web", 26 | "data-jpa" 27 | ], 28 | "count": 2 29 | } 30 | } -------------------------------------------------------------------------------- /initializr-docs/src/main/asciidoc/api-guide.adoc: -------------------------------------------------------------------------------- 1 | [[api-guide]] 2 | = API Guide 3 | 4 | include::metadata-format.adoc[leveloffset=+1] 5 | 6 | include::using-the-stubs.adoc[leveloffset=+1] 7 | -------------------------------------------------------------------------------- /initializr-docs/src/main/asciidoc/images/web-selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-docs/src/main/asciidoc/images/web-selected.png -------------------------------------------------------------------------------- /initializr-docs/src/main/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Spring Initializr Reference Guide 2 | Stéphane Nicoll; Dave Syer 3 | :doctype: book 4 | :idprefix: 5 | :idseparator: - 6 | :toc: left 7 | :toclevels: 4 8 | :tabsize: 4 9 | :numbered: 10 | :sectanchors: 11 | :sectnums: 12 | :icons: font 13 | :hide-uri-scheme: 14 | :docinfo: shared,private 15 | 16 | :test-examples: ../../test/java/io/spring/initializr 17 | :initializr-repo: snapshot 18 | :github-tag: master 19 | :github-repo: spring-io/initializr 20 | :github-raw: https://raw.github.com/{github-repo}/{github-tag} 21 | :github-code: https://github.com/{github-repo}/tree/{github-tag} 22 | :github-wiki: https://github.com/{github-repo}/wiki 23 | :github-master-code: https://github.com/{github-repo}/tree/master 24 | :sc-initializr-generator: {github-code}/initializr-generator/src/main/java/io/spring/initializr 25 | :spring-initializr-docs-version: current 26 | :spring-initializr-docs: http://docs.spring.io/initializr/docs/{spring-initializr-docs-version}/reference 27 | :spring-initializr-docs-current: http://docs.spring.io/initializr/docs/current/reference/html 28 | :spring-boot-reference: http://docs.spring.io/spring-boot/docs/{spring-boot-docs-version}/reference/htmlsingle 29 | 30 | // ====================================================================================== 31 | 32 | include::documentation-overview.adoc[] 33 | include::user-guide.adoc[] 34 | include::configuration-guide.adoc[] 35 | include::api-guide.adoc[] 36 | // ====================================================================================== 37 | -------------------------------------------------------------------------------- /initializr-docs/src/test/java/io/spring/initializr/stub/SampleApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.stub; 18 | 19 | import io.spring.initializr.actuate.autoconfigure.InitializrActuatorEndpointsAutoConfiguration; 20 | import io.spring.initializr.web.autoconfigure.InitializrAutoConfiguration; 21 | 22 | import org.springframework.boot.autoconfigure.SpringBootApplication; 23 | 24 | /** 25 | * A sample app where the Initializr auto-configuration has been disabled. 26 | * 27 | * @author Stephane Nicoll 28 | */ 29 | @SpringBootApplication(exclude = { InitializrAutoConfiguration.class, 30 | InitializrActuatorEndpointsAutoConfiguration.class }) 31 | public class SampleApp { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /initializr-docs/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /initializr-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | io.spring.initializr 6 | initializr 7 | ${revision} 8 | 9 | initializr-generator 10 | Spring Initializr :: Generator 11 | 12 | 13 | ${basedir}/.. 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot 20 | 21 | 22 | 23 | org.slf4j 24 | slf4j-api 25 | 26 | 27 | com.samskivert 28 | jmustache 29 | 30 | 31 | com.fasterxml.jackson.core 32 | jackson-databind 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-configuration-processor 38 | true 39 | 40 | 41 | 42 | org.junit.jupiter 43 | junit-jupiter 44 | test 45 | 46 | 47 | org.assertj 48 | assertj-core 49 | test 50 | 51 | 52 | org.mockito 53 | mockito-junit-jupiter 54 | test 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter 59 | test 60 | 61 | 62 | xmlunit 63 | xmlunit 64 | test 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.apache.maven.plugins 72 | maven-jar-plugin 73 | 74 | 75 | 76 | test-jar 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/InitializrException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr; 18 | 19 | /** 20 | * Base Initializr exception. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | @SuppressWarnings("serial") 25 | public class InitializrException extends RuntimeException { 26 | 27 | public InitializrException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | public InitializrException(String message) { 32 | super(message); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/generator/BuildProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.generator; 18 | 19 | import java.util.Map; 20 | import java.util.TreeMap; 21 | import java.util.function.Supplier; 22 | 23 | import io.spring.initializr.util.VersionProperty; 24 | 25 | /** 26 | * Build properties associated to a project request. 27 | * 28 | * @author Stephane Nicoll 29 | */ 30 | public class BuildProperties { 31 | 32 | /** 33 | * Maven-specific build properties, added to the regular {@code properties} element. 34 | */ 35 | private final TreeMap> maven = new TreeMap<>(); 36 | 37 | /** 38 | * Gradle-specific build properties, added to the {@code buildscript} section of the 39 | * gradle build. 40 | */ 41 | private final TreeMap> gradle = new TreeMap<>(); 42 | 43 | /** 44 | * Version properties. Shared between the two build systems. 45 | */ 46 | private final TreeMap> versions = new TreeMap<>(); 47 | 48 | public Map> getMaven() { 49 | return this.maven; 50 | } 51 | 52 | public Map> getGradle() { 53 | return this.gradle; 54 | } 55 | 56 | public Map> getVersions() { 57 | return this.versions; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/generator/InvalidProjectRequestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.generator; 18 | 19 | import io.spring.initializr.InitializrException; 20 | 21 | /** 22 | * Thrown when a {@link ProjectRequest} is invalid. 23 | * 24 | * @author Stephane Nicoll 25 | */ 26 | @SuppressWarnings("serial") 27 | public class InvalidProjectRequestException extends InitializrException { 28 | 29 | public InvalidProjectRequestException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | public InvalidProjectRequestException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/generator/ProjectFailedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.generator; 18 | 19 | /** 20 | * Event published when an error occurred trying to generate a project. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | public class ProjectFailedEvent extends ProjectRequestEvent { 25 | 26 | private final Exception cause; 27 | 28 | public ProjectFailedEvent(ProjectRequest projectRequest, Exception cause) { 29 | super(projectRequest); 30 | this.cause = cause; 31 | } 32 | 33 | /** 34 | * Return the cause of the failure. 35 | * @return the cause of the failure 36 | */ 37 | public Exception getCause() { 38 | return this.cause; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/generator/ProjectGeneratedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.generator; 18 | 19 | /** 20 | * Event published when a new project has been generated successfully. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | public class ProjectGeneratedEvent extends ProjectRequestEvent { 25 | 26 | public ProjectGeneratedEvent(ProjectRequest projectRequest) { 27 | super(projectRequest); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/generator/ProjectRequestEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.generator; 18 | 19 | /** 20 | * Event published when a {@link ProjectRequest} has been processed. 21 | * 22 | * @author Stephane Nicoll 23 | * @see ProjectGeneratedEvent 24 | * @see ProjectFailedEvent 25 | */ 26 | public abstract class ProjectRequestEvent { 27 | 28 | private final ProjectRequest projectRequest; 29 | 30 | private final long timestamp; 31 | 32 | protected ProjectRequestEvent(ProjectRequest projectRequest) { 33 | this.projectRequest = projectRequest; 34 | this.timestamp = System.currentTimeMillis(); 35 | } 36 | 37 | /** 38 | * Return the {@link ProjectRequest} used to generate the project. 39 | * @return the project request 40 | */ 41 | public ProjectRequest getProjectRequest() { 42 | return this.projectRequest; 43 | } 44 | 45 | /** 46 | * Return the timestamp at which the request was processed. 47 | * @return the timestamp that the request was processed 48 | */ 49 | public long getTimestamp() { 50 | return this.timestamp; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/generator/ProjectRequestPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.generator; 18 | 19 | import io.spring.initializr.metadata.InitializrMetadata; 20 | 21 | /** 22 | * Project generation hook that allows for custom modification of {@link ProjectRequest} 23 | * instances, e.g. adding custom dependencies or forcing certain settings based on custom 24 | * logic. 25 | * 26 | * @author Stephane Nicoll 27 | */ 28 | public interface ProjectRequestPostProcessor { 29 | 30 | /** 31 | * Apply this post processor to the given {@code ProjectRequest} before it gets 32 | * resolved against the specified {@code InitializrMetadata}. 33 | *

34 | * Consider using this hook to customize basic settings of the {@code request}; for 35 | * more advanced logic (in particular with regards to dependencies), consider using 36 | * {@code postProcessAfterResolution}. 37 | * @param request an unresolved {@link ProjectRequest} 38 | * @param metadata the metadata to use to resolve this request 39 | * @see ProjectRequest#resolve(InitializrMetadata) 40 | */ 41 | default void postProcessBeforeResolution(ProjectRequest request, 42 | InitializrMetadata metadata) { 43 | } 44 | 45 | /** 46 | * Apply this post processor to the given {@code ProjectRequest} after it has 47 | * been resolved against the specified {@code InitializrMetadata}. 48 | *

49 | * Dependencies, repositories, bills of materials, default properties and others 50 | * aspects of the request will have been resolved prior to invocation. In particular, 51 | * note that no further validation checks will be performed. 52 | * @param request an resolved {@code ProjectRequest} 53 | * @param metadata the metadata that were used to resolve this request 54 | */ 55 | default void postProcessAfterResolution(ProjectRequest request, 56 | InitializrMetadata metadata) { 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/generator/ProjectRequestResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.generator; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import io.spring.initializr.metadata.InitializrMetadata; 23 | 24 | import org.springframework.util.Assert; 25 | 26 | /** 27 | * Resolve {@link ProjectRequest} instances, honouring callback hook points. 28 | * 29 | * @author Stephane Nicoll 30 | */ 31 | public class ProjectRequestResolver { 32 | 33 | private final List postProcessors; 34 | 35 | public ProjectRequestResolver(List postProcessors) { 36 | this.postProcessors = new ArrayList<>(postProcessors); 37 | } 38 | 39 | public ProjectRequest resolve(ProjectRequest request, InitializrMetadata metadata) { 40 | Assert.notNull(request, "Request must not be null"); 41 | applyPostProcessBeforeResolution(request, metadata); 42 | request.resolve(metadata); 43 | applyPostProcessAfterResolution(request, metadata); 44 | return request; 45 | } 46 | 47 | private void applyPostProcessBeforeResolution(ProjectRequest request, 48 | InitializrMetadata metadata) { 49 | for (ProjectRequestPostProcessor processor : this.postProcessors) { 50 | processor.postProcessBeforeResolution(request, metadata); 51 | } 52 | } 53 | 54 | private void applyPostProcessAfterResolution(ProjectRequest request, 55 | InitializrMetadata metadata) { 56 | for (ProjectRequestPostProcessor processor : this.postProcessors) { 57 | processor.postProcessAfterResolution(request, metadata); 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/generator/ProjectResourceLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.generator; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.net.URL; 22 | import java.nio.charset.Charset; 23 | 24 | import org.springframework.cache.annotation.Cacheable; 25 | import org.springframework.util.ResourceUtils; 26 | import org.springframework.util.StreamUtils; 27 | 28 | /** 29 | * Locate project resources. 30 | * 31 | * @author Stephane Nicoll 32 | */ 33 | public class ProjectResourceLocator { 34 | 35 | private static final Charset UTF_8 = Charset.forName("UTF-8"); 36 | 37 | /** 38 | * Return the binary content of the resource at the specified location. 39 | * @param location a resource location 40 | * @return the content of the resource 41 | */ 42 | @Cacheable("initializr.project-resources") 43 | public byte[] getBinaryResource(String location) { 44 | try (InputStream stream = getInputStream(location)) { 45 | return StreamUtils.copyToByteArray(stream); 46 | } 47 | catch (IOException ex) { 48 | throw new IllegalStateException("Cannot get resource", ex); 49 | } 50 | } 51 | 52 | /** 53 | * Return the textual content of the resource at the specified location. 54 | * @param location a resource location 55 | * @return the content of the resource 56 | */ 57 | @Cacheable("initializr.project-resources") 58 | public String getTextResource(String location) { 59 | try (InputStream stream = getInputStream(location)) { 60 | return StreamUtils.copyToString(stream, UTF_8); 61 | } 62 | catch (IOException ex) { 63 | throw new IllegalStateException("Cannot get resource", ex); 64 | } 65 | } 66 | 67 | private InputStream getInputStream(String location) throws IOException { 68 | URL url = ResourceUtils.getURL(location); 69 | return url.openStream(); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/DefaultMetadataElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * A {@link MetadataElement} that specifies if its the default for a given capability. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | public class DefaultMetadataElement extends MetadataElement { 25 | 26 | private boolean defaultValue; 27 | 28 | public DefaultMetadataElement() { 29 | } 30 | 31 | public DefaultMetadataElement(String id, String name, boolean defaultValue) { 32 | super(id, name); 33 | this.defaultValue = defaultValue; 34 | } 35 | 36 | public DefaultMetadataElement(String id, boolean defaultValue) { 37 | this(id, null, defaultValue); 38 | } 39 | 40 | public void setDefault(boolean defaultValue) { 41 | this.defaultValue = defaultValue; 42 | } 43 | 44 | public boolean isDefault() { 45 | return this.defaultValue; 46 | } 47 | 48 | public static DefaultMetadataElement create(String id, boolean defaultValue) { 49 | return new DefaultMetadataElement(id, defaultValue); 50 | } 51 | 52 | public static DefaultMetadataElement create(String id, String name, 53 | boolean defaultValue) { 54 | return new DefaultMetadataElement(id, name, defaultValue); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/Defaultable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * Metadata with a default value. 21 | * 22 | * @param the value type 23 | * @author Dave Syer 24 | */ 25 | public interface Defaultable { 26 | 27 | /** 28 | * Return the default value. 29 | * @return the default value 30 | */ 31 | T getDefault(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/DependencyMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import java.util.Map; 20 | 21 | import io.spring.initializr.util.Version; 22 | 23 | /** 24 | * Dependency metadata for a given spring boot {@link Version}. 25 | * 26 | * @author Stephane Nicoll 27 | */ 28 | public class DependencyMetadata { 29 | 30 | final Version bootVersion; 31 | 32 | final Map dependencies; 33 | 34 | final Map repositories; 35 | 36 | final Map boms; 37 | 38 | public DependencyMetadata() { 39 | this(null, null, null, null); 40 | } 41 | 42 | public DependencyMetadata(Version bootVersion, Map dependencies, 43 | Map repositories, Map boms) { 44 | this.bootVersion = bootVersion; 45 | this.dependencies = dependencies; 46 | this.repositories = repositories; 47 | this.boms = boms; 48 | } 49 | 50 | public Version getBootVersion() { 51 | return this.bootVersion; 52 | } 53 | 54 | public Map getDependencies() { 55 | return this.dependencies; 56 | } 57 | 58 | public Map getRepositories() { 59 | return this.repositories; 60 | } 61 | 62 | public Map getBoms() { 63 | return this.boms; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/DependencyMetadataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import io.spring.initializr.util.Version; 20 | 21 | /** 22 | * Provide the {@link DependencyMetadata} for a given spring boot version. 23 | * 24 | * @author Stephane Nicoll 25 | */ 26 | public interface DependencyMetadataProvider { 27 | 28 | /** 29 | * Return the dependency metadata to use for the specified {@code bootVersion}. 30 | * @param metadata the intializr metadata 31 | * @param bootVersion the Spring Boot version 32 | * @return the dependency metadata 33 | */ 34 | DependencyMetadata get(InitializrMetadata metadata, Version bootVersion); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/Describable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * An item that can describe itself. 21 | * 22 | * @author Dave Syer 23 | */ 24 | public interface Describable { 25 | 26 | /** 27 | * Returns the item description. 28 | * @return the description 29 | */ 30 | String getDescription(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/InitializrMetadataCustomizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * Strategy interface used to customize the {@link InitializrMetadata}. 21 | * 22 | * @author Dave Syer 23 | */ 24 | public interface InitializrMetadataCustomizer { 25 | 26 | /** 27 | * Customize the {@link InitializrMetadata}, updating or moving around capabilities 28 | * before they are validated. 29 | * @param metadata the initalizr metadata 30 | */ 31 | void customize(InitializrMetadata metadata); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/InitializrMetadataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * Provide the {@link InitializrMetadata} to use. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | public interface InitializrMetadataProvider { 25 | 26 | /** 27 | * Return the metadata to use. Rather than keeping a handle to a particular instance, 28 | * implementations may decide to refresh or recompute the metadata if necessary. 29 | * @return the initializr metadata 30 | */ 31 | InitializrMetadata get(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/InvalidInitializrMetadataException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * Thrown when the configuration defines invalid metadata. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | @SuppressWarnings("serial") 25 | public class InvalidInitializrMetadataException extends RuntimeException { 26 | 27 | public InvalidInitializrMetadataException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | public InvalidInitializrMetadataException(String message) { 32 | super(message); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/MetadataElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * A basic metadata element. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | public class MetadataElement { 25 | 26 | /** 27 | * A visual representation of this element. 28 | */ 29 | private String name; 30 | 31 | /** 32 | * The unique id of this element for a given capability. 33 | */ 34 | private String id; 35 | 36 | public MetadataElement() { 37 | } 38 | 39 | public MetadataElement(MetadataElement other) { 40 | this(other.id, other.name); 41 | } 42 | 43 | public MetadataElement(String id, String name) { 44 | this.id = id; 45 | this.name = name; 46 | } 47 | 48 | public String getName() { 49 | return (this.name != null) ? this.name : this.id; 50 | } 51 | 52 | public String getId() { 53 | return this.id; 54 | } 55 | 56 | public void setId(String id) { 57 | this.id = id; 58 | } 59 | 60 | public void setName(String name) { 61 | this.name = name; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/ServiceCapabilityType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * Defines the supported service capability type. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | public enum ServiceCapabilityType { 25 | 26 | /** 27 | * A special type that defines the action to use. 28 | */ 29 | ACTION("action"), 30 | 31 | /** 32 | * A simple text value with no option. 33 | */ 34 | TEXT("text"), 35 | 36 | /** 37 | * A simple value to be chosen amongst the specified options. 38 | */ 39 | SINGLE_SELECT("single-select"), 40 | 41 | /** 42 | * A hierarchical set of values (values in values) with the ability to select multiple 43 | * values. 44 | */ 45 | HIERARCHICAL_MULTI_SELECT("hierarchical-multi-select"); 46 | 47 | private final String name; 48 | 49 | ServiceCapabilityType(String name) { 50 | this.name = name; 51 | } 52 | 53 | public String getName() { 54 | return this.name; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/SimpleInitializrMetadataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | /** 20 | * A simple {@link InitializrMetadataProvider} implementation. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | public class SimpleInitializrMetadataProvider implements InitializrMetadataProvider { 25 | 26 | private final InitializrMetadata metadata; 27 | 28 | public SimpleInitializrMetadataProvider(InitializrMetadata metadata) { 29 | this.metadata = metadata; 30 | } 31 | 32 | @Override 33 | public InitializrMetadata get() { 34 | return this.metadata; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/SingleSelectCapability.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import java.util.List; 20 | import java.util.concurrent.CopyOnWriteArrayList; 21 | 22 | import com.fasterxml.jackson.annotation.JsonCreator; 23 | import com.fasterxml.jackson.annotation.JsonProperty; 24 | 25 | /** 26 | * A {@link ServiceCapabilityType#SINGLE_SELECT single select} capability. 27 | * 28 | * @author Stephane Nicoll 29 | */ 30 | public class SingleSelectCapability 31 | extends ServiceCapability> 32 | implements Defaultable { 33 | 34 | private final List content = new CopyOnWriteArrayList<>(); 35 | 36 | @JsonCreator 37 | SingleSelectCapability(@JsonProperty("id") String id) { 38 | this(id, null, null); 39 | } 40 | 41 | public SingleSelectCapability(String id, String title, String description) { 42 | super(id, ServiceCapabilityType.SINGLE_SELECT, title, description); 43 | } 44 | 45 | @Override 46 | public List getContent() { 47 | return this.content; 48 | } 49 | 50 | /** 51 | * Return the default element of this capability. 52 | */ 53 | @Override 54 | public DefaultMetadataElement getDefault() { 55 | return this.content.stream().filter(DefaultMetadataElement::isDefault).findFirst() 56 | .orElse(null); 57 | } 58 | 59 | /** 60 | * Return the element with the specified id or {@code null} if no such element exists. 61 | * @param id the ID of the element to find 62 | * @return the element or {@code null} 63 | */ 64 | public DefaultMetadataElement get(String id) { 65 | return this.content.stream().filter((it) -> id.equals(it.getId())).findFirst() 66 | .orElse(null); 67 | } 68 | 69 | @Override 70 | public void merge(List otherContent) { 71 | otherContent.forEach((it) -> { 72 | if (get(it.getId()) == null) { 73 | this.content.add(it); 74 | } 75 | }); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/TextCapability.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | /** 23 | * A {@link ServiceCapabilityType#TEXT text} capability. 24 | * 25 | * @author Stephane Nicoll 26 | */ 27 | public class TextCapability extends ServiceCapability { 28 | 29 | private String content; 30 | 31 | @JsonCreator 32 | TextCapability(@JsonProperty("id") String id) { 33 | this(id, null, null); 34 | } 35 | 36 | TextCapability(String id, String title, String description) { 37 | super(id, ServiceCapabilityType.TEXT, title, description); 38 | } 39 | 40 | @Override 41 | public String getContent() { 42 | return this.content; 43 | } 44 | 45 | public void setContent(String content) { 46 | this.content = content; 47 | } 48 | 49 | @Override 50 | public void merge(String otherContent) { 51 | if (otherContent != null) { 52 | this.content = otherContent; 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import java.util.LinkedHashMap; 20 | import java.util.Map; 21 | 22 | /** 23 | * Defines a particular project type. Each type is associated to a concrete action that 24 | * should be invoked to generate the content of that type. 25 | * 26 | * @author Stephane Nicoll 27 | */ 28 | public class Type extends DefaultMetadataElement implements Describable { 29 | 30 | private String description; 31 | 32 | @Deprecated 33 | private String stsId; 34 | 35 | private String action; 36 | 37 | private final Map tags = new LinkedHashMap<>(); 38 | 39 | public void setAction(String action) { 40 | String actionToUse = action; 41 | if (!actionToUse.startsWith("/")) { 42 | actionToUse = "/" + actionToUse; 43 | } 44 | this.action = actionToUse; 45 | } 46 | 47 | @Override 48 | public String getDescription() { 49 | return this.description; 50 | } 51 | 52 | public void setDescription(String description) { 53 | this.description = description; 54 | } 55 | 56 | public String getStsId() { 57 | return this.stsId; 58 | } 59 | 60 | public void setStsId(String stsId) { 61 | this.stsId = stsId; 62 | } 63 | 64 | public String getAction() { 65 | return this.action; 66 | } 67 | 68 | public Map getTags() { 69 | return this.tags; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/metadata/TypeCapability.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * An {@link ServiceCapabilityType#ACTION action} capability. 24 | * 25 | * @author Stephane Nicoll 26 | */ 27 | public class TypeCapability extends ServiceCapability> 28 | implements Defaultable { 29 | 30 | private final List content = new ArrayList<>(); 31 | 32 | public TypeCapability() { 33 | super("type", ServiceCapabilityType.ACTION, "Type", "project type"); 34 | } 35 | 36 | @Override 37 | public List getContent() { 38 | return this.content; 39 | } 40 | 41 | /** 42 | * Return the {@link Type} with the specified id or {@code null} if no such type 43 | * exists. 44 | * @param id the ID to find 45 | * @return the Type or {@code null} 46 | */ 47 | public Type get(String id) { 48 | return this.content.stream() 49 | .filter((it) -> id.equals(it.getId()) || id.equals(it.getStsId())) 50 | .findFirst().orElse(null); 51 | } 52 | 53 | /** 54 | * Return the default {@link Type}. 55 | */ 56 | @Override 57 | public Type getDefault() { 58 | return this.content.stream().filter(DefaultMetadataElement::isDefault).findFirst() 59 | .orElse(null); 60 | } 61 | 62 | @Override 63 | public void merge(List otherContent) { 64 | otherContent.forEach((it) -> { 65 | if (get(it.getId()) == null) { 66 | this.content.add(it); 67 | } 68 | }); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /initializr-generator/src/main/java/io/spring/initializr/util/InvalidVersionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.util; 18 | 19 | /** 20 | * Thrown if a input represents an invalid version. 21 | * 22 | * @author Stephane Nicoll 23 | */ 24 | @SuppressWarnings("serial") 25 | public class InvalidVersionException extends RuntimeException { 26 | 27 | public InvalidVersionException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | public InvalidVersionException(String message) { 32 | super(message); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/project/gradle3/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-generator/src/main/resources/project/gradle3/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/project/gradle3/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip 6 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/project/gradle3/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/project/gradle4/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-generator/src/main/resources/project/gradle4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/project/gradle4/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/project/gradle4/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/project/maven/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-generator/src/main/resources/project/maven/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/project/maven/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/Application.groovy: -------------------------------------------------------------------------------- 1 | package {{packageName}} 2 | 3 | import org.springframework.boot.SpringApplication 4 | {{applicationImports}} 5 | 6 | {{applicationAnnotations}} 7 | class {{applicationName}} { 8 | 9 | static void main(String[] args) { 10 | SpringApplication.run({{applicationName}}, args) 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/Application.java: -------------------------------------------------------------------------------- 1 | package {{packageName}}; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | {{applicationImports}} 5 | 6 | {{applicationAnnotations}} 7 | public class {{applicationName}} { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run({{applicationName}}.class, args); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/Application.kt: -------------------------------------------------------------------------------- 1 | package {{packageName}} 2 | 3 | {{^kotlinSupport}} 4 | import org.springframework.boot.SpringApplication 5 | {{/kotlinSupport}} 6 | {{applicationImports}} 7 | {{#kotlinSupport}} 8 | import org.springframework.boot.runApplication 9 | {{/kotlinSupport}} 10 | 11 | {{applicationAnnotations}} 12 | class {{applicationName}} 13 | 14 | fun main(args: Array) { 15 | {{^kotlinSupport}} 16 | SpringApplication.run({{applicationName}}::class.java, *args) 17 | {{/kotlinSupport}} 18 | {{#kotlinSupport}} 19 | runApplication<{{applicationName}}>(*args) 20 | {{/kotlinSupport}} 21 | } 22 | 23 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/ApplicationTests.groovy: -------------------------------------------------------------------------------- 1 | package {{packageName}} 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | {{testImports}} 6 | @RunWith(SpringRunner) 7 | @SpringBootTest 8 | {{testAnnotations}}class {{applicationName}}Tests { 9 | 10 | @Test 11 | void contextLoads() { 12 | } 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package {{packageName}}; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | {{testImports}} 6 | @RunWith(SpringRunner.class) 7 | @SpringBootTest 8 | {{testAnnotations}}public class {{applicationName}}Tests { 9 | 10 | @Test 11 | public void contextLoads() { 12 | } 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/ApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package {{packageName}} 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | {{testImports}} 6 | @RunWith(SpringRunner::class) 7 | @SpringBootTest 8 | {{testAnnotations}}class {{applicationName}}Tests { 9 | 10 | @Test 11 | fun contextLoads() { 12 | } 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/ServletInitializer.groovy: -------------------------------------------------------------------------------- 1 | package {{packageName}} 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder 4 | {{servletInitializrImport}} 5 | 6 | class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | application.sources({{applicationName}}) 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/ServletInitializer.java: -------------------------------------------------------------------------------- 1 | package {{packageName}}; 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; 4 | {{servletInitializrImport}} 5 | 6 | public class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | return application.sources({{applicationName}}.class); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/ServletInitializer.kt: -------------------------------------------------------------------------------- 1 | package {{packageName}} 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder 4 | {{servletInitializrImport}} 5 | 6 | class ServletInitializer : SpringBootServletInitializer() { 7 | 8 | override fun configure(application: SpringApplicationBuilder): SpringApplicationBuilder { 9 | return application.sources({{applicationName}}::class.java) 10 | } 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/boot-cli-capabilities.txt: -------------------------------------------------------------------------------- 1 | {{{logo}}} 2 | :: Service capabilities :: {{serviceUrl}} 3 | 4 | Supported dependencies 5 | {{{dependencies}}} 6 | 7 | Project types (* denotes the default) 8 | {{{types}}} 9 | 10 | Parameters 11 | {{{parameters}}} 12 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/cli-capabilities.txt: -------------------------------------------------------------------------------- 1 | {{{logo}}} 2 | :: Spring Initializr :: {{serviceUrl}} 3 | 4 | This service generates quickstart projects that can be easily customized. 5 | Possible customizations include a project's dependencies, Java version, and 6 | build system or build structure. See below for further details. 7 | 8 | The services uses a HAL based hypermedia format to expose a set of resources 9 | to interact with. If you access this root resource requesting application/json 10 | as media type the response will contain the following links: 11 | {{{types}}} 12 | 13 | The URI templates take a set of parameters to customize the result of a request 14 | to the linked resource. 15 | {{{parameters}}} 16 | 17 | The following section has a list of supported identifiers for the comma-separated 18 | list of "dependencies". 19 | {{{dependencies}}} 20 | {{#hasExamples}} 21 | Examples: 22 | 23 | {{{examples}}} 24 | {{/hasExamples}} 25 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/curl-examples.txt: -------------------------------------------------------------------------------- 1 | To create a default demo.zip: 2 | $ curl {{serviceUrl}}/starter.zip -o demo.zip 3 | 4 | To create a web project using Java 11: 5 | $ curl {{serviceUrl}}/starter.zip -d dependencies=web \\ 6 | -d javaVersion=11 -o demo.zip 7 | 8 | To create a web/data-jpa gradle project unpacked: 9 | $ curl {{serviceUrl}}/starter.tgz -d dependencies=web,data-jpa \\ 10 | -d type=gradle-project -d baseDir=my-dir | tar -xzvf - 11 | 12 | To generate a Maven POM with war packaging: 13 | $ curl {{serviceUrl}}/pom.xml -d packaging=war -o pom.xml 14 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/gitignore.tmpl: -------------------------------------------------------------------------------- 1 | {{#mavenBuild}} 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | {{/mavenBuild}} 5 | {{^mavenBuild}} 6 | .gradle 7 | /build/ 8 | !gradle/wrapper/gradle-wrapper.jar 9 | {{/mavenBuild}} 10 | 11 | ### STS ### 12 | .apt_generated 13 | .classpath 14 | .factorypath 15 | .project 16 | .settings 17 | .springBeans 18 | .sts4-cache 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | {{^mavenBuild}} 26 | /out/ 27 | {{/mavenBuild}} 28 | 29 | ### NetBeans ### 30 | /nbproject/private/ 31 | /nbbuild/ 32 | /dist/ 33 | /nbdist/ 34 | /.nb-gradle/ 35 | {{#mavenBuild}} 36 | /build/ 37 | {{/mavenBuild}} 38 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/httpie-examples.txt: -------------------------------------------------------------------------------- 1 | To create a default project: 2 | $ http {{serviceUrl}}/starter.zip -d 3 | 4 | To create a web project using Java 11: 5 | $ http {{serviceUrl}}/starter.zip dependencies==web \\ 6 | javaVersion==11 -d 7 | 8 | To create a web/data-jpa gradle project unpacked: 9 | $ http {{serviceUrl}}/starter.tgz dependencies==web,data-jpa \\ 10 | type==gradle-project baseDir==my-dir | tar -xzvf - 11 | 12 | To generate a Maven POM with war packaging: 13 | $ http {{serviceUrl}}/pom.xml packaging==war -o pom.xml 14 | -------------------------------------------------------------------------------- /initializr-generator/src/main/resources/templates/starter-settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = '{{artifactId}}' 2 | -------------------------------------------------------------------------------- /initializr-generator/src/test/java/io/spring/initializr/metadata/SingleSelectCapabilityTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | /** 24 | * @author Stephane Nicoll 25 | */ 26 | class SingleSelectCapabilityTests { 27 | 28 | @Test 29 | void defaultEmpty() { 30 | SingleSelectCapability capability = new SingleSelectCapability("test"); 31 | assertThat(capability.getDefault()).isNull(); 32 | } 33 | 34 | @Test 35 | void defaultNoDefault() { 36 | SingleSelectCapability capability = new SingleSelectCapability("test"); 37 | capability.getContent().add(DefaultMetadataElement.create("foo", false)); 38 | capability.getContent().add(DefaultMetadataElement.create("bar", false)); 39 | assertThat(capability.getDefault()).isNull(); 40 | } 41 | 42 | @Test 43 | void defaultType() { 44 | SingleSelectCapability capability = new SingleSelectCapability("test"); 45 | capability.getContent().add(DefaultMetadataElement.create("foo", false)); 46 | DefaultMetadataElement second = DefaultMetadataElement.create("bar", true); 47 | capability.getContent().add(second); 48 | assertThat(capability.getDefault()).isEqualTo(second); 49 | } 50 | 51 | @Test 52 | void mergeAddEntry() { 53 | SingleSelectCapability capability = new SingleSelectCapability("test"); 54 | DefaultMetadataElement foo = DefaultMetadataElement.create("foo", false); 55 | capability.getContent().add(foo); 56 | 57 | SingleSelectCapability anotherCapability = new SingleSelectCapability("test"); 58 | DefaultMetadataElement bar = DefaultMetadataElement.create("bar", false); 59 | anotherCapability.getContent().add(bar); 60 | 61 | capability.merge(anotherCapability); 62 | assertThat(capability.getContent()).hasSize(2); 63 | assertThat(capability.get("foo")).isEqualTo(foo); 64 | assertThat(capability.get("bar")).isEqualTo(bar); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /initializr-generator/src/test/java/io/spring/initializr/metadata/TextCapabilityTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | /** 24 | * @author Stephane Nicoll 25 | */ 26 | class TextCapabilityTests { 27 | 28 | @Test 29 | void mergeValue() { 30 | TextCapability capability = new TextCapability("foo"); 31 | capability.setContent("1234"); 32 | TextCapability another = new TextCapability("foo"); 33 | another.setContent("4567"); 34 | capability.merge(another); 35 | assertThat(capability.getId()).isEqualTo("foo"); 36 | assertThat(capability.getType()).isEqualTo(ServiceCapabilityType.TEXT); 37 | assertThat(capability.getContent()).isEqualTo("4567"); 38 | } 39 | 40 | @Test 41 | void mergeTitle() { 42 | TextCapability capability = new TextCapability("foo", "Foo", "my desc"); 43 | capability.merge(new TextCapability("foo", "AnotherFoo", "")); 44 | assertThat(capability.getId()).isEqualTo("foo"); 45 | assertThat(capability.getType()).isEqualTo(ServiceCapabilityType.TEXT); 46 | assertThat(capability.getTitle()).isEqualTo("AnotherFoo"); 47 | assertThat(capability.getDescription()).isEqualTo("my desc"); 48 | } 49 | 50 | @Test 51 | void mergeDescription() { 52 | TextCapability capability = new TextCapability("foo", "Foo", "my desc"); 53 | capability.merge(new TextCapability("foo", "", "another desc")); 54 | assertThat(capability.getId()).isEqualTo("foo"); 55 | assertThat(capability.getType()).isEqualTo(ServiceCapabilityType.TEXT); 56 | assertThat(capability.getTitle()).isEqualTo("Foo"); 57 | assertThat(capability.getDescription()).isEqualTo("another desc"); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /initializr-generator/src/test/java/io/spring/initializr/metadata/TypeCapabilityTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | /** 24 | * @author Stephane Nicoll 25 | */ 26 | class TypeCapabilityTests { 27 | 28 | @Test 29 | void defaultEmpty() { 30 | TypeCapability capability = new TypeCapability(); 31 | assertThat(capability.getDefault()).isNull(); 32 | } 33 | 34 | @Test 35 | void defaultNoDefault() { 36 | TypeCapability capability = new TypeCapability(); 37 | Type first = new Type(); 38 | first.setId("foo"); 39 | first.setDefault(false); 40 | Type second = new Type(); 41 | second.setId("bar"); 42 | second.setDefault(false); 43 | capability.getContent().add(first); 44 | capability.getContent().add(second); 45 | assertThat(capability.getDefault()).isNull(); 46 | } 47 | 48 | @Test 49 | void defaultType() { 50 | TypeCapability capability = new TypeCapability(); 51 | Type first = new Type(); 52 | first.setId("foo"); 53 | first.setDefault(false); 54 | Type second = new Type(); 55 | second.setId("bar"); 56 | second.setDefault(true); 57 | capability.getContent().add(first); 58 | capability.getContent().add(second); 59 | assertThat(capability.getDefault()).isEqualTo(second); 60 | } 61 | 62 | @Test 63 | void mergeAddEntry() { 64 | TypeCapability capability = new TypeCapability(); 65 | Type first = new Type(); 66 | first.setId("foo"); 67 | first.setDefault(false); 68 | capability.getContent().add(first); 69 | 70 | TypeCapability anotherCapability = new TypeCapability(); 71 | Type another = new Type(); 72 | another.setId("foo"); 73 | another.setDefault(false); 74 | Type second = new Type(); 75 | second.setId("bar"); 76 | second.setDefault(true); 77 | anotherCapability.getContent().add(another); 78 | anotherCapability.getContent().add(second); 79 | 80 | capability.merge(anotherCapability); 81 | assertThat(capability.getContent()).hasSize(2); 82 | assertThat(capability.get("foo")).isEqualTo(first); 83 | assertThat(capability.get("bar")).isEqualTo(second); 84 | assertThat(capability.getDefault()).isEqualTo(second); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /initializr-generator/src/test/java/io/spring/initializr/metadata/TypeTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.metadata; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | /** 24 | * @author Stephane Nicoll 25 | */ 26 | class TypeTests { 27 | 28 | @Test 29 | void parseAction() { 30 | Type type = new Type(); 31 | type.setId("foo"); 32 | type.setAction("my-action.zip"); 33 | assertThat(type.getAction()).isEqualTo("/my-action.zip"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /initializr-generator/src/test/java/io/spring/initializr/test/generator/GradleSettingsAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.test.generator; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | /** 22 | * Very simple assertions for the gradle settings. 23 | * 24 | * @author Stephane Nicoll 25 | */ 26 | public class GradleSettingsAssert { 27 | 28 | private final String content; 29 | 30 | public GradleSettingsAssert(String content) { 31 | this.content = content; 32 | } 33 | 34 | public GradleSettingsAssert hasProjectName(String name) { 35 | return contains(String.format("rootProject.name = '%s'", name)); 36 | } 37 | 38 | public GradleSettingsAssert contains(String expression) { 39 | assertThat(this.content).contains(expression); 40 | return this; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /initializr-generator/src/test/java/io/spring/initializr/test/generator/SourceCodeAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.test.generator; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.nio.charset.Charset; 22 | 23 | import org.springframework.core.io.Resource; 24 | import org.springframework.util.StreamUtils; 25 | 26 | import static org.assertj.core.api.Assertions.assertThat; 27 | 28 | /** 29 | * Source code assertions. 30 | * 31 | * @author Stephane Nicoll 32 | */ 33 | public class SourceCodeAssert { 34 | 35 | private final String name; 36 | 37 | private final String content; 38 | 39 | public SourceCodeAssert(String name, String content) { 40 | this.name = name; 41 | this.content = content.replaceAll("\r\n", "\n"); 42 | } 43 | 44 | public SourceCodeAssert equalsTo(Resource expected) { 45 | try (InputStream stream = expected.getInputStream()) { 46 | String expectedContent = StreamUtils.copyToString(stream, 47 | Charset.forName("UTF-8")); 48 | assertThat(this.content).describedAs("Content for %s", this.name) 49 | .isEqualTo(expectedContent.replaceAll("\r\n", "\n")); 50 | } 51 | catch (IOException ex) { 52 | throw new IllegalStateException("Cannot read file", ex); 53 | } 54 | return this; 55 | } 56 | 57 | public SourceCodeAssert hasImports(String... classNames) { 58 | for (String className : classNames) { 59 | contains("import " + className); 60 | } 61 | return this; 62 | } 63 | 64 | public SourceCodeAssert doesNotHaveImports(String... classNames) { 65 | for (String className : classNames) { 66 | doesNotContain("import " + className); 67 | } 68 | return this; 69 | } 70 | 71 | public SourceCodeAssert contains(String... expressions) { 72 | assertThat(this.content).describedAs("Content for %s", this.name) 73 | .contains(expressions); 74 | return this; 75 | } 76 | 77 | public SourceCodeAssert doesNotContain(String... expressions) { 78 | assertThat(this.content).describedAs("Content for %s", this.name) 79 | .doesNotContain(expressions); 80 | return this; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /initializr-generator/src/test/java/io/spring/initializr/util/VersionPropertyTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.util; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; 23 | 24 | /** 25 | * Tests for {@link VersionProperty}. 26 | * 27 | * @author Stephane Nicoll 28 | */ 29 | class VersionPropertyTests { 30 | 31 | @Test 32 | void testStandardProperty() { 33 | assertThat(VersionProperty.of("spring-boot.version").toStandardFormat()) 34 | .isEqualTo("spring-boot.version"); 35 | } 36 | 37 | @Test 38 | void testCamelCaseProperty() { 39 | assertThat(VersionProperty.of("spring-boot.version").toCamelCaseFormat()) 40 | .isEqualTo("springBootVersion"); 41 | } 42 | 43 | @Test 44 | void testStandardPropertyWithNoSeparator() { 45 | assertThat(VersionProperty.of("springbootversion").toStandardFormat()) 46 | .isEqualTo("springbootversion"); 47 | } 48 | 49 | @Test 50 | void testCamelCasePropertyWithNoSeparator() { 51 | assertThat(VersionProperty.of("springbootversion").toCamelCaseFormat()) 52 | .isEqualTo("springbootversion"); 53 | } 54 | 55 | @Test 56 | void testInvalidPropertyUpperCase() { 57 | assertThatIllegalArgumentException() 58 | .isThrownBy(() -> VersionProperty.of("Spring-boot.version")); 59 | } 60 | 61 | @Test 62 | void testInvalidPropertyIllegalCharacter() { 63 | assertThatIllegalArgumentException() 64 | .isThrownBy(() -> VersionProperty.of("spring-boot_version")) 65 | .withMessageContaining("Unsupported character"); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/application-test-custom-defaults.yml: -------------------------------------------------------------------------------- 1 | initializr: 2 | groupId: 3 | value: org.foo 4 | artifactId: 5 | value: foo-bar 6 | version: 7 | value: 1.2.4-SNAPSHOT 8 | name: 9 | value: FooBar 10 | description: 11 | value: FooBar Project 12 | packageName: 13 | value: org.foo.demo -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/application-test-custom-env.yml: -------------------------------------------------------------------------------- 1 | initializr: 2 | env: 3 | artifactRepository: https://repo.spring.io/lib-release 4 | google-analytics-tracking-code: UA-1234567-89 5 | fallbackApplicationName: FooBarApplication 6 | invalidApplicationNames: 7 | - InvalidApplication 8 | kotlin: 9 | default-version: 1.0.0-beta-2423 -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/application-test-ssl.yml: -------------------------------------------------------------------------------- 1 | initializr: 2 | env: 3 | forceSsl: true -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/metadata/config/test-bom.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "env": { 4 | "forceSsl": false, 5 | "boms": { 6 | "my-bom": { 7 | "groupId": "org.acme", 8 | "artifactId": "my-bom", 9 | "version": "2.1.1.RELEASE" 10 | }, 11 | "another-bom": { 12 | "groupId": "org.acme", 13 | "artifactId": "another-bom", 14 | "version": "4.5.6.RELEASE" 15 | } 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/metadata/config/test-repository.json: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": { 3 | "env": { 4 | "repositories": { 5 | "my-repo": { 6 | "name": "my repo", 7 | "url": "http://example.com/my", 8 | "snapshotsEnabled": true 9 | }, 10 | "another-repo": { 11 | "name": "another repo", 12 | "url": "http://example.com/another", 13 | "snapshotsEnabled": false 14 | } 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/custom/custom.txt: -------------------------------------------------------------------------------- 1 | Custom resources 2 | 3 | com.example.custom 4 | 42 -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/annotation-processor-dependency-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | 17 | group = 'com.example' 18 | version = '0.0.1-SNAPSHOT' 19 | sourceCompatibility = '1.8' 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | dependencies { 26 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 27 | implementation 'org.springframework.boot:spring-boot-starter-web' 28 | annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' 29 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 30 | } 31 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/bom-ordering-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | 17 | group = 'com.example' 18 | version = '0.0.1-SNAPSHOT' 19 | sourceCompatibility = '1.8' 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | dependencies { 26 | implementation 'org.acme:foo' 27 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 28 | } 29 | 30 | dependencyManagement { 31 | imports { 32 | mavenBom "org.acme:bar-bom:1.0" 33 | mavenBom "org.acme:biz-bom:1.0" 34 | mavenBom "org.acme:foo-bom:1.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/bom-property-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | 17 | group = 'com.example' 18 | version = '0.0.1-SNAPSHOT' 19 | sourceCompatibility = '1.8' 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | ext { 26 | set('fooVersion', '1.3.3') 27 | } 28 | 29 | dependencies { 30 | implementation 'org.acme:foo' 31 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 32 | } 33 | 34 | dependencyManagement { 35 | imports { 36 | mavenBom "org.acme:foo-bom:${fooVersion}" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/compile-only-dependency-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | 17 | group = 'com.example' 18 | version = '0.0.1-SNAPSHOT' 19 | sourceCompatibility = '1.8' 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | dependencies { 26 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 27 | implementation 'org.springframework.boot:spring-boot-starter-web' 28 | compileOnly 'org.acme:foo' 29 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 30 | } 31 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/gitignore.gen: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | /out/ 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/kotlin-java11-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | kotlinVersion = '1.1.1' 4 | springBootVersion = '2.1.1.RELEASE' 5 | } 6 | repositories { 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 11 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 12 | classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") 13 | } 14 | } 15 | 16 | apply plugin: 'kotlin' 17 | apply plugin: 'kotlin-spring' 18 | apply plugin: 'org.springframework.boot' 19 | apply plugin: 'io.spring.dependency-management' 20 | 21 | group = 'com.example' 22 | version = '0.0.1-SNAPSHOT' 23 | sourceCompatibility = '11' 24 | 25 | repositories { 26 | mavenCentral() 27 | } 28 | 29 | dependencies { 30 | implementation 'org.springframework.boot:spring-boot-starter' 31 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 32 | implementation "org.jetbrains.kotlin:kotlin-reflect" 33 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 34 | } 35 | 36 | compileKotlin { 37 | kotlinOptions { 38 | freeCompilerArgs = ['-Xjsr305=strict'] 39 | jvmTarget = '1.8' 40 | } 41 | } 42 | 43 | compileTestKotlin { 44 | kotlinOptions { 45 | freeCompilerArgs = ['-Xjsr305=strict'] 46 | jvmTarget = '1.8' 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/repositories-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | 17 | group = 'com.example' 18 | version = '0.0.1-SNAPSHOT' 19 | sourceCompatibility = '1.8' 20 | 21 | repositories { 22 | mavenCentral() 23 | maven { url 'https://example.com/foo' } 24 | maven { url 'https://example.com/bar' } 25 | } 26 | 27 | dependencies { 28 | implementation 'org.acme:bar' 29 | implementation 'org.acme:foo' 30 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 31 | } 32 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/repositories-milestone-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.2.0.M1' 4 | } 5 | repositories { 6 | mavenCentral() 7 | maven { url 'https://repo.spring.io/snapshot' } 8 | maven { url 'https://repo.spring.io/milestone' } 9 | } 10 | dependencies { 11 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'org.springframework.boot' 17 | apply plugin: 'io.spring.dependency-management' 18 | 19 | group = 'com.example' 20 | version = '0.0.1-SNAPSHOT' 21 | sourceCompatibility = '1.8' 22 | 23 | repositories { 24 | mavenCentral() 25 | maven { url 'https://repo.spring.io/snapshot' } 26 | maven { url 'https://repo.spring.io/milestone' } 27 | } 28 | 29 | dependencies { 30 | implementation 'org.acme:foo' 31 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 32 | } 33 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/gradle/version-override-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | 17 | group = 'com.example' 18 | version = '0.0.1-SNAPSHOT' 19 | sourceCompatibility = '1.8' 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | ext { 26 | set('springBarVersion', '0.2.0.RELEASE') 27 | set('spring-foo.version', '0.1.0.RELEASE') 28 | } 29 | 30 | dependencies { 31 | implementation 'org.springframework.boot:spring-boot-starter-web' 32 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 33 | } 34 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/previous/DemoApplication.groovy.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.springframework.boot.SpringApplication 4 | import org.springframework.boot.autoconfigure.SpringBootApplication 5 | 6 | @SpringBootApplication 7 | class DemoApplication { 8 | 9 | static void main(String[] args) { 10 | SpringApplication.run(DemoApplication, args) 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/previous/ServletInitializer.groovy.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder 4 | import org.springframework.boot.web.support.SpringBootServletInitializer 5 | 6 | class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | application.sources(DemoApplication) 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/previous/build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '1.5.18.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'groovy' 14 | apply plugin: 'org.springframework.boot' 15 | 16 | group = 'com.example' 17 | version = '0.0.1-SNAPSHOT' 18 | sourceCompatibility = '1.8' 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | implementation 'org.springframework.boot:spring-boot-starter' 26 | implementation 'org.codehaus.groovy:groovy' 27 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 28 | } 29 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/previous/pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.5.18.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | org.codehaus.groovy 28 | groovy 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | org.codehaus.gmavenplus 46 | gmavenplus-plugin 47 | 1.5 48 | 49 | 50 | 51 | addSources 52 | addTestSources 53 | generateStubs 54 | compile 55 | testGenerateStubs 56 | testCompile 57 | removeStubs 58 | removeTestStubs 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/standard/DemoApplication.groovy.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.springframework.boot.SpringApplication 4 | import org.springframework.boot.autoconfigure.SpringBootApplication 5 | 6 | @SpringBootApplication 7 | class DemoApplication { 8 | 9 | static void main(String[] args) { 10 | SpringApplication.run(DemoApplication, args) 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/standard/DemoApplicationTests.groovy.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner) 9 | @SpringBootTest 10 | class DemoApplicationTests { 11 | 12 | @Test 13 | void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/standard/DemoApplicationTestsWeb.groovy.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner) 9 | @SpringBootTest 10 | class DemoApplicationTests { 11 | 12 | @Test 13 | void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/standard/ServletInitializer.groovy.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder 4 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer 5 | 6 | class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | application.sources(DemoApplication) 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/standard/build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'groovy' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | 17 | group = 'com.example' 18 | version = '0.0.1-SNAPSHOT' 19 | sourceCompatibility = '1.8' 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | dependencies { 26 | implementation 'org.springframework.boot:spring-boot-starter' 27 | implementation 'org.codehaus.groovy:groovy' 28 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 29 | } 30 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/standard/pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | org.codehaus.groovy 28 | groovy 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | org.codehaus.gmavenplus 46 | gmavenplus-plugin 47 | 1.5 48 | 49 | 50 | 51 | addSources 52 | addTestSources 53 | generateStubs 54 | compile 55 | testGenerateStubs 56 | testCompile 57 | removeStubs 58 | removeTestStubs 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/standard/war-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'groovy' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | apply plugin: 'war' 17 | 18 | group = 'com.example' 19 | version = '0.0.1-SNAPSHOT' 20 | sourceCompatibility = '1.8' 21 | 22 | repositories { 23 | mavenCentral() 24 | } 25 | 26 | dependencies { 27 | implementation 'org.springframework.boot:spring-boot-starter-web' 28 | implementation 'org.codehaus.groovy:groovy' 29 | providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' 30 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 31 | } 32 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/groovy/standard/war-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | war 15 | demo 16 | Demo project for Spring Boot 17 | 18 | 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.codehaus.groovy 29 | groovy 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-tomcat 35 | provided 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | test 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | org.codehaus.gmavenplus 52 | gmavenplus-plugin 53 | 1.5 54 | 55 | 56 | 57 | addSources 58 | addTestSources 59 | generateStubs 60 | compile 61 | testGenerateStubs 62 | testCompile 63 | removeStubs 64 | removeTestStubs 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/previous/DemoApplication.java.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoApplication.class, args); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/previous/ServletInitializer.java.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; 4 | import org.springframework.boot.web.support.SpringBootServletInitializer; 5 | 6 | public class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | return application.sources(DemoApplication.class); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/previous/build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '1.5.18.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | 16 | group = 'com.example' 17 | version = '0.0.1-SNAPSHOT' 18 | sourceCompatibility = '1.8' 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | implementation 'org.springframework.boot:spring-boot-starter' 26 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 27 | } 28 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/previous/pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.5.18.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/standard/DemoApplication.java.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoApplication.class, args); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/standard/DemoApplicationTests.java.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/standard/DemoApplicationTestsWeb.java.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/standard/ServletInitializer.java.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; 4 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 5 | 6 | public class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | return application.sources(DemoApplication.class); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/standard/build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | 17 | group = 'com.example' 18 | version = '0.0.1-SNAPSHOT' 19 | sourceCompatibility = '1.8' 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | dependencies { 26 | implementation 'org.springframework.boot:spring-boot-starter' 27 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 28 | } 29 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/standard/pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/standard/war-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.1.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'org.springframework.boot' 15 | apply plugin: 'io.spring.dependency-management' 16 | apply plugin: 'war' 17 | 18 | group = 'com.example' 19 | version = '0.0.1-SNAPSHOT' 20 | sourceCompatibility = '1.8' 21 | 22 | repositories { 23 | mavenCentral() 24 | } 25 | 26 | dependencies { 27 | implementation 'org.springframework.boot:spring-boot-starter-web' 28 | providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' 29 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 30 | } 31 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/java/standard/war-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | war 15 | demo 16 | Demo project for Spring Boot 17 | 18 | 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-tomcat 31 | provided 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/previous/DemoApplication.kt.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.springframework.boot.SpringApplication 4 | import org.springframework.boot.autoconfigure.SpringBootApplication 5 | 6 | @SpringBootApplication 7 | class DemoApplication 8 | 9 | fun main(args: Array) { 10 | SpringApplication.run(DemoApplication::class.java, *args) 11 | } 12 | 13 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/previous/ServletInitializer.kt.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder 4 | import org.springframework.boot.web.support.SpringBootServletInitializer 5 | 6 | class ServletInitializer : SpringBootServletInitializer() { 7 | 8 | override fun configure(application: SpringApplicationBuilder): SpringApplicationBuilder { 9 | return application.sources(DemoApplication::class.java) 10 | } 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/previous/build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | kotlinVersion = '1.1.1' 4 | springBootVersion = '1.5.18.RELEASE' 5 | } 6 | repositories { 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 11 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 12 | classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") 13 | } 14 | } 15 | 16 | apply plugin: 'kotlin' 17 | apply plugin: 'kotlin-spring' 18 | apply plugin: 'org.springframework.boot' 19 | 20 | group = 'com.example' 21 | version = '0.0.1-SNAPSHOT' 22 | sourceCompatibility = '1.8' 23 | 24 | repositories { 25 | mavenCentral() 26 | } 27 | 28 | dependencies { 29 | implementation 'org.springframework.boot:spring-boot-starter' 30 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}" 31 | implementation "org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}" 32 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 33 | } 34 | 35 | compileKotlin { 36 | kotlinOptions { 37 | freeCompilerArgs = ['-Xjsr305=strict'] 38 | jvmTarget = '1.8' 39 | } 40 | } 41 | 42 | compileTestKotlin { 43 | kotlinOptions { 44 | freeCompilerArgs = ['-Xjsr305=strict'] 45 | jvmTarget = '1.8' 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/standard/DemoApplication.kt.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | class DemoApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | 13 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/standard/DemoApplicationTests.kt.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner::class) 9 | @SpringBootTest 10 | class DemoApplicationTests { 11 | 12 | @Test 13 | fun contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/standard/DemoApplicationTestsWeb.kt.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner::class) 9 | @SpringBootTest 10 | class DemoApplicationTests { 11 | 12 | @Test 13 | fun contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/standard/ServletInitializer.kt.gen: -------------------------------------------------------------------------------- 1 | package com.example.demo 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder 4 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer 5 | 6 | class ServletInitializer : SpringBootServletInitializer() { 7 | 8 | override fun configure(application: SpringApplicationBuilder): SpringApplicationBuilder { 9 | return application.sources(DemoApplication::class.java) 10 | } 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/standard/build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | kotlinVersion = '1.1.1' 4 | springBootVersion = '2.1.1.RELEASE' 5 | } 6 | repositories { 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 11 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 12 | classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") 13 | } 14 | } 15 | 16 | apply plugin: 'kotlin' 17 | apply plugin: 'kotlin-spring' 18 | apply plugin: 'org.springframework.boot' 19 | apply plugin: 'io.spring.dependency-management' 20 | 21 | group = 'com.example' 22 | version = '0.0.1-SNAPSHOT' 23 | sourceCompatibility = '1.8' 24 | 25 | repositories { 26 | mavenCentral() 27 | } 28 | 29 | dependencies { 30 | implementation 'org.springframework.boot:spring-boot-starter' 31 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 32 | implementation "org.jetbrains.kotlin:kotlin-reflect" 33 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 34 | } 35 | 36 | compileKotlin { 37 | kotlinOptions { 38 | freeCompilerArgs = ['-Xjsr305=strict'] 39 | jvmTarget = '1.8' 40 | } 41 | } 42 | 43 | compileTestKotlin { 44 | kotlinOptions { 45 | freeCompilerArgs = ['-Xjsr305=strict'] 46 | jvmTarget = '1.8' 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/standard/pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 1.1.1 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter 26 | 27 | 28 | org.jetbrains.kotlin 29 | kotlin-reflect 30 | 31 | 32 | org.jetbrains.kotlin 33 | kotlin-stdlib-jdk8 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | 44 | ${project.basedir}/src/main/kotlin 45 | ${project.basedir}/src/test/kotlin 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-maven-plugin 50 | 51 | 52 | org.jetbrains.kotlin 53 | kotlin-maven-plugin 54 | 55 | 56 | -Xjsr305=strict 57 | 58 | 59 | spring 60 | 61 | 62 | 63 | 64 | org.jetbrains.kotlin 65 | kotlin-maven-allopen 66 | ${kotlin.version} 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/standard/war-build.gradle.gen: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | kotlinVersion = '1.1.1' 4 | springBootVersion = '2.1.1.RELEASE' 5 | } 6 | repositories { 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 11 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 12 | classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") 13 | } 14 | } 15 | 16 | apply plugin: 'kotlin' 17 | apply plugin: 'kotlin-spring' 18 | apply plugin: 'org.springframework.boot' 19 | apply plugin: 'io.spring.dependency-management' 20 | apply plugin: 'war' 21 | 22 | group = 'com.example' 23 | version = '0.0.1-SNAPSHOT' 24 | sourceCompatibility = '1.8' 25 | 26 | repositories { 27 | mavenCentral() 28 | } 29 | 30 | dependencies { 31 | implementation 'org.springframework.boot:spring-boot-starter-web' 32 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 33 | implementation "org.jetbrains.kotlin:kotlin-reflect" 34 | providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' 35 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 36 | } 37 | 38 | compileKotlin { 39 | kotlinOptions { 40 | freeCompilerArgs = ['-Xjsr305=strict'] 41 | jvmTarget = '1.8' 42 | } 43 | } 44 | 45 | compileTestKotlin { 46 | kotlinOptions { 47 | freeCompilerArgs = ['-Xjsr305=strict'] 48 | jvmTarget = '1.8' 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/kotlin/standard/war-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | war 15 | demo 16 | Demo project for Spring Boot 17 | 18 | 19 | 1.8 20 | 1.1.1 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.jetbrains.kotlin 30 | kotlin-reflect 31 | 32 | 33 | org.jetbrains.kotlin 34 | kotlin-stdlib-jdk8 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-tomcat 40 | provided 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | 50 | ${project.basedir}/src/main/kotlin 51 | ${project.basedir}/src/test/kotlin 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-maven-plugin 56 | 57 | 58 | org.jetbrains.kotlin 59 | kotlin-maven-plugin 60 | 61 | 62 | -Xjsr305=strict 63 | 64 | 65 | spring 66 | 67 | 68 | 69 | 70 | org.jetbrains.kotlin 71 | kotlin-maven-allopen 72 | ${kotlin.version} 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/annotation-processor-dependency-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-data-jpa 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-configuration-processor 34 | true 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/bom-ordering-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.acme 24 | foo 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.acme 38 | foo-bom 39 | 1.0 40 | pom 41 | import 42 | 43 | 44 | org.acme 45 | biz-bom 46 | 1.0 47 | pom 48 | import 49 | 50 | 51 | org.acme 52 | bar-bom 53 | 1.0 54 | pom 55 | import 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/bom-property-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 1.3.3 20 | 21 | 22 | 23 | 24 | org.acme 25 | foo 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-test 31 | test 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.acme 39 | foo-bom 40 | ${foo.version} 41 | pom 42 | import 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-maven-plugin 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/compile-only-dependency-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-data-jpa 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.acme 33 | foo 34 | true 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/gitignore.gen: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /nbbuild/ 22 | /dist/ 23 | /nbdist/ 24 | /.nb-gradle/ 25 | /build/ 26 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/kotlin-java11-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 11 19 | 1.1.1 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter 26 | 27 | 28 | org.jetbrains.kotlin 29 | kotlin-reflect 30 | 31 | 32 | org.jetbrains.kotlin 33 | kotlin-stdlib-jdk8 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | 44 | ${project.basedir}/src/main/kotlin 45 | ${project.basedir}/src/test/kotlin 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-maven-plugin 50 | 51 | 52 | org.jetbrains.kotlin 53 | kotlin-maven-plugin 54 | 55 | 56 | -Xjsr305=strict 57 | 58 | 59 | spring 60 | 61 | 62 | 63 | 64 | org.jetbrains.kotlin 65 | kotlin-maven-allopen 66 | ${kotlin.version} 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/repositories-milestone-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.0.M1 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.acme 24 | foo 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | 45 | spring-snapshots 46 | Spring Snapshots 47 | https://repo.spring.io/snapshot 48 | 49 | true 50 | 51 | 52 | 53 | spring-milestones 54 | Spring Milestones 55 | https://repo.spring.io/milestone 56 | 57 | 58 | 59 | 60 | spring-snapshots 61 | Spring Snapshots 62 | https://repo.spring.io/snapshot 63 | 64 | true 65 | 66 | 67 | 68 | spring-milestones 69 | Spring Milestones 70 | https://repo.spring.io/milestone 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/repositories-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.acme 24 | bar 25 | 26 | 27 | org.acme 28 | foo 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | 49 | foo-repository 50 | foo-repo 51 | https://example.com/foo 52 | 53 | 54 | bar-repository 55 | bar-repo 56 | https://example.com/bar 57 | 58 | true 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/project/maven/version-override-pom.xml.gen: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.1.RELEASE 9 | 10 | 11 | com.example 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 0.2.0.RELEASE 20 | 0.1.0.RELEASE 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-test 32 | test 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /initializr-generator/src/test/resources/templates/custom.txt: -------------------------------------------------------------------------------- 1 | Custom resources 2 | 3 | {{groupId}} 4 | {{customValue}} -------------------------------------------------------------------------------- /initializr-web/src/assembly/snippets.xml: -------------------------------------------------------------------------------- 1 | 5 | snippets 6 | 7 | zip 8 | 9 | false 10 | 11 | 12 | target/snippets 13 | 14 | 15 | stubs/** 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /initializr-web/src/assembly/stub.xml: -------------------------------------------------------------------------------- 1 | 5 | stubs 6 | 7 | jar 8 | 9 | false 10 | 11 | 12 | target/snippets/stubs 13 | META-INF/${project.groupId}/${project.artifactId}/${project.version}/mappings 14 | 15 | **/* 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /initializr-web/src/main/java/io/spring/initializr/web/mapper/DependencyMetadataJsonMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.mapper; 18 | 19 | import io.spring.initializr.metadata.DependencyMetadata; 20 | 21 | /** 22 | * Generate a JSON representation of a set of dependencies. 23 | * 24 | * @author Stephane Nicoll 25 | */ 26 | interface DependencyMetadataJsonMapper { 27 | 28 | /** 29 | * Write a json representation of the specified metadata. 30 | * @param metadata the dependency metadata 31 | * @return the JSON representation 32 | */ 33 | String write(DependencyMetadata metadata); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /initializr-web/src/main/java/io/spring/initializr/web/mapper/InitializrMetadataJsonMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.mapper; 18 | 19 | import io.spring.initializr.metadata.InitializrMetadata; 20 | 21 | /** 22 | * Generate a JSON representation of the metadata. 23 | * 24 | * @author Stephane Nicoll 25 | */ 26 | public interface InitializrMetadataJsonMapper { 27 | 28 | /** 29 | * Write a json representation of the specified metadata. 30 | * @param metadata the initializr metadata 31 | * @param appUrl the app URL 32 | * @return the JSON representation 33 | */ 34 | String write(InitializrMetadata metadata, String appUrl); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /initializr-web/src/main/java/io/spring/initializr/web/mapper/InitializrMetadataVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.mapper; 18 | 19 | import org.springframework.http.MediaType; 20 | 21 | /** 22 | * Define the supported metadata version. 23 | * 24 | * @author Stephane Nicoll 25 | */ 26 | public enum InitializrMetadataVersion { 27 | 28 | /** 29 | * HAL-compliant metadata. 30 | */ 31 | V2("application/vnd.initializr.v2+json"), 32 | 33 | /** 34 | * Add "versionRange" attribute to any dependency to specify which Spring Boot 35 | * versions are compatible with it. Also provide a separate "dependencies" endpoint to 36 | * query dependencies metadata. 37 | */ 38 | V2_1("application/vnd.initializr.v2.1+json"); 39 | 40 | private final MediaType mediaType; 41 | 42 | InitializrMetadataVersion(String mediaType) { 43 | this.mediaType = MediaType.parseMediaType(mediaType); 44 | } 45 | 46 | public MediaType getMediaType() { 47 | return this.mediaType; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /initializr-web/src/main/java/io/spring/initializr/web/mapper/LinkMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.mapper; 18 | 19 | import java.util.ArrayList; 20 | import java.util.LinkedHashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | import com.fasterxml.jackson.databind.node.ArrayNode; 25 | import com.fasterxml.jackson.databind.node.JsonNodeFactory; 26 | import com.fasterxml.jackson.databind.node.ObjectNode; 27 | import io.spring.initializr.metadata.Link; 28 | 29 | /** 30 | * Generate a json representation for {@link Link}. 31 | * 32 | * @author Stephane Nicoll 33 | */ 34 | public final class LinkMapper { 35 | 36 | private static final JsonNodeFactory nodeFactory = JsonNodeFactory.instance; 37 | 38 | private LinkMapper() { 39 | } 40 | 41 | /** 42 | * Map the specified links to a json model. If several links share the same relation, 43 | * they are grouped together. 44 | * @param links the links to map 45 | * @return a model for the specified links 46 | */ 47 | public static ObjectNode mapLinks(List links) { 48 | ObjectNode result = nodeFactory.objectNode(); 49 | Map> byRel = new LinkedHashMap<>(); 50 | links.forEach((it) -> byRel.computeIfAbsent(it.getRel(), (k) -> new ArrayList<>()) 51 | .add(it)); 52 | byRel.forEach((rel, l) -> { 53 | if (l.size() == 1) { 54 | ObjectNode root = JsonNodeFactory.instance.objectNode(); 55 | mapLink(l.get(0), root); 56 | result.set(rel, root); 57 | } 58 | else { 59 | ArrayNode root = JsonNodeFactory.instance.arrayNode(); 60 | l.forEach((link) -> { 61 | ObjectNode node = JsonNodeFactory.instance.objectNode(); 62 | mapLink(link, node); 63 | root.add(node); 64 | }); 65 | result.set(rel, root); 66 | } 67 | }); 68 | return result; 69 | } 70 | 71 | private static void mapLink(Link link, ObjectNode node) { 72 | node.put("href", link.getHref()); 73 | if (link.isTemplated()) { 74 | node.put("templated", true); 75 | } 76 | if (link.getDescription() != null) { 77 | node.put("title", link.getDescription()); 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /initializr-web/src/main/java/io/spring/initializr/web/support/SpringBootMetadataReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.support; 18 | 19 | import java.io.IOException; 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | import com.fasterxml.jackson.databind.JsonNode; 24 | import com.fasterxml.jackson.databind.ObjectMapper; 25 | import com.fasterxml.jackson.databind.node.ArrayNode; 26 | import io.spring.initializr.metadata.DefaultMetadataElement; 27 | 28 | import org.springframework.web.client.RestTemplate; 29 | 30 | /** 31 | * Reads metadata from the main spring.io website. This is a stateful service: create a 32 | * new instance whenever you need to refresh the content. 33 | * 34 | * @author Stephane Nicoll 35 | */ 36 | public class SpringBootMetadataReader { 37 | 38 | private final JsonNode content; 39 | 40 | /** 41 | * Parse the content of the metadata at the specified url. 42 | * @param objectMapper the object mapper 43 | * @param restTemplate the rest template 44 | * @param url the metadata URL 45 | * @throws IOException on load error 46 | */ 47 | public SpringBootMetadataReader(ObjectMapper objectMapper, RestTemplate restTemplate, 48 | String url) throws IOException { 49 | this.content = objectMapper 50 | .readTree(restTemplate.getForObject(url, String.class)); 51 | } 52 | 53 | /** 54 | * Return the boot versions parsed by this instance. 55 | * @return the versions 56 | */ 57 | public List getBootVersions() { 58 | ArrayNode releases = (ArrayNode) this.content.get("projectReleases"); 59 | List list = new ArrayList<>(); 60 | for (JsonNode node : releases) { 61 | DefaultMetadataElement version = new DefaultMetadataElement(); 62 | version.setId(node.get("version").textValue()); 63 | String name = node.get("versionDisplayName").textValue(); 64 | version.setName( 65 | node.get("snapshot").booleanValue() ? name + " (SNAPSHOT)" : name); 66 | version.setDefault(node.get("current").booleanValue()); 67 | list.add(version); 68 | } 69 | return list; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /initializr-web/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | io.spring.initializr.web.autoconfigure.InitializrAutoConfiguration 3 | 4 | org.springframework.boot.env.EnvironmentPostProcessor=\ 5 | io.spring.initializr.web.autoconfigure.CloudfoundryEnvironmentPostProcessor 6 | -------------------------------------------------------------------------------- /initializr-web/src/main/resources/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-web/src/main/resources/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /initializr-web/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-web/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /initializr-web/src/main/resources/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-web/src/main/resources/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /initializr-web/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-web/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /initializr-web/src/main/resources/static/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-web/src/main/resources/static/img/favicon.png -------------------------------------------------------------------------------- /initializr-web/src/main/resources/static/img/platform-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/initializr/f5395c07e1a4d3d60998f5c798cc3cf22c1566f4/initializr-web/src/main/resources/static/img/platform-bg.png -------------------------------------------------------------------------------- /initializr-web/src/main/resources/templates/gs.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spring Initializr 5 | 7 | 8 | 9 |

10 | 40 |

Getting Started

41 |
42 |
    43 | {{#repos}} 44 |
  • {{name}}}
  • 45 | {{/repos}} 46 |
47 |
48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /initializr-web/src/test/java/io/spring/initializr/web/AbstractFullStackInitializrIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web; 18 | 19 | import io.spring.initializr.web.AbstractInitializrIntegrationTests.Config; 20 | 21 | import org.springframework.boot.test.context.SpringBootTest; 22 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 23 | import org.springframework.boot.web.server.LocalServerPort; 24 | 25 | /** 26 | * @author Stephane Nicoll 27 | * @author Dave Syer 28 | */ 29 | @SpringBootTest(classes = Config.class, webEnvironment = WebEnvironment.RANDOM_PORT) 30 | public abstract class AbstractFullStackInitializrIntegrationTests 31 | extends AbstractInitializrIntegrationTests { 32 | 33 | @LocalServerPort 34 | protected int port; 35 | 36 | protected String host = "localhost"; 37 | 38 | @Override 39 | protected String createUrl(String context) { 40 | return "http://" + this.host + ":" + this.port 41 | + (context.startsWith("/") ? context : "/" + context); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /initializr-web/src/test/java/io/spring/initializr/web/mapper/DependencyMetadataJsonMapperTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.mapper; 18 | 19 | import java.net.URL; 20 | import java.util.Collections; 21 | 22 | import io.spring.initializr.metadata.BillOfMaterials; 23 | import io.spring.initializr.metadata.Dependency; 24 | import io.spring.initializr.metadata.DependencyMetadata; 25 | import io.spring.initializr.metadata.Repository; 26 | import io.spring.initializr.util.Version; 27 | import org.json.JSONObject; 28 | import org.junit.jupiter.api.Test; 29 | 30 | import static org.assertj.core.api.Assertions.assertThat; 31 | 32 | /** 33 | * @author Stephane Nicoll 34 | */ 35 | class DependencyMetadataJsonMapperTests { 36 | 37 | private final DependencyMetadataJsonMapper mapper = new DependencyMetadataV21JsonMapper(); 38 | 39 | @Test 40 | void mapDependency() throws Exception { 41 | Dependency d = Dependency.withId("foo", "org.foo", "foo"); 42 | d.setRepository("my-repo"); 43 | d.setBom("my-bom"); 44 | Repository repository = new Repository(); 45 | repository.setName("foo-repo"); 46 | repository.setUrl(new URL("http://example.com/foo")); 47 | BillOfMaterials bom = BillOfMaterials.create("org.foo", "foo-bom", 48 | "1.0.0.RELEASE"); 49 | DependencyMetadata metadata = new DependencyMetadata( 50 | Version.parse("1.2.0.RELEASE"), Collections.singletonMap(d.getId(), d), 51 | Collections.singletonMap("repo-id", repository), 52 | Collections.singletonMap("bom-id", bom)); 53 | JSONObject content = new JSONObject(this.mapper.write(metadata)); 54 | assertThat(content.getJSONObject("dependencies").getJSONObject("foo") 55 | .getString("bom")).isEqualTo("my-bom"); 56 | assertThat(content.getJSONObject("dependencies").getJSONObject("foo") 57 | .getString("repository")).isEqualTo("my-repo"); 58 | assertThat(content.getJSONObject("repositories").getJSONObject("repo-id") 59 | .getString("name")).isEqualTo("foo-repo"); 60 | assertThat(content.getJSONObject("boms").getJSONObject("bom-id") 61 | .getString("artifactId")).isEqualTo("foo-bom"); 62 | assertThat(content.getJSONObject("boms").getJSONObject("bom-id") 63 | .getString("version")).isEqualTo("1.0.0.RELEASE"); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /initializr-web/src/test/java/io/spring/initializr/web/project/MainControllerDefaultsIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.project; 18 | 19 | import io.spring.initializr.test.generator.PomAssert; 20 | import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests; 21 | import org.junit.jupiter.api.Test; 22 | 23 | import org.springframework.test.context.ActiveProfiles; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | 27 | /** 28 | * @author Stephane Nicoll 29 | */ 30 | @ActiveProfiles({ "test-default", "test-custom-defaults" }) 31 | class MainControllerDefaultsIntegrationTests 32 | extends AbstractInitializrControllerIntegrationTests { 33 | 34 | // see defaults customization 35 | 36 | @Test 37 | void generateDefaultPom() { 38 | String content = getRestTemplate().getForObject(createUrl("/pom.xml?style=web"), 39 | String.class); 40 | PomAssert pomAssert = new PomAssert(content); 41 | pomAssert.hasGroupId("org.foo").hasArtifactId("foo-bar") 42 | .hasVersion("1.2.4-SNAPSHOT").hasPackaging("jar").hasName("FooBar") 43 | .hasDescription("FooBar Project"); 44 | } 45 | 46 | @Test 47 | void defaultsAppliedToHome() { 48 | String body = htmlHome(); 49 | assertThat(body).as("custom groupId not found").contains("org.foo"); 50 | assertThat(body).as("custom artifactId not found").contains("foo-bar"); 51 | assertThat(body).as("custom name not found").contains("FooBar"); 52 | assertThat(body).as("custom description not found").contains("FooBar Project"); 53 | assertThat(body).as("custom package not found").contains("org.foo.demo"); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /initializr-web/src/test/java/io/spring/initializr/web/project/MainControllerDependenciesTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.project; 18 | 19 | import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests; 20 | import org.json.JSONException; 21 | import org.json.JSONObject; 22 | import org.junit.jupiter.api.Test; 23 | import org.skyscreamer.jsonassert.JSONAssert; 24 | import org.skyscreamer.jsonassert.JSONCompareMode; 25 | 26 | import org.springframework.http.HttpHeaders; 27 | import org.springframework.http.ResponseEntity; 28 | import org.springframework.test.context.ActiveProfiles; 29 | 30 | import static org.assertj.core.api.Assertions.assertThat; 31 | 32 | /** 33 | * @author Stephane Nicoll 34 | */ 35 | @ActiveProfiles("test-default") 36 | class MainControllerDependenciesTests 37 | extends AbstractInitializrControllerIntegrationTests { 38 | 39 | @Test 40 | void noBootVersion() throws JSONException { 41 | ResponseEntity response = execute("/dependencies", String.class, null, 42 | "application/json"); 43 | assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); 44 | validateContentType(response, CURRENT_METADATA_MEDIA_TYPE); 45 | validateDependenciesOutput("2.1.4", response.getBody()); 46 | } 47 | 48 | @Test 49 | void filteredDependencies() throws JSONException { 50 | ResponseEntity response = execute( 51 | "/dependencies?bootVersion=2.2.1.RELEASE", String.class, null, 52 | "application/json"); 53 | assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); 54 | validateContentType(response, CURRENT_METADATA_MEDIA_TYPE); 55 | validateDependenciesOutput("2.2.1", response.getBody()); 56 | } 57 | 58 | protected void validateDependenciesOutput(String version, String actual) 59 | throws JSONException { 60 | JSONObject expected = readJsonFrom( 61 | "metadata/dependencies/test-dependencies-" + version + ".json"); 62 | JSONAssert.assertEquals(expected, new JSONObject(actual), JSONCompareMode.STRICT); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /initializr-web/src/test/java/io/spring/initializr/web/project/MainControllerEnvIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.project; 18 | 19 | import java.net.URI; 20 | 21 | import io.spring.initializr.test.generator.ProjectAssert; 22 | import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests; 23 | import org.junit.jupiter.api.Test; 24 | 25 | import org.springframework.http.HttpStatus; 26 | import org.springframework.http.ResponseEntity; 27 | import org.springframework.test.context.ActiveProfiles; 28 | 29 | import static org.assertj.core.api.Assertions.assertThat; 30 | 31 | /** 32 | * Integration tests with custom environment. 33 | * 34 | * @author Stephane Nicoll 35 | */ 36 | @ActiveProfiles({ "test-default", "test-custom-env" }) 37 | class MainControllerEnvIntegrationTests 38 | extends AbstractInitializrControllerIntegrationTests { 39 | 40 | @Test 41 | void downloadCliWithCustomRepository() throws Exception { 42 | ResponseEntity entity = getRestTemplate().getForEntity(createUrl("/spring"), 43 | String.class); 44 | assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND); 45 | String expected = "https://repo.spring.io/lib-release/org/springframework/boot/spring-boot-cli/2.1.4.RELEASE/spring-boot-cli-2.1.4.RELEASE-bin.zip"; 46 | assertThat(entity.getHeaders().getLocation()).isEqualTo(new URI(expected)); 47 | } 48 | 49 | @Test 50 | void generateProjectWithInvalidName() { 51 | downloadZip("/starter.zip?style=data-jpa&name=Invalid") 52 | .isJavaProject(ProjectAssert.DEFAULT_PACKAGE_NAME, "FooBarApplication") 53 | .isMavenProject().hasStaticAndTemplatesResources(false).pomAssert() 54 | .hasDependenciesCount(2).hasSpringBootStarterDependency("data-jpa") 55 | .hasSpringBootStarterTest(); 56 | } 57 | 58 | @Test 59 | void googleAnalytics() { 60 | String body = htmlHome(); 61 | assertThat(body).contains("https://www.googletagmanager.com/gtm.js"); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /initializr-web/src/test/java/io/spring/initializr/web/project/ProjectGenerationPostProcessorTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.project; 18 | 19 | import io.spring.initializr.generator.ProjectRequest; 20 | import io.spring.initializr.generator.ProjectRequestPostProcessor; 21 | import io.spring.initializr.metadata.InitializrMetadata; 22 | import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests; 23 | import io.spring.initializr.web.project.ProjectGenerationPostProcessorTests.ProjectRequestPostProcessorConfiguration; 24 | import org.junit.jupiter.api.Test; 25 | 26 | import org.springframework.context.annotation.Bean; 27 | import org.springframework.context.annotation.Configuration; 28 | import org.springframework.context.annotation.Import; 29 | import org.springframework.core.annotation.Order; 30 | import org.springframework.test.context.ActiveProfiles; 31 | 32 | @ActiveProfiles("test-default") 33 | @Import(ProjectRequestPostProcessorConfiguration.class) 34 | class ProjectGenerationPostProcessorTests 35 | extends AbstractInitializrControllerIntegrationTests { 36 | 37 | @Test 38 | void postProcessorsInvoked() { 39 | downloadZip("/starter.zip?bootVersion=2.0.4.RELEASE&javaVersion=1.8") 40 | .isJavaProject().isMavenProject().pomAssert() 41 | .hasSpringBootParent("2.2.3.RELEASE").hasProperty("java.version", "1.7"); 42 | } 43 | 44 | @Configuration 45 | static class ProjectRequestPostProcessorConfiguration { 46 | 47 | @Bean 48 | @Order(2) 49 | ProjectRequestPostProcessor secondPostProcessor() { 50 | return new ProjectRequestPostProcessor() { 51 | @Override 52 | public void postProcessBeforeResolution(ProjectRequest request, 53 | InitializrMetadata metadata) { 54 | request.setJavaVersion("1.7"); 55 | } 56 | }; 57 | } 58 | 59 | @Bean 60 | @Order(1) 61 | ProjectRequestPostProcessor firstPostProcessor() { 62 | return new ProjectRequestPostProcessor() { 63 | @Override 64 | public void postProcessBeforeResolution(ProjectRequest request, 65 | InitializrMetadata metadata) { 66 | request.setJavaVersion("1.2"); 67 | request.setBootVersion("2.2.3.RELEASE"); 68 | } 69 | }; 70 | } 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /initializr-web/src/test/java/io/spring/initializr/web/test/MockMvcClientHttpRequestFactoryTestExecutionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.test; 18 | 19 | import org.springframework.beans.factory.config.ConfigurableBeanFactory; 20 | import org.springframework.test.context.TestContext; 21 | import org.springframework.test.context.support.AbstractTestExecutionListener; 22 | import org.springframework.test.web.servlet.MockMvc; 23 | 24 | /** 25 | * @author Dave Syer 26 | */ 27 | public final class MockMvcClientHttpRequestFactoryTestExecutionListener 28 | extends AbstractTestExecutionListener { 29 | 30 | private MockMvcClientHttpRequestFactory factory; 31 | 32 | @Override 33 | public void beforeTestClass(TestContext testContext) throws Exception { 34 | ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) testContext 35 | .getApplicationContext().getAutowireCapableBeanFactory(); 36 | if (!beanFactory.containsBean("mockMvcClientHttpRequestFactory")) { 37 | this.factory = new MockMvcClientHttpRequestFactory( 38 | beanFactory.getBean(MockMvc.class)); 39 | beanFactory.registerSingleton("mockMvcClientHttpRequestFactory", 40 | this.factory); 41 | } 42 | else { 43 | this.factory = beanFactory.getBean("mockMvcClientHttpRequestFactory", 44 | MockMvcClientHttpRequestFactory.class); 45 | } 46 | } 47 | 48 | @Override 49 | public void beforeTestMethod(TestContext testContext) throws Exception { 50 | if (this.factory != null) { 51 | this.factory.setTest(testContext.getTestClass(), testContext.getTestMethod()); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /initializr-web/src/test/java/io/spring/initializr/web/ui/UiControllerIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.initializr.web.ui; 18 | 19 | import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests; 20 | import org.json.JSONException; 21 | import org.json.JSONObject; 22 | import org.junit.jupiter.api.Test; 23 | import org.skyscreamer.jsonassert.JSONAssert; 24 | import org.skyscreamer.jsonassert.JSONCompareMode; 25 | 26 | import org.springframework.http.MediaType; 27 | import org.springframework.http.ResponseEntity; 28 | import org.springframework.test.context.ActiveProfiles; 29 | 30 | /** 31 | * @author Stephane Nicoll 32 | */ 33 | @ActiveProfiles("test-default") 34 | class UiControllerIntegrationTests extends AbstractInitializrControllerIntegrationTests { 35 | 36 | @Test 37 | void dependenciesNoVersion() throws JSONException { 38 | ResponseEntity response = execute("/ui/dependencies", String.class, null); 39 | validateContentType(response, MediaType.APPLICATION_JSON); 40 | validateDependenciesOutput("all", response.getBody()); 41 | } 42 | 43 | @Test 44 | void dependenciesSpecificVersion() throws JSONException { 45 | ResponseEntity response = execute( 46 | "/ui/dependencies?version=1.1.2.RELEASE", String.class, null); 47 | validateContentType(response, MediaType.APPLICATION_JSON); 48 | validateDependenciesOutput("1.1.2", response.getBody()); 49 | } 50 | 51 | protected void validateDependenciesOutput(String version, String actual) 52 | throws JSONException { 53 | JSONObject expected = readJsonFrom( 54 | "metadata/ui/test-dependencies-" + version + ".json"); 55 | JSONAssert.assertEquals(expected, new JSONObject(actual), JSONCompareMode.STRICT); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /initializr-web/src/test/resources/metadata/dependencies/test-dependencies-2.1.4.json: -------------------------------------------------------------------------------- 1 | { 2 | "bootVersion": "2.1.4.RELEASE", 3 | "repositories": { 4 | "my-api-repo-1": { 5 | "name": "repo1", 6 | "url": "http://example.com/repo1", 7 | "snapshotEnabled": false 8 | } 9 | }, 10 | "boms": { 11 | "my-api-bom": { 12 | "groupId": "org.acme", 13 | "artifactId": "my-api-bom", 14 | "version": "1.0.0.RELEASE", 15 | "repositories": [ 16 | "my-api-repo-1" 17 | ] 18 | } 19 | }, 20 | "dependencies": { 21 | "web": { 22 | "groupId": "org.springframework.boot", 23 | "scope": "compile", 24 | "artifactId": "spring-boot-starter-web" 25 | }, 26 | "security": { 27 | "groupId": "org.springframework.boot", 28 | "scope": "compile", 29 | "artifactId": "spring-boot-starter-security" 30 | }, 31 | "data-jpa": { 32 | "groupId": "org.springframework.boot", 33 | "scope": "compile", 34 | "artifactId": "spring-boot-starter-data-jpa" 35 | }, 36 | "org.acme:foo": { 37 | "groupId": "org.acme", 38 | "scope": "compile", 39 | "artifactId": "foo", 40 | "version": "1.3.5" 41 | }, 42 | "org.acme:bar": { 43 | "groupId": "org.acme", 44 | "scope": "compile", 45 | "artifactId": "bar", 46 | "version": "2.1.0" 47 | }, 48 | "org.acme:bur": { 49 | "groupId": "org.acme", 50 | "scope": "test", 51 | "artifactId": "bur", 52 | "version": "2.1.0" 53 | }, 54 | "my-api": { 55 | "groupId": "org.acme", 56 | "scope": "provided", 57 | "artifactId": "my-api", 58 | "bom": "my-api-bom" 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /initializr-web/src/test/resources/metadata/dependencies/test-dependencies-2.2.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "bootVersion": "2.2.1.RELEASE", 3 | "repositories": { 4 | "my-api-repo-2": { 5 | "name": "repo2", 6 | "url": "http://example.com/repo2", 7 | "snapshotEnabled": false 8 | } 9 | }, 10 | "boms": { 11 | "my-api-bom": { 12 | "groupId": "org.acme", 13 | "artifactId": "my-api-bom", 14 | "version": "2.0.0.RELEASE", 15 | "repositories": [ 16 | "my-api-repo-2" 17 | ] 18 | } 19 | }, 20 | "dependencies": { 21 | "web": { 22 | "groupId": "org.springframework.boot", 23 | "scope": "compile", 24 | "artifactId": "spring-boot-starter-web" 25 | }, 26 | "security": { 27 | "groupId": "org.springframework.boot", 28 | "scope": "compile", 29 | "artifactId": "spring-boot-starter-security" 30 | }, 31 | "data-jpa": { 32 | "groupId": "org.springframework.boot", 33 | "scope": "compile", 34 | "artifactId": "spring-boot-starter-data-jpa" 35 | }, 36 | "org.acme:foo": { 37 | "groupId": "org.acme", 38 | "scope": "compile", 39 | "artifactId": "foo", 40 | "version": "1.3.5" 41 | }, 42 | "org.acme:bar": { 43 | "groupId": "org.acme", 44 | "scope": "compile", 45 | "artifactId": "bar", 46 | "version": "2.1.0" 47 | }, 48 | "org.acme:biz": { 49 | "groupId": "org.acme", 50 | "scope": "runtime", 51 | "artifactId": "biz", 52 | "version": "1.3.5" 53 | }, 54 | "my-api": { 55 | "groupId": "org.acme", 56 | "scope": "provided", 57 | "artifactId": "my-api", 58 | "bom": "my-api-bom" 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /initializr-web/src/test/resources/metadata/ui/test-dependencies-1.1.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | { 4 | "id": "web", 5 | "name": "Web", 6 | "description": "Web dependency description", 7 | "group": "Core" 8 | }, 9 | { 10 | "id": "security", 11 | "name": "Security", 12 | "group": "Core" 13 | }, 14 | { 15 | "id": "data-jpa", 16 | "name": "Data JPA", 17 | "group": "Core", 18 | "keywords": "jpa" 19 | }, 20 | { 21 | "id": "org.acme:foo", 22 | "name": "Foo", 23 | "group": "Other", 24 | "keywords": "thefoo,dafoo", 25 | "weight": 42 26 | }, 27 | { 28 | "id": "org.acme:bar", 29 | "name": "Bar", 30 | "group": "Other" 31 | }, 32 | { 33 | "id": "my-api", 34 | "name": "My API", 35 | "group": "Other" 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /initializr-web/src/test/resources/metadata/ui/test-dependencies-all.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | { 4 | "id": "web", 5 | "name": "Web", 6 | "description": "Web dependency description", 7 | "group": "Core" 8 | }, 9 | { 10 | "id": "security", 11 | "name": "Security", 12 | "group": "Core" 13 | }, 14 | { 15 | "id": "data-jpa", 16 | "name": "Data JPA", 17 | "group": "Core", 18 | "keywords": "jpa" 19 | }, 20 | { 21 | "id": "org.acme:foo", 22 | "name": "Foo", 23 | "group": "Other", 24 | "keywords": "thefoo,dafoo", 25 | "weight": 42 26 | }, 27 | { 28 | "id": "org.acme:bar", 29 | "name": "Bar", 30 | "group": "Other" 31 | }, 32 | { 33 | "id": "org.acme:biz", 34 | "name": "Biz", 35 | "group": "Other" 36 | }, 37 | { 38 | "id": "org.acme:bur", 39 | "name": "Bur", 40 | "group": "Other" 41 | }, 42 | { 43 | "id": "my-api", 44 | "name": "My API", 45 | "group": "Other" 46 | } 47 | ] 48 | } -------------------------------------------------------------------------------- /initializr-web/src/test/resources/org/springframework/restdocs/templates/asciidoctor/default-response-fields.snippet: -------------------------------------------------------------------------------- 1 | [source,json,options="nowrap"] 2 | ---- 3 | {{value}} 4 | ---- --------------------------------------------------------------------------------