From 8d6bdfdf411ac1350983a8dcdc63d53ba53c8836 Mon Sep 17 00:00:00 2001 From: Michal Karm Babacek Date: Mon, 11 Apr 2022 14:44:40 +0200 Subject: [PATCH 1/2] Thorntail -> Quarkus --- .circleci/config.yml | 29 +- .github/workflows/main.yml | 75 ++-- .mvn/wrapper/MavenWrapperDownloader.java | 142 ++++++ .mvn/wrapper/maven-wrapper.properties | 18 + Container/Dockerfile | 11 - Container/Dockerfile.CI | 35 -- Container/Dockerfile.jvm | 11 + Container/README.md | 167 ++------ Container/settings.xml | 47 +- Container/start.sh | 32 -- mvnw | 316 ++++++++++++++ mvnw.cmd | 188 ++++++++ pom.xml | 405 +++++++----------- releasing.md | 7 +- .../eclipse/microprofile/starter/APITest.java | 99 ----- .../microprofile/starter/DataBean.java | 4 +- .../starter/FakeDirectoryCreator.java | 4 +- .../starter/StarterUnexpectedException.java | 2 +- .../eclipse/microprofile/starter/Version.java | 10 +- .../microprofile/starter/ZipFileCreator.java | 2 +- .../servers/AbstractMicroprofileAddon.java | 8 +- .../servers/MicroprofileServersAddon.java | 4 +- .../servers/model/JDKSelector.java | 4 +- .../servers/model/MicroprofileSpec.java | 2 +- .../servers/model/ServerMPVersion.java | 6 +- .../servers/model/StandaloneMPSpec.java | 18 +- .../servers/model/SupportedServer.java | 20 +- .../servers/model/VersionSpecMatrix.java | 156 +++---- .../servers/server/HelidonServer.java | 4 +- .../servers/server/KumuluzeeServer.java | 5 +- .../servers/server/LibertyServer.java | 40 +- .../servers/server/PayaraMicroServer.java | 2 +- .../servers/server/QuarkusServer.java | 2 +- .../servers/server/ThorntailServer.java | 2 +- .../servers/server/TomeeServer.java | 2 +- .../servers/server/WildFlyServer.java | 2 +- .../servers/server/WildflySwarmServer.java | 4 +- .../starter/core/AlternativesProvider.java | 2 +- .../core/TemplateVariableProvider.java | 2 +- .../starter/core/addon/AddonManager.java | 12 +- .../core/artifacts/AbstractCreator.java | 2 +- .../core/artifacts/BuildToolCreator.java | 2 +- .../starter/core/artifacts/CDICreator.java | 2 +- .../starter/core/artifacts/Creator.java | 10 +- .../core/artifacts/DirectoryCreator.java | 2 +- .../starter/core/artifacts/FileCreator.java | 2 +- .../starter/core/artifacts/GradleCreator.java | 6 +- .../starter/core/artifacts/JavaCreator.java | 2 +- .../starter/core/artifacts/MavenCreator.java | 6 +- .../core/artifacts/TemplateEngine.java | 2 +- .../core/config/ConfigurationParameter.java | 2 +- .../ConfigurationParameterProducer.java | 2 +- .../JessieConfigurationException.java | 2 +- .../core/exception/JessieException.java | 2 +- .../exception/JessieUnexpectedException.java | 2 +- .../core/exception/TechnicalException.java | 2 +- .../file/ConfigFileNotFoundException.java | 2 +- .../starter/core/file/ModelReader.java | 4 +- .../starter/core/file/YAMLReader.java | 2 +- .../starter/core/files/FileCopyEngine.java | 4 +- .../core/files/FileResolutionException.java | 2 +- .../starter/core/files/FilesLocator.java | 20 +- .../files/JessieFileTemplateResolver.java | 4 +- .../TemplateFileResolutionException.java | 2 +- .../starter/core/files/ThymeleafEngine.java | 4 +- .../starter/core/model/BeansXMLMode.java | 5 +- .../starter/core/model/BuildTool.java | 2 +- .../starter/core/model/ComboBoxItem.java | 2 +- .../starter/core/model/JavaSEVersion.java | 6 +- .../starter/core/model/JessieMaven.java | 2 +- .../starter/core/model/JessieModel.java | 2 +- .../core/model/JessieModelInitializer.java | 2 +- .../core/model/JessieSpecification.java | 3 +- .../core/model/MicroProfileVersion.java | 10 +- .../starter/core/model/ModelManager.java | 34 +- .../starter/core/model/OptionValue.java | 4 +- .../OptionValueSingleValueException.java | 2 +- .../starter/core/model/ViewType.java | 6 +- .../JavaSEVersionDeserializer.java | 2 +- .../MicroProfileVersionDeserializer.java | 2 +- .../deserializer/OptionsDeserializer.java | 8 +- .../PropertyValueNotSupportedException.java | 2 +- .../deserializer/ViewTypeDeserializer.java | 2 +- .../serializer/OptionValueSerializer.java | 2 +- .../core/templates/TemplateModelLoader.java | 8 +- .../core/templates/TemplateModelValues.java | 4 +- .../core/validation/ModelValidation.java | 4 +- .../validation/ModelValidationException.java | 2 +- .../core/validation/PackageNameValidator.java | 4 +- .../exception/CustomExceptionHandler.java | 4 +- .../CustomExceptionHandlerFactory.java | 4 +- .../starter/log/DynamoDBLogger.java | 62 +-- .../microprofile/starter/log/ErrorLogger.java | 8 +- .../microprofile/starter/log/LoggingTask.java | 4 +- .../microprofile/starter/rest/API.java | 2 +- .../starter/rest/APIEndpointLatest.java | 4 +- .../starter/rest/APIEndpointV1.java | 4 +- .../starter/rest/APIEndpointV2.java | 4 +- .../starter/rest/APIEndpointV3.java | 4 +- .../starter/rest/APIEndpointV4.java | 4 +- .../starter/rest/APIEndpointV5.java | 4 +- .../starter/rest/APIEndpointV6.java | 2 +- .../microprofile/starter/rest/APIService.java | 32 +- .../rest/model/MPOptionsAvailable.java | 4 +- .../starter/rest/model/Project.java | 2 +- .../starter/rest/model/ServerOptions.java | 2 +- .../starter/rest/model/ServerOptionsV5.java | 2 +- .../starter/spi/AbstractAddon.java | 2 +- .../microprofile/starter/spi/JessieAddon.java | 2 +- .../spi/JessieAlternativesProvider.java | 2 +- .../starter/spi/JessieGradleAdapter.java | 2 +- .../starter/spi/JessieMavenAdapter.java | 2 +- .../microprofile/starter/spi/MavenHelper.java | 27 +- .../starter/validation/PackageValidator.java | 2 +- .../microprofile/starter/view/EngineData.java | 2 +- .../starter/view/GeneratorDataBean.java | 29 +- .../starter/view/HeaderFilter.java | 2 +- .../CustomSelectManyCheckboxRenderer.java | 4 +- src/main/liberty/config/server.xml | 20 - src/main/resources/META-INF/beans.xml | 2 +- .../META-INF}/faces-config.xml | 8 +- .../META-INF/resources}/index.xhtml | 2 +- .../resources}/resources/css/starter-1.4.css | 2 +- .../resources/img/MP-logo-w-tagline-1.png | Bin .../META-INF/resources}/resources/img/mp.ico | Bin .../resources}/resources/script/getHost.js | 0 .../WEB-INF => resources/META-INF}/web.xml | 41 +- src/main/resources/application.properties | 0 src/main/resources/files/readme.md.tpl | 2 + src/main/resources/pom-servers.xml | 2 +- src/main/resources/templates/defaultMP.yaml | 2 +- src/main/resources/templates/templates.yaml | 2 +- src/{it => test}/README.md | 24 +- .../microprofile/starter/APIITCase.java | 103 +++++ .../starter/TestMatrixITCase.java} | 380 ++++++++-------- .../core/TemplateVariableProviderTest.java | 13 +- .../core/artifacts/DirectoryCreatorTest.java | 13 +- .../starter/core/model/JessieMavenTest.java | 13 +- .../dynamologger/DynamoDBLoggerTest.java | 4 +- .../readmeparser/ReadmeParserTest.java | 63 ++- .../microprofile/starter/utils/Commands.java | 225 +++++----- .../microprofile/starter/utils/Logs.java | 48 ++- .../microprofile/starter/utils/MPSpecGET.java | 2 +- .../starter/utils/MPSpecPOST.java | 2 +- .../starter/utils/ReadmeParser.java | 10 +- .../starter/utils/SpecSelection.java | 2 +- .../starter/utils/WebpageTester.java | 12 +- .../microprofile/starter/utils/Whitelist.java | 25 +- src/test/resources/arquillian.xml | 11 - .../v3/supportMatrix.json.segments | 6 +- .../v3/supportMatrix_servers.json.segments | 10 +- .../v4/supportMatrix.json.segments | 4 +- .../v4/supportMatrix_servers.json.segments | 13 +- .../v5/supportMatrix.json.segments | 4 +- .../v5/supportMatrix_servers.json.segments | 12 +- .../v6/supportMatrix.json.segments | 4 +- .../v6/supportMatrix_servers.json.segments | 15 +- version.txt.bat | 2 - 158 files changed, 1951 insertions(+), 1493 deletions(-) create mode 100644 .mvn/wrapper/MavenWrapperDownloader.java create mode 100644 .mvn/wrapper/maven-wrapper.properties delete mode 100644 Container/Dockerfile delete mode 100644 Container/Dockerfile.CI create mode 100644 Container/Dockerfile.jvm delete mode 100755 Container/start.sh create mode 100755 mvnw create mode 100755 mvnw.cmd delete mode 100644 src/it/java/org/eclipse/microprofile/starter/APITest.java delete mode 100644 src/main/liberty/config/server.xml rename src/main/{webapp/WEB-INF => resources/META-INF}/faces-config.xml (86%) rename src/main/{webapp => resources/META-INF/resources}/index.xhtml (99%) rename src/main/{webapp => resources/META-INF/resources}/resources/css/starter-1.4.css (99%) rename src/main/{webapp => resources/META-INF/resources}/resources/img/MP-logo-w-tagline-1.png (100%) rename src/main/{webapp => resources/META-INF/resources}/resources/img/mp.ico (100%) rename src/main/{webapp => resources/META-INF/resources}/resources/script/getHost.js (100%) rename src/main/{webapp/WEB-INF => resources/META-INF}/web.xml (69%) create mode 100644 src/main/resources/application.properties rename src/{it => test}/README.md (79%) create mode 100644 src/test/java/org/eclipse/microprofile/starter/APIITCase.java rename src/{it/java/org/eclipse/microprofile/starter/TestMatrixTest.java => test/java/org/eclipse/microprofile/starter/TestMatrixITCase.java} (60%) rename src/{it => test}/java/org/eclipse/microprofile/starter/utils/Commands.java (54%) rename src/{it => test}/java/org/eclipse/microprofile/starter/utils/Logs.java (67%) rename src/{it => test}/java/org/eclipse/microprofile/starter/utils/MPSpecGET.java (97%) rename src/{it => test}/java/org/eclipse/microprofile/starter/utils/MPSpecPOST.java (94%) rename src/{it => test}/java/org/eclipse/microprofile/starter/utils/ReadmeParser.java (82%) rename src/{it => test}/java/org/eclipse/microprofile/starter/utils/SpecSelection.java (96%) rename src/{it => test}/java/org/eclipse/microprofile/starter/utils/WebpageTester.java (93%) rename src/{it => test}/java/org/eclipse/microprofile/starter/utils/Whitelist.java (83%) delete mode 100644 src/test/resources/arquillian.xml delete mode 100644 version.txt.bat diff --git a/.circleci/config.yml b/.circleci/config.yml index ec6bed1d..32b97111 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,37 +22,38 @@ jobs: curl -X POST -i -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $GITTER_TOKEN" \ "https://api.gitter.im/v1/rooms/$GITTER_ROOM_ID/chatMessages" -d \ "{\"text\":\"Automatic message: Hello, new [build]($CIRCLE_BUILD_URL) has started.\"}" - - run: if [[ ! -d ${HOME}/jdk-11.0.9+11 ]];then wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11/OpenJDK11U-jdk_x64_linux_hotspot_11.0.9_11.tar.gz;fi; - - run: if [[ ! -d ${HOME}/jdk-11.0.9+11 ]];then tar -xvf OpenJDK11U-jdk_x64_linux_hotspot_11.0.9_11.tar.gz -C ${HOME}/;fi; + - run: if [[ ! -d ${HOME}/jdk-11.0.14.1+1 ]];then wget https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14.1_1.tar.gz;fi; + - run: if [[ ! -d ${HOME}/jdk-11.0.14.1+1 ]];then tar -xvf OpenJDK11U-jdk_x64_linux_hotspot_11.0.14.1_1.tar.gz -C ${HOME}/;fi; + # Don't forget that various severs need maven for testing, e.g. Tomee etc. - run: if [[ ! -d ${HOME}/apache-maven-3.6.3 ]];then wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz;fi; - run: if [[ ! -d ${HOME}/apache-maven-3.6.3 ]];then tar -xvf apache-maven-3.6.3-bin.tar.gz -C ${HOME}/;fi; - run: name: build-fetch command: | - export PATH=${HOME}/apache-maven-3.6.3/bin:${HOME}/jdk-11.0.9+11/bin:${PATH}; \ - export JAVA_HOME=${HOME}/jdk-11.0.9+11/; \ - mvn -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2 dependency:go-offline -Pthorntail -Dskip.integration.tests=false + export JAVA_HOME=${HOME}/jdk-11.0.14.1+1/; \ + mkdir -p ~/.m2/; \ + cp ./Container/settings.xml ~/.m2/settings.xml; \ + ./mvnw dependency:go-offline - save_cache: paths: - ${HOME}/.m2 - ${HOME}/apache-maven-3.6.3 - - ${HOME}/jdk-11.0.9+11 + - ${HOME}/jdk-11.0.14.1+1 key: v1-dependencies-{{ checksum "pom.xml" }} - run: name: package-tests no_output_timeout: 120000 command: | - export PATH=${HOME}/apache-maven-3.6.3/bin:${HOME}/jdk-11.0.9+11/bin:${PATH}; \ - export JAVA_HOME=${HOME}/jdk-11.0.9+11/; \ + export PATH=${HOME}/apache-maven-3.6.3/bin:${HOME}/jdk-11.0.14.1+1/bin:${PATH}; \ + export JAVA_HOME=${HOME}/jdk-11.0.14.1+1/; \ export WLP_JAR_EXTRACT_DIR=${HOME}; \ - mvn -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2 clean package -Pthorntail \ + ./mvnw clean package \ '-Dtest=#w*' '-Dtest=#q*' '-Dtest=#t*' '-Dtest=#k*' '-Dtest=#h*' '-Dtest=#p*' \ - -Dskip.integration.tests=false -DSTARTER_TS_WORKSPACE=/dev/shm/ + -DSTARTER_TS_WORKSPACE=/dev/shm/ - persist_to_workspace: root: . paths: - - ./target/mp-starter-hollow-thorntail.jar - - ./target/mp-starter.war + - ./target/quarkus-app - ./Container docker-build: @@ -64,11 +65,11 @@ jobs: - run: name: Prepare files for Docker build command: | - cp /tmp/workspace/Container . -R && cp /tmp/workspace/target . -R && unzip target/mp-starter-hollow-thorntail.jar -d target/mp-starter-hollow-thorntail + cp /tmp/workspace/Container . -R && cp /tmp/workspace/target . -R - run: name: Build Docker image command: | - docker build -f Container/Dockerfile -t $IMAGE_NAME:master . + docker build -f ./Container/Dockerfile.jvm -t $IMAGE_NAME:master . - run: name: Archive built Docker image command: docker save -o image.tar $IMAGE_NAME diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b42da2c4..3f58f691 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,8 +31,12 @@ env: jobs: run-units: - name: API MicroProfile Starter - runs-on: ubuntu-20.04 + name: API and WEB smoke test - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-20.04, windows-2019 ] steps: - uses: actions/checkout@v2 with: @@ -61,23 +65,32 @@ jobs: with: maven-version: 3.6.3 - name: Build and run tests for Starter + if: startsWith(matrix.os, 'windows') + run: | + cmd /C mvn --version + cmd /C mvnw.cmd --version + cmd /C java --version + copy Container\settings.xml ~\.m2\settings.xml + cmd /C mvnw.cmd clean verify -Dtest=APIITCase -DSTARTER_TS_WORKSPACE=%RUNNER_TEMP% + shell: cmd + - name: Build and run tests for Starter + if: startsWith(matrix.os, 'ubuntu') run: | mvn --version + ./mvnw --version java --version - mvn clean verify -Pthorntail -Dtest=APITest -DSTARTER_TS_WORKSPACE=$RUNNER_TEMP - - name: Prepare failure archive (if maven failed) - if: failure() - shell: bash - run: find . -type d -name '*-reports' -o -name "*.log" | tar -czf test-reports-apitest.tgz -T - - - name: Upload failure Archive (if maven failed) - uses: actions/upload-artifact@v2 - if: failure() + mkdir -p ~/.m2/ + cp ./Container/settings.xml ~/.m2/settings.xml + ./mvnw clean verify -Dtest=APIITCase -DSTARTER_TS_WORKSPACE=$RUNNER_TEMP + - uses: actions/upload-artifact@v3 + if: always() with: - name: test-reports-apitest - path: 'test-reports-apitest.tgz' + name: test-reports-apitest-${{ matrix.os }} + path: | + target/surefire-reports run-starter: - name: ${{ matrix.runtime }} MicroProfile Starter - runs-on: ubuntu-20.04 + name: ${{ matrix.runtime }} - ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: @@ -89,6 +102,7 @@ jobs: 'thorntail', 'tomee', 'wildfly' ] + os: [ ubuntu-20.04, windows-2019 ] steps: - uses: actions/checkout@v2 with: @@ -117,17 +131,30 @@ jobs: with: maven-version: 3.6.3 - name: Build and run tests for Starter + if: startsWith(matrix.os, 'windows') + # We run only a subset of tests on Windows, the "All" (all examples selected variant) + # Due to notorious instabilities in file locking in ~/.m2 on GitHub Actions runners. + # It might take some of the server's processes to release those locks. + run: | + cmd /C mvn --version + cmd /C mvnw.cmd --version + cmd /C java --version + copy Container\settings.xml ~\.m2\settings.xml + cmd /C mvnw.cmd clean verify -Dtest=TestMatrixITCase#${{ matrix.runtime }}All -DSTARTER_TS_WORKSPACE=%RUNNER_TEMP% + shell: cmd + - name: Build and run tests for Starter + if: startsWith(matrix.os, 'ubuntu') run: | mvn --version + ./mvnw --version java --version - mvn clean verify -Pthorntail -Dtest=TestMatrixTest#${{ matrix.runtime }}* -DSTARTER_TS_WORKSPACE=$RUNNER_TEMP - - name: Prepare failure archive (if maven failed) - if: failure() - shell: bash - run: find . -type d -name '*-reports' -o -name "*.log" | tar -czf test-reports-${{ matrix.runtime }}.tgz -T - - - name: Upload failure Archive (if maven failed) - uses: actions/upload-artifact@v2 - if: failure() + mkdir -p ~/.m2/ + cp ./Container/settings.xml ~/.m2/settings.xml + ./mvnw clean verify -Dtest=TestMatrixITCase#${{ matrix.runtime }}* -DSTARTER_TS_WORKSPACE=$RUNNER_TEMP + - uses: actions/upload-artifact@v3 + if: always() with: - name: test-reports-${{ matrix.runtime }} - path: 'test-reports-${{ matrix.runtime }}.tgz' + name: test-reports-${{ matrix.runtime }}-${{ matrix.os }} + path: | + target/surefire-reports + target/archived-logs diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 00000000..17add53e --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader +{ + private static final String WRAPPER_VERSION = "3.1.0"; + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/" + WRAPPER_VERSION + + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use instead of the + * default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main( String args[] ) + { + System.out.println( "- Downloader started" ); + File baseDirectory = new File( args[0] ); + System.out.println( "- Using base directory: " + baseDirectory.getAbsolutePath() ); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File( baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH ); + String url = DEFAULT_DOWNLOAD_URL; + if ( mavenWrapperPropertyFile.exists() ) + { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try + { + mavenWrapperPropertyFileInputStream = new FileInputStream( mavenWrapperPropertyFile ); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load( mavenWrapperPropertyFileInputStream ); + url = mavenWrapperProperties.getProperty( PROPERTY_NAME_WRAPPER_URL, url ); + } + catch ( IOException e ) + { + System.out.println( "- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" ); + } + finally + { + try + { + if ( mavenWrapperPropertyFileInputStream != null ) + { + mavenWrapperPropertyFileInputStream.close(); + } + } + catch ( IOException e ) + { + // Ignore ... + } + } + } + System.out.println( "- Downloading from: " + url ); + + File outputFile = new File( baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH ); + if ( !outputFile.getParentFile().exists() ) + { + if ( !outputFile.getParentFile().mkdirs() ) + { + System.out.println( "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + + "'" ); + } + } + System.out.println( "- Downloading to: " + outputFile.getAbsolutePath() ); + try + { + downloadFileFromURL( url, outputFile ); + System.out.println( "Done" ); + System.exit( 0 ); + } + catch ( Throwable e ) + { + System.out.println( "- Error downloading" ); + e.printStackTrace(); + System.exit( 1 ); + } + } + + private static void downloadFileFromURL( String urlString, File destination ) + throws Exception + { + if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null ) + { + String username = System.getenv( "MVNW_USERNAME" ); + char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray(); + Authenticator.setDefault( new Authenticator() + { + @Override + protected PasswordAuthentication getPasswordAuthentication() + { + return new PasswordAuthentication( username, password ); + } + } ); + } + URL website = new URL( urlString ); + ReadableByteChannel rbc; + rbc = Channels.newChannel( website.openStream() ); + FileOutputStream fos = new FileOutputStream( destination ); + fos.getChannel().transferFrom( rbc, 0, Long.MAX_VALUE ); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..41d82133 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/Container/Dockerfile b/Container/Dockerfile deleted file mode 100644 index da200138..00000000 --- a/Container/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM centos:7 -LABEL Author="Michal Karm Babacek " -ENV JAVA_VERSION 11 -RUN yum install java-${JAVA_VERSION}-openjdk-devel -y && yum clean all && rm -rf /var/cache/yum /tmp/* && \ - useradd -s /sbin/nologin wildfly -EXPOSE 8080/tcp -USER wildfly -WORKDIR /opt/ -COPY --chown=wildfly:wildfly target/mp-starter-hollow-thorntail /opt/mp-starter-hollow-thorntail -COPY --chown=wildfly:wildfly target/mp-starter.war Container/start.sh /opt/ -CMD ["/opt/start.sh"] diff --git a/Container/Dockerfile.CI b/Container/Dockerfile.CI deleted file mode 100644 index e7f88f70..00000000 --- a/Container/Dockerfile.CI +++ /dev/null @@ -1,35 +0,0 @@ -# Multi-stage build (Docker 17.05 or higher) - -# build stage -############# -FROM centos:7 AS build-env -LABEL Author="Michal Karm Babacek " -WORKDIR /opt -ENV MVN_VERSION 3.6.0 -ENV JAVA_VERSION 11 -ENV M2_HOME /opt/apache-maven-${MVN_VERSION} -ENV JAVA_HOME /usr/lib/jvm/jre-${JAVA_VERSION}-openjdk -RUN yum install java-${JAVA_VERSION}-openjdk-devel unzip -y -RUN curl -L -O https://www-eu.apache.org/dist/maven/maven-3/${MVN_VERSION}/binaries/apache-maven-${MVN_VERSION}-bin.zip && \ - unzip apache-maven-${MVN_VERSION}-bin.zip -COPY src ./src -COPY pom.xml ./ -COPY Container/settings.xml /root/.m2/settings.xml -COPY Container/start.sh /opt/ -RUN ./apache-maven-${MVN_VERSION}/bin/mvn package -Pthorntail && \ - unzip target/mp-starter-hollow-thorntail.jar -d target/mp-starter-hollow-thorntail - - -# prod stage -############# -FROM centos:7 -LABEL Author="Michal Karm Babacek " -ENV JAVA_VERSION 11 -RUN yum install java-${JAVA_VERSION}-openjdk -y && yum clean all && \ - rm -rf /var/cache/yum /tmp/* && useradd -s /sbin/nologin wildfly -EXPOSE 8080/tcp -USER wildfly -WORKDIR /opt/ -COPY --from=build-env --chown=wildfly:wildfly /opt/target/mp-starter-hollow-thorntail /opt/mp-starter-hollow-thorntail -COPY --from=build-env --chown=wildfly:wildfly /opt/start.sh /opt/target/mp-starter.war /opt/ -CMD ["/opt/start.sh"] diff --git a/Container/Dockerfile.jvm b/Container/Dockerfile.jvm new file mode 100644 index 00000000..de217f9c --- /dev/null +++ b/Container/Dockerfile.jvm @@ -0,0 +1,11 @@ +FROM registry.access.redhat.com/ubi8/openjdk-11:1.11 +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' +COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 target/quarkus-app/*.jar /deployments/ +COPY --chown=185 target/quarkus-app/app/ /deployments/app/ +COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ +EXPOSE 8080 +USER 185 +ENV AB_JOLOKIA_OFF="" +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" diff --git a/Container/README.md b/Container/README.md index fb95cf49..48919877 100644 --- a/Container/README.md +++ b/Container/README.md @@ -4,161 +4,59 @@ Building an image and running a container Development workflow ==================== -Locally without Docker on Thorntail ----------------------- +Locally without Docker, with Quarkus +------------------------------------ ``` -mvn thorntail:run -Pthorntail - +./mvnw clean package +java -jar target/quarkus-app/quarkus-run.jar ``` +Note the tests might take an hour as they download artifacts for all tested servers. +Use ` -Dtest=APIITCase` for just a quick API check. -Navigate to 127.0.0.1:8080 or http://127.0.0.1:8080/index.xhtml to see the app. - -Locally without Docker on Open Liberty ----------------------- - -Build and deploy to Open Liberty using the Liberty profile. To build the MP Starter app, use: +Navigate to http://127.0.0.1:8080 to see the app. +Live coding available with: ``` -mvn package liberty:run -Pliberty - + ./mvnw quarkus:dev ``` -Natigate to http://localhost:9080/mp-starter/ to test the app. - Docker build ------------ -With at least Docker 17.05, one can build an image and either run it locally or push it to a registry. -Please note that the first build takes time, but subsequent runs add merely ```~12M``` of the war file. ``` -mvn package -Pthorntail && unzip target/mp-starter-hollow-thorntail.jar -d target/mp-starter-hollow-thorntail -docker build -f Container/Dockerfile -t microprofile/start.microprofile.io:1.0 . +./mvnw clean package +docker build -f ./Container/Dockerfile.jvm -t microprofile/start.microprofile.io:master . ``` Run locally ----------- - +e.g. ``` -docker run -p 127.0.0.1:8080:8080/tcp -d -i --name mp-starter microprofile/start.microprofile.io:1.0 -docker stop -t 2 mp-starter && docker rm mp-starter +docker run --network=host -it -d -it --name starter -e AWS_ACCESS_KEY_ID=changeit \ + -e AWS_SECRET_ACCESS_KEY=changeit -e MP_STARTER_APP_ID=local-test -e AWS_REGION=changeit \ + -e AWS_DYNAMODB_TABLE_NAME=microprofile_test_starter_log \ + -e JAVA_OPTS="-Xms64m -Xmx128m" microprofile/start.microprofile.io:master ``` Push image to registry and restart service ------------------------------------------ ``` -docker push microprofile/start.microprofile.io:1.0 -ssh ec2-user@aws-microstarter "sudo systemctl restart docker-compose@start.microprofile.io" +docker push microprofile/start.microprofile.io:master +ssh ec2-user@aws-microstarter "sudo systemctl restart docker-compose@test-start.microprofile.io" ``` -Subsequent pushes just upload ```~12M``` of the war file. - -Example flow ------------- - -``` -mvn package -Pthorntail && unzip target/mp-starter-hollow-thorntail.jar -d target/mp-starter-hollow-thorntail -docker build -f Container/Dockerfile -t microprofile/start.microprofile.io:1.0 . -docker push microprofile/start.microprofile.io:1.0 -ssh ec2-user@aws-microstarter "sudo systemctl restart docker-compose@start.microprofile.io" -``` - -Recorded --------- -[![asciicast](https://asciinema.org/a/217550.svg)](https://asciinema.org/a/217550) - - -Production and CI -================= - -The Dockerfile is a [multi-staged build](https://docs.docker.com/develop/develop-images/multistage-build). -The first stage downloads Maven, installs OpenJDK Devel, builds the application. - -The second stage installs just OpenJDK Headless JVM and adds the uberjar contents from the previous stage. - -Due to the application's dependency on JSF the image is very fat. -Refactoring the app so as it runs just with a plain servlet container is a possible improvement to be made. - -Building an image ------------------ -Note the tag ```microprofile/start.microprofile.io:1.0``` is an example and you should use your own namespace. - -``` -docker build -f Container/Dockerfile.CI -t microprofile/start.microprofile.io:1.0 . -``` - -One can push the built image to a public DockerHub (one needs an account though): - -``` -docker push microprofile/start.microprofile.io:1.0 -``` - -Running a container locally ---------------------------- -The container accepts several environment properties one should use them to tweak the server. - -``` -docker run -e MY_LOGLEVEL=INFO \ - -e MY_IO_THREADS="8" \ - -e MY_TASK_MAX_THREADS="64" \ - -e MY_HTTP_PORT="8080" \ - -e MY_HTTPS_PORT="8443" \ - -e MY_MS_HEAP="64m" \ - -e MY_MX_HEAP="512m" \ - -e MY_META_SPACE="96M" \ - -e MY_MAX_META_SPACE="256m" \ - -p 127.0.0.1:8080:8080/tcp -d -i --name mp-starter microprofile/start.microprofile.io:1.0 -``` - -One can watch the logs: - -``` -docker logs -f mp-starter -``` - -You can stop and remove it as: - -``` -docker stop -t 2 mp-starter && docker rm mp-starter -``` - -Debugging the image build -------------------------- -One can skip the final stage of the multistage build and just do the first stage: - -``` -docker build --target build-env -f Container/Dockerfile.CI -t microprofile/start.microprofile.io:1.0 . -``` - -You can start bash and look around without starting the application: - -``` -docker run -i --entrypoint=/bin/bash --name mp-starter microprofile/start.microprofile.io:1.0 -``` - -If you have the container running already and you want to examine it, you can: - -``` -docker exec -t -i mp-starter bash -``` - - Using Systemd and Docker Compose ================================ -If you don't need any orchestration and you would just like to play with the container on a single host, +If you don't need any orchestration, and you would just like to play with the container on a single host, the following might come handy. Get a VM on the Internet ------------------------ -After you are done installing Docker (use your package manager of choice) and Docker compose, e.g. - -``` -curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose -chmod +x /usr/local/bin/docker-compose -``` +After you are done installing Docker (use your package manager of choice) and Docker compose: Compose ------- @@ -171,20 +69,17 @@ cat /etc/docker/compose/mp-starter/docker-compose.yml version: '3' services: mp-starter: - image: "microprofile/start.microprofile.io:1.0" - user: wildfly + image: "microprofile/start.microprofile.io:master" ports: - - 443:8443 - 80:8080 restart: always environment: - MY_LOGLEVEL: "INFO" - MY_IO_THREADS: "2" - MY_TASK_MAX_THREADS: "32" - MY_MS_HEAP: "512m" - MY_MX_HEAP: "512m" - MY_META_SPACE: "96M" - MY_MAX_META_SPACE: "256m" + AWS_ACCESS_KEY_ID: "changeit" + AWS_SECRET_ACCESS_KEY: "changeit" + MP_STARTER_APP_ID: "changeit" + AWS_REGION: "changeit" + AWS_DYNAMODB_TABLE_NAME: "microprofile_test_starter_log" + JAVA_OPTS: "-Xms64m -Xmx128m" ``` Systemd unit @@ -235,11 +130,3 @@ Verify it is running: docker ps -a curl localhost ``` - -Although one probably cannot access it from the outside due to a firewall your IaaS provider has in place, so let's configure the Security Group/Firewall/Network Security, depends on your provider. - -We haven't setup our own TLS infrastructure nor we have Elytron in Wildfly configured with Let's Encrypt, so let's hide -the system behind Cloudflare's balancer. This is the list of Cloudflare's IP ranges we are going to allow inbound traffic from: https://www.cloudflare.com/ips/ - -Now if you configure your domain and enforce HTTPS with Cloudflare you get your application running and accessible from -the Internet on HTTPS only. diff --git a/Container/settings.xml b/Container/settings.xml index 894b8102..0d5a3974 100644 --- a/Container/settings.xml +++ b/Container/settings.xml @@ -1,12 +1,37 @@ - - - - - - google-maven-central - GCS Maven Central mirror EU - https://maven-central-eu.storage-download.googleapis.com/repos/central/data/ - central - - + + + + google-mirror + + + google-maven-central + GCS Maven Central mirror EU + https://maven-central.storage-download.googleapis.com/maven2/ + + true + + + false + + + + + + google-maven-central + GCS Maven Central mirror EU + https://maven-central.storage-download.googleapis.com/maven2/ + + true + + + false + + + + + + + google-mirror + diff --git a/Container/start.sh b/Container/start.sh deleted file mode 100755 index e1d2050d..00000000 --- a/Container/start.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# @author Michal Karm Babacek - -# Assigned by the container -export HOSTNAME=`hostname` - -# Run -java -server \ - -Xms${MY_MS_HEAP:-64m} \ - -Xmx${MY_MX_HEAP:-512m} \ - -XX:MetaspaceSize=${MY_META_SPACE:-96M} \ - -XX:MaxMetaspaceSize=${MY_MAX_META_SPACE:-256m} \ - -XX:+UseG1GC \ - -XX:+HeapDumpOnOutOfMemoryError \ - -XX:HeapDumpPath=/opt/mp-starter-hollow-thorntail/ \ - -XX:+ExitOnOutOfMemoryError \ - -cp /opt/mp-starter-hollow-thorntail \ - org.wildfly.swarm.bootstrap.Main \ - /opt/mp-starter.war \ - -Dswarm.io.workers.default.io-threads=${MY_IO_THREADS:-8} \ - -Dswarm.io.workers.default.task-max-threads=${MY_TASK_MAX_THREADS:-64} \ - -Dswarm.transactions.node-identifier=666 \ - -Dswarm.logging.root-logger.level=${MY_LOGLEVEL:-INFO} \ - -Dswarm.http.port=${MY_HTTP_PORT:-8080} \ - -Dswarm.https.port=${MY_HTTPS_PORT:-8443} \ - -Dswarm.undertow.servers.default-server.hosts.default-host.alias="${HOSTNAME}" \ - -Dswarm.bind.address="${HOSTNAME}" \ - -DAWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \ - -DAWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \ - -DMP_STARTER_APP_ID="${MP_STARTER_APP_ID:-test-instance}" \ - -DAWS_REGION="${AWS_REGION:-eu-west-1}" \ - -DAWS_DYNAMODB_TABLE_NAME="${AWS_DYNAMODB_TABLE_NAME:-microprofile_starter_log}" diff --git a/mvnw b/mvnw new file mode 100755 index 00000000..8a8fb228 --- /dev/null +++ b/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100755 index 00000000..1d8ab018 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index 48962012..7285193b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ + - javax - javaee-api - 8.0 - provided + org.apache.myfaces.core.extensions.quarkus + myfaces-quarkus + ${myfaces.version} + + + com.googlecode.owasp-java-html-sanitizer + owasp-java-html-sanitizer + + + com.github.librepdf + openpdf + + + commons-fileupload + commons-fileupload + + + org.apache.poi + poi + + + org.apache.poi + poi-ooxml + + + com.rometools + rome + + + + + org.apache.myfaces.core.extensions.quarkus + myfaces-quarkus-deployment + ${myfaces.version} - org.primefaces primefaces ${primefaces.version} + + + io.quarkus + quarkus-resteasy-jsonb + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-arc + + + + org.apache.maven maven-model-builder ${maven.model.builder.version} - org.apache.commons commons-compress ${commons.compress.version} - com.fasterxml.jackson.dataformat jackson-dataformat-yaml ${jackson.dataformat.yaml.version} - com.fasterxml.jackson.core jackson-databind ${jackson.databind.version} - - org.thymeleaf thymeleaf ${thymeleaf.version} + + - junit - junit - ${junit.version} + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured test - - - mp-starter @@ -125,6 +175,62 @@ + + ${quarkus.platform.group-id} + quarkus-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + generate-code-tests + + + + + + maven-compiler-plugin + ${compiler-plugin.version} + + + -parameters + + + + + maven-surefire-plugin + ${surefire-plugin.version} + + + 3 + + org.jboss.logmanager.LogManager + ${maven.home} + + + + + org.codehaus.mojo + exec-maven-plugin + ${maven.exec.plugin.version} + + + generate-configs + validate + + exec + + + + + git + describe --tags --always + ${basedir} + ${basedir}/target/classes/version.txt + + org.apache.maven.plugins maven-checkstyle-plugin @@ -166,13 +272,12 @@ - + value="java.io,java.net,java.util,jakarta.enterprise.inject.spi,jakarta.enterprise.context"/> @@ -204,9 +309,8 @@ - - + @@ -218,221 +322,6 @@ - - org.codehaus.mojo - exec-maven-plugin - ${maven.exec.plugin.version} - - - generate-configs - validate - - exec - - - - - ${basedir}/version.txt.${script.extension} - ${basedir}/target/classes/ - - - - org.apache.maven.plugins - maven-failsafe-plugin - 3.0.0-M3 - - - - integration-test - verify - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.0.0 - - - add-integration-test-source-as-test-sources - generate-test-sources - - add-test-source - - - - src/it/java - - - - - - - - - Windows - - - Windows - - - - bat - - - - unix - - - unix - - - - sh - - - - thorntail - - true - - - - io.thorntail - jsf - - - - io.thorntail - cdi - - - - io.thorntail - jaxrs - - - - org.jboss.resteasy - resteasy-client - ${resteasy.version} - test - - - - io.thorntail - arquillian - test - - - - - - - - io.thorntail - bom - ${version.thorntail} - pom - import - - - - - - mp-starter - - - io.thorntail - thorntail-maven-plugin - ${version.thorntail} - - - true - - - - - package - - - - - - - - - liberty - - true - - - true - - - - - maven-war-plugin - 3.3.2 - - false - - - - io.openliberty.tools - liberty-maven-plugin - ${openliberty.maven.version} - - - package-server - package - - create - install-feature - deploy - package - - - target/wlp-package - - - - - ${skipTests} - runnable - ${final.name} - - ${final.name} - - - - - - - - org.jboss.arquillian.container - arquillian-container-test-api - 1.6.0.Final - test - - - org.jboss.arquillian.junit - arquillian-junit-container - 1.6.0.Final - test - - - org.wildfly.swarm - arquillian - 2018.5.0 - test - - - - diff --git a/releasing.md b/releasing.md index 665562cc..d5cc02e8 100644 --- a/releasing.md +++ b/releasing.md @@ -32,12 +32,13 @@ Releasing on production requires a manual step and can only be performed by thos The following commands will build and release to production the currently checked-out tag of the MicroProfile Starter: -- mvn package -Pthorntail -- unzip target/mp-starter-hollow-thorntail.jar -d target/mp-starter-hollow-thorntail -- docker build -f Container/Dockerfile -t microprofile/start.microprofile.io:_1.0_ . +- ./mvnw package +- docker build -f Container/Dockerfile.jvm -t microprofile/start.microprofile.io:_1.0_ . - docker login (with an account which can push to https://hub.docker.com/r/microprofile/start.microprofile.io) - docker push microprofile/start.microprofile.io:_1.0_ - Edit image version within _docker-compose.yml_ file at aws-microstarter server (match with the one you have pushed) - Restart Docker container ( ssh -i <> ec2-user@aws-microstarter "sudo systemctl restart docker-compose@start.microprofile.io") The version _1.0_ will follow the semantic versioning rules for future releases. + +See also [container instructions](./Container/README.md). diff --git a/src/it/java/org/eclipse/microprofile/starter/APITest.java b/src/it/java/org/eclipse/microprofile/starter/APITest.java deleted file mode 100644 index 9badad27..00000000 --- a/src/it/java/org/eclipse/microprofile/starter/APITest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2017-2020 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.eclipse.microprofile.starter; - -import org.jboss.arquillian.container.test.api.RunAsClient; -import org.jboss.arquillian.junit.Arquillian; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.wildfly.swarm.arquillian.DefaultDeployment; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import java.io.File; -import java.io.FileNotFoundException; -import java.nio.charset.StandardCharsets; -import java.util.Scanner; - -import static org.junit.Assert.assertTrue; - -/** - * MicroProfile Starter runtimes API smoke tests. - * - * Some rudimentary tests to make sure we ain't breaking the API. - * - * @author Michal Karm Babacek - */ -@RunWith(Arquillian.class) -@DefaultDeployment(type = DefaultDeployment.Type.WAR) - public class APITest { - - public static final String API_URL = "http://127.0.0.1:9090/api"; - final Client client = ClientBuilder.newBuilder().build(); - - private WebTarget target; - private File v6Matrix; - private File v6MatrixServers; - private File v5Matrix; - private File v5MatrixServers; - private File v4Matrix; - private File v4MatrixServers; - private File v3Matrix; - private File v3MatrixServers; - - @Before - public void before() { - target = client.target(API_URL); - v6Matrix = new File(getClass().getClassLoader().getResource("json_examples/v6/supportMatrix.json.segments").getFile()); - v6MatrixServers = new File(getClass().getClassLoader().getResource("json_examples/v6/supportMatrix_servers.json.segments").getFile()); - v5Matrix = new File(getClass().getClassLoader().getResource("json_examples/v5/supportMatrix.json.segments").getFile()); - v5MatrixServers = new File(getClass().getClassLoader().getResource("json_examples/v5/supportMatrix_servers.json.segments").getFile()); - v4Matrix = new File(getClass().getClassLoader().getResource("json_examples/v4/supportMatrix.json.segments").getFile()); - v4MatrixServers = new File(getClass().getClassLoader().getResource("json_examples/v4/supportMatrix_servers.json.segments").getFile()); - v3Matrix = new File(getClass().getClassLoader().getResource("json_examples/v3/supportMatrix.json.segments").getFile()); - v3MatrixServers = new File(getClass().getClassLoader().getResource("json_examples/v3/supportMatrix_servers.json.segments").getFile()); - } - - public void test(File segments, String uri) throws FileNotFoundException { - String response = client.target(API_URL + uri).request().get(String.class); - try (Scanner scanner = new Scanner(segments, StandardCharsets.UTF_8.toString())) { - scanner.useDelimiter("\n"); - while (scanner.hasNext()) { - String l = scanner.nextLine(); - assertTrue("Response of " + uri + " \n" + response + "\n should have contained the string: " + l, response.contains(l)); - } - } - } - - @Test - @RunAsClient - public void supportMatrix() throws FileNotFoundException { - test(v6Matrix, "/6/supportMatrix"); - test(v6MatrixServers, "/6/supportMatrix/servers"); - test(v5Matrix, "/5/supportMatrix"); - test(v5MatrixServers, "/5/supportMatrix/servers"); - test(v4Matrix, "/4/supportMatrix"); - test(v4MatrixServers, "/4/supportMatrix/servers"); - test(v3Matrix, "/3/supportMatrix"); - test(v3MatrixServers, "/3/supportMatrix/servers"); - } -} \ No newline at end of file diff --git a/src/main/java/org/eclipse/microprofile/starter/DataBean.java b/src/main/java/org/eclipse/microprofile/starter/DataBean.java index 8daf1ee6..0f014e96 100755 --- a/src/main/java/org/eclipse/microprofile/starter/DataBean.java +++ b/src/main/java/org/eclipse/microprofile/starter/DataBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -70,7 +70,7 @@ public String getHomePage(String value) { public String getRuntimeName(String value) { SupportedServer supportedServer = SupportedServer.valueFor(value); - return supportedServer == null ? "" : supportedServer.getDisplayName(); + return supportedServer == null ? "" : supportedServer.getDisplayName(); } public String getVersionReleasePage(String value) { diff --git a/src/main/java/org/eclipse/microprofile/starter/FakeDirectoryCreator.java b/src/main/java/org/eclipse/microprofile/starter/FakeDirectoryCreator.java index c91a0fcb..fe4e9297 100755 --- a/src/main/java/org/eclipse/microprofile/starter/FakeDirectoryCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/FakeDirectoryCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -31,7 +31,7 @@ public class FakeDirectoryCreator extends DirectoryCreator { @Inject - private ZipFileCreator zipFileCreator; + ZipFileCreator zipFileCreator; @Override public void createDirectory(String directoryPath) { diff --git a/src/main/java/org/eclipse/microprofile/starter/StarterUnexpectedException.java b/src/main/java/org/eclipse/microprofile/starter/StarterUnexpectedException.java index 761419be..fbf4328b 100644 --- a/src/main/java/org/eclipse/microprofile/starter/StarterUnexpectedException.java +++ b/src/main/java/org/eclipse/microprofile/starter/StarterUnexpectedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/Version.java b/src/main/java/org/eclipse/microprofile/starter/Version.java index e6cce880..af68577e 100644 --- a/src/main/java/org/eclipse/microprofile/starter/Version.java +++ b/src/main/java/org/eclipse/microprofile/starter/Version.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -20,19 +20,19 @@ package org.eclipse.microprofile.starter; import org.eclipse.microprofile.starter.core.files.FilesLocator; +import org.jboss.logging.Logger; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import java.util.Scanner; -import java.util.logging.Level; -import java.util.logging.Logger; + /** * @author Michal Karm Babacek */ @ApplicationScoped public class Version { - private static final Logger LOG = Logger.getLogger(Version.class.getName()); + private static final Logger LOG = Logger.getLogger(Version.class); private String git; @@ -42,7 +42,7 @@ public void init() { .getResourceAsStream("/version.txt")).useDelimiter("\\A")) { git = s.hasNext() ? s.next() : ""; } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); + LOG.error(e.getMessage()); } } diff --git a/src/main/java/org/eclipse/microprofile/starter/ZipFileCreator.java b/src/main/java/org/eclipse/microprofile/starter/ZipFileCreator.java index 50d6d09d..79edc59d 100755 --- a/src/main/java/org/eclipse/microprofile/starter/ZipFileCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/ZipFileCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/AbstractMicroprofileAddon.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/AbstractMicroprofileAddon.java index f6e9ebf3..b805cfa5 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/AbstractMicroprofileAddon.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/AbstractMicroprofileAddon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -25,7 +25,11 @@ import org.eclipse.microprofile.starter.spi.MavenHelper; import javax.inject.Inject; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; public abstract class AbstractMicroprofileAddon extends AbstractAddon { diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/MicroprofileServersAddon.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/MicroprofileServersAddon.java index c3710bb3..e61cc592 100755 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/MicroprofileServersAddon.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/MicroprofileServersAddon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -52,7 +52,7 @@ public class MicroprofileServersAddon extends AbstractMicroprofileAddon { @Inject - private MavenHelper mavenHelper; + MavenHelper mavenHelper; private Model serverPomModel; diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/JDKSelector.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/JDKSelector.java index fc84f0d8..c187f1bf 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/JDKSelector.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/JDKSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2020 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -44,7 +44,7 @@ public void init() { fillJavaSEVersion(data, SupportedServer.THORNTAIL_V2, JavaSEVersion.SE11, MicroProfileVersion.MP22, null); // Supported from MP 2.2 fillJavaSEVersion(data, SupportedServer.QUARKUS, JavaSEVersion.SE8, null, MicroProfileVersion.MP40); // Supported until MP 4.1 - fillJavaSEVersion(data, SupportedServer.QUARKUS, JavaSEVersion.SE11, MicroProfileVersion.MP32, null); // Supported from MP 3.2 + fillJavaSEVersion(data, SupportedServer.QUARKUS, JavaSEVersion.SE11, MicroProfileVersion.MP32, null); // Supported from MP 3.2 fillJavaSEVersion(data, SupportedServer.WILDFLY, JavaSEVersion.SE8, null, null); // Supported for all MPVersions fillJavaSEVersion(data, SupportedServer.WILDFLY, JavaSEVersion.SE11, MicroProfileVersion.MP32, null); // Supported from MP 3.2 diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/MicroprofileSpec.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/MicroprofileSpec.java index 66848e64..7a182354 100755 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/MicroprofileSpec.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/MicroprofileSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/ServerMPVersion.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/ServerMPVersion.java index e05eb430..dbe0f88d 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/ServerMPVersion.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/ServerMPVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2020 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -23,8 +23,8 @@ public class ServerMPVersion { - private SupportedServer supportedServer; - private MicroProfileVersion minimalMPVersion; // minimal MP Version required to show checkbox. + private final SupportedServer supportedServer; + private final MicroProfileVersion minimalMPVersion; // minimal MP Version required to show checkbox. // Can be null meaning that there is no restriction on the MP Version, only on the Runtime. diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/StandaloneMPSpec.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/StandaloneMPSpec.java index a5b2fda0..e560a813 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/StandaloneMPSpec.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/StandaloneMPSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2020 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -34,14 +34,14 @@ public enum StandaloneMPSpec { // @formatter:off ; - private String code; - private String label; - private String tagURL; - private String description; - private List serverRestrictions; - private String groupId; - private String artifactId; - private String version; + private final String code; + private final String label; + private final String tagURL; + private final String description; + private final List serverRestrictions; + private final String groupId; + private final String artifactId; + private final String version; StandaloneMPSpec(String code, String label, diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/SupportedServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/SupportedServer.java index 33f0921b..814dbd71 100755 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/SupportedServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/SupportedServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -116,15 +116,15 @@ public enum SupportedServer { ; // @formatter:on - private String code; - private String displayName; - private List mpVersions; - private String jarFileName; - private String jarParameters; - private String portServiceA; - private String portServiceB; - private String homePage; - private boolean gradleSupport; + private final String code; + private final String displayName; + private final List mpVersions; + private final String jarFileName; + private final String jarParameters; + private final String portServiceA; + private final String portServiceB; + private final String homePage; + private final boolean gradleSupport; SupportedServer(String code, String displayName, List mpVersions, String jarFileName , String jarParameters, String portServiceA, String portServiceB, String homePage, boolean gradleSupport) { diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/VersionSpecMatrix.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/VersionSpecMatrix.java index f289b305..1607cdf9 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/VersionSpecMatrix.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/model/VersionSpecMatrix.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2020 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -38,110 +38,110 @@ private void init() { data.put(MicroProfileVersion.MP12, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.1") - .add(MicroprofileSpec.FAULT_TOLERANCE, "1.0") - .add(MicroprofileSpec.JWT_AUTH, "1.0") - .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") - .add(MicroprofileSpec.METRICS, "1.0")); + .add(MicroprofileSpec.CONFIG, "1.1") + .add(MicroprofileSpec.FAULT_TOLERANCE, "1.0") + .add(MicroprofileSpec.JWT_AUTH, "1.0") + .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") + .add(MicroprofileSpec.METRICS, "1.0")); data.put(MicroProfileVersion.MP13, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.2") - .add(MicroprofileSpec.FAULT_TOLERANCE, "1.0") - .add(MicroprofileSpec.JWT_AUTH, "1.0") - .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") - .add(MicroprofileSpec.OPEN_API, "1.0") - .add(MicroprofileSpec.REST_CLIENT, "1.0") - .add(MicroprofileSpec.OPEN_TRACING, "1.0") - .add(MicroprofileSpec.METRICS, "1.1")); + .add(MicroprofileSpec.CONFIG, "1.2") + .add(MicroprofileSpec.FAULT_TOLERANCE, "1.0") + .add(MicroprofileSpec.JWT_AUTH, "1.0") + .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") + .add(MicroprofileSpec.OPEN_API, "1.0") + .add(MicroprofileSpec.REST_CLIENT, "1.0") + .add(MicroprofileSpec.OPEN_TRACING, "1.0") + .add(MicroprofileSpec.METRICS, "1.1")); data.put(MicroProfileVersion.MP14, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.3") - .add(MicroprofileSpec.FAULT_TOLERANCE, "1.1") - .add(MicroprofileSpec.JWT_AUTH, "1.1") - .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") - .add(MicroprofileSpec.OPEN_API, "1.0") - .add(MicroprofileSpec.REST_CLIENT, "1.1") - .add(MicroprofileSpec.OPEN_TRACING, "1.1") - .add(MicroprofileSpec.METRICS, "1.1")); + .add(MicroprofileSpec.CONFIG, "1.3") + .add(MicroprofileSpec.FAULT_TOLERANCE, "1.1") + .add(MicroprofileSpec.JWT_AUTH, "1.1") + .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") + .add(MicroprofileSpec.OPEN_API, "1.0") + .add(MicroprofileSpec.REST_CLIENT, "1.1") + .add(MicroprofileSpec.OPEN_TRACING, "1.1") + .add(MicroprofileSpec.METRICS, "1.1")); data.put(MicroProfileVersion.MP20, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.3") - .add(MicroprofileSpec.FAULT_TOLERANCE, "1.1") - .add(MicroprofileSpec.JWT_AUTH, "1.1") - .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") - .add(MicroprofileSpec.OPEN_API, "1.0") - .add(MicroprofileSpec.REST_CLIENT, "1.1") - .add(MicroprofileSpec.OPEN_TRACING, "1.1") - .add(MicroprofileSpec.METRICS, "1.1")); + .add(MicroprofileSpec.CONFIG, "1.3") + .add(MicroprofileSpec.FAULT_TOLERANCE, "1.1") + .add(MicroprofileSpec.JWT_AUTH, "1.1") + .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") + .add(MicroprofileSpec.OPEN_API, "1.0") + .add(MicroprofileSpec.REST_CLIENT, "1.1") + .add(MicroprofileSpec.OPEN_TRACING, "1.1") + .add(MicroprofileSpec.METRICS, "1.1")); data.put(MicroProfileVersion.MP21, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.3") - .add(MicroprofileSpec.FAULT_TOLERANCE, "1.1") - .add(MicroprofileSpec.JWT_AUTH, "1.1") - .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") - .add(MicroprofileSpec.OPEN_API, "1.0") - .add(MicroprofileSpec.REST_CLIENT, "1.1") - .add(MicroprofileSpec.OPEN_TRACING, "1.2") - .add(MicroprofileSpec.METRICS, "1.1")); + .add(MicroprofileSpec.CONFIG, "1.3") + .add(MicroprofileSpec.FAULT_TOLERANCE, "1.1") + .add(MicroprofileSpec.JWT_AUTH, "1.1") + .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") + .add(MicroprofileSpec.OPEN_API, "1.0") + .add(MicroprofileSpec.REST_CLIENT, "1.1") + .add(MicroprofileSpec.OPEN_TRACING, "1.2") + .add(MicroprofileSpec.METRICS, "1.1")); data.put(MicroProfileVersion.MP22, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.3") - .add(MicroprofileSpec.FAULT_TOLERANCE, "2.0") - .add(MicroprofileSpec.JWT_AUTH, "1.1") - .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") - .add(MicroprofileSpec.OPEN_API, "1.1") - .add(MicroprofileSpec.REST_CLIENT, "1.2") - .add(MicroprofileSpec.OPEN_TRACING, "1.3") - .add(MicroprofileSpec.METRICS, "1.1")); + .add(MicroprofileSpec.CONFIG, "1.3") + .add(MicroprofileSpec.FAULT_TOLERANCE, "2.0") + .add(MicroprofileSpec.JWT_AUTH, "1.1") + .add(MicroprofileSpec.HEALTH_CHECKS, "1.0") + .add(MicroprofileSpec.OPEN_API, "1.1") + .add(MicroprofileSpec.REST_CLIENT, "1.2") + .add(MicroprofileSpec.OPEN_TRACING, "1.3") + .add(MicroprofileSpec.METRICS, "1.1")); data.put(MicroProfileVersion.MP30, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.3") - .add(MicroprofileSpec.FAULT_TOLERANCE, "2.0") - .add(MicroprofileSpec.JWT_AUTH, "1.1") - .add(MicroprofileSpec.HEALTH_CHECKS, "2.0") - .add(MicroprofileSpec.OPEN_API, "1.1") - .add(MicroprofileSpec.REST_CLIENT, "1.3") - .add(MicroprofileSpec.OPEN_TRACING, "1.3") - .add(MicroprofileSpec.METRICS, "2.0")); + .add(MicroprofileSpec.CONFIG, "1.3") + .add(MicroprofileSpec.FAULT_TOLERANCE, "2.0") + .add(MicroprofileSpec.JWT_AUTH, "1.1") + .add(MicroprofileSpec.HEALTH_CHECKS, "2.0") + .add(MicroprofileSpec.OPEN_API, "1.1") + .add(MicroprofileSpec.REST_CLIENT, "1.3") + .add(MicroprofileSpec.OPEN_TRACING, "1.3") + .add(MicroprofileSpec.METRICS, "2.0")); data.put(MicroProfileVersion.MP32, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.3") - .add(MicroprofileSpec.FAULT_TOLERANCE, "2.0") - .add(MicroprofileSpec.JWT_AUTH, "1.1") - .add(MicroprofileSpec.HEALTH_CHECKS, "2.1") - .add(MicroprofileSpec.OPEN_API, "1.1") - .add(MicroprofileSpec.REST_CLIENT, "1.3") - .add(MicroprofileSpec.OPEN_TRACING, "1.3") - .add(MicroprofileSpec.METRICS, "2.2")); + .add(MicroprofileSpec.CONFIG, "1.3") + .add(MicroprofileSpec.FAULT_TOLERANCE, "2.0") + .add(MicroprofileSpec.JWT_AUTH, "1.1") + .add(MicroprofileSpec.HEALTH_CHECKS, "2.1") + .add(MicroprofileSpec.OPEN_API, "1.1") + .add(MicroprofileSpec.REST_CLIENT, "1.3") + .add(MicroprofileSpec.OPEN_TRACING, "1.3") + .add(MicroprofileSpec.METRICS, "2.2")); data.put(MicroProfileVersion.MP33, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "1.4") - .add(MicroprofileSpec.FAULT_TOLERANCE, "2.1") - .add(MicroprofileSpec.JWT_AUTH, "1.1") - .add(MicroprofileSpec.HEALTH_CHECKS, "2.2") - .add(MicroprofileSpec.OPEN_API, "1.1") - .add(MicroprofileSpec.REST_CLIENT, "1.4.0") - .add(MicroprofileSpec.OPEN_TRACING, "1.3") - .add(MicroprofileSpec.METRICS, "2.3")); + .add(MicroprofileSpec.CONFIG, "1.4") + .add(MicroprofileSpec.FAULT_TOLERANCE, "2.1") + .add(MicroprofileSpec.JWT_AUTH, "1.1") + .add(MicroprofileSpec.HEALTH_CHECKS, "2.2") + .add(MicroprofileSpec.OPEN_API, "1.1") + .add(MicroprofileSpec.REST_CLIENT, "1.4.0") + .add(MicroprofileSpec.OPEN_TRACING, "1.3") + .add(MicroprofileSpec.METRICS, "2.3")); data.put(MicroProfileVersion.MP40, new EnumMapBuilder() - .add(MicroprofileSpec.CONFIG, "2.0") - .add(MicroprofileSpec.FAULT_TOLERANCE, "3.0") - .add(MicroprofileSpec.JWT_AUTH, "1.2") - .add(MicroprofileSpec.HEALTH_CHECKS, "3.0") - .add(MicroprofileSpec.OPEN_API, "2.0") - .add(MicroprofileSpec.REST_CLIENT, "2.0.0") - .add(MicroprofileSpec.OPEN_TRACING, "2.0") - .add(MicroprofileSpec.METRICS, "3.0")); + .add(MicroprofileSpec.CONFIG, "2.0") + .add(MicroprofileSpec.FAULT_TOLERANCE, "3.0") + .add(MicroprofileSpec.JWT_AUTH, "1.2") + .add(MicroprofileSpec.HEALTH_CHECKS, "3.0") + .add(MicroprofileSpec.OPEN_API, "2.0") + .add(MicroprofileSpec.REST_CLIENT, "2.0.0") + .add(MicroprofileSpec.OPEN_TRACING, "2.0") + .add(MicroprofileSpec.METRICS, "3.0")); data.put(MicroProfileVersion.MP41, new EnumMapBuilder() diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/HelidonServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/HelidonServer.java index c54be8af..60f395d7 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/HelidonServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/HelidonServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -42,7 +42,7 @@ public class HelidonServer extends AbstractMicroprofileAddon { @Inject - private CDICreator cdiCreator; + CDICreator cdiCreator; @PostConstruct public void init() { diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/KumuluzeeServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/KumuluzeeServer.java index c6c60e13..c163099b 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/KumuluzeeServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/KumuluzeeServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -37,7 +37,7 @@ public class KumuluzeeServer extends AbstractMicroprofileAddon { @Inject - private CDICreator cdiCreator; + CDICreator cdiCreator; @PostConstruct public void init() { @@ -79,7 +79,6 @@ public void adaptMavenModel(Model pomFile, JessieModel model, boolean mainProjec // KumuluzEE needs jar packaging pomFile.setPackaging("jar"); - String kumuluzVersion = ""; String kumuluzeeConfigVersion = ""; String artifactId = ""; diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/LibertyServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/LibertyServer.java index 255b6d57..ba7aface 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/LibertyServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/LibertyServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -28,10 +28,10 @@ import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.HashSet; @ApplicationScoped public class LibertyServer extends AbstractMicroprofileAddon { @@ -51,7 +51,7 @@ public void createFiles(JessieModel model) { Set alternatives = model.getParameter(JessieModel.Parameter.ALTERNATIVES); Map variables = model.getVariables(); - String resourceDirectory = model.getDirectory(true) + "/src/main/liberty/config"; + String resourceDirectory = model.getDirectory(true) + "/src/main/liberty/config"; directoryCreator.createDirectory(resourceDirectory); templateEngine.processTemplateFile(resourceDirectory, "server.xml", alternatives, variables); @@ -61,20 +61,20 @@ public void createFiles(JessieModel model) { Set tempAlternative = new HashSet<>(alternatives); tempAlternative.add(JessieModel.SECONDARY_INDICATOR); - resourceDirectory = model.getDirectory(false) + "/src/main/liberty/config"; + resourceDirectory = model.getDirectory(false) + "/src/main/liberty/config"; directoryCreator.createDirectory(resourceDirectory); templateEngine.processTemplateFile(resourceDirectory, "server.xml", tempAlternative, variables); - if (microprofileSpecs.contains(MicroprofileSpec.JWT_AUTH)) { + if (microprofileSpecs.contains(MicroprofileSpec.JWT_AUTH)) { resourceDirectory = resourceDirectory + "/resources/security"; directoryCreator.createDirectory(resourceDirectory); - + templateEngine.processFile(resourceDirectory, "public.jks", alternatives); } } - + if (model.hasMainAndSecondaryProject() && microprofileSpecs.contains(MicroprofileSpec.JWT_AUTH)) { resourceDirectory = model.getDirectory(false) + "/src/main/liberty/server/resources/security"; @@ -90,21 +90,27 @@ public void createFiles(JessieModel model) { public void adaptMavenModel(Model pomFile, JessieModel model, boolean mainProject) { String openLibertyMavenVersion = "3.5.1"; pomFile.addProperty("openliberty.maven.version", openLibertyMavenVersion); - String jaegerClientVersion="0.34.0"; - String slf4jApiVersion="1.7.25"; - String slf4jJdkVersion="1.7.25"; + String jaegerClientVersion = "0.34.0"; + String slf4jApiVersion = "1.7.25"; + String slf4jJdkVersion = "1.7.25"; switch (model.getSpecification().getMicroProfileVersion()) { case NONE: break; - case MP40: case MP41: - jaegerClientVersion="1.5.0"; - slf4jApiVersion="1.7.30"; - slf4jJdkVersion="1.7.30"; + case MP40: + case MP41: + jaegerClientVersion = "1.5.0"; + slf4jApiVersion = "1.7.30"; + slf4jJdkVersion = "1.7.30"; break; - case MP33: case MP30: - case MP22: case MP21: case MP20: - case MP14: case MP13: case MP12: + case MP33: + case MP30: + case MP22: + case MP21: + case MP20: + case MP14: + case MP13: + case MP12: default: break; } diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/PayaraMicroServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/PayaraMicroServer.java index 48aeba21..e5d209a7 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/PayaraMicroServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/PayaraMicroServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/QuarkusServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/QuarkusServer.java index f6c3c98d..655dacad 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/QuarkusServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/QuarkusServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/ThorntailServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/ThorntailServer.java index f892be32..e2e901f5 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/ThorntailServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/ThorntailServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/TomeeServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/TomeeServer.java index e8fb6725..9aec70d6 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/TomeeServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/TomeeServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/WildFlyServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/WildFlyServer.java index 946e8b2f..4bac4270 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/WildFlyServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/WildFlyServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/WildflySwarmServer.java b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/WildflySwarmServer.java index 6d41760d..ff93bb94 100644 --- a/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/WildflySwarmServer.java +++ b/src/main/java/org/eclipse/microprofile/starter/addon/microprofile/servers/server/WildflySwarmServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -68,7 +68,7 @@ public void createFiles(JessieModel model) { String webInfDirectory = model.getDirectory(true) + "/" + MavenCreator.SRC_MAIN_WEBAPP + "/WEB-INF"; directoryCreator.createDirectory(webInfDirectory); - templateEngine.processTemplateFile(webInfDirectory, "web.xml",alternatives, variables); + templateEngine.processTemplateFile(webInfDirectory, "web.xml", alternatives, variables); } } diff --git a/src/main/java/org/eclipse/microprofile/starter/core/AlternativesProvider.java b/src/main/java/org/eclipse/microprofile/starter/core/AlternativesProvider.java index 53d95d6f..fc831982 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/AlternativesProvider.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/AlternativesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/TemplateVariableProvider.java b/src/main/java/org/eclipse/microprofile/starter/core/TemplateVariableProvider.java index 59018ad0..daa3428e 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/TemplateVariableProvider.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/TemplateVariableProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/addon/AddonManager.java b/src/main/java/org/eclipse/microprofile/starter/core/addon/AddonManager.java index 39288525..cb36ba98 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/addon/AddonManager.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/addon/AddonManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -41,23 +41,23 @@ public class AddonManager { @Inject - private Instance addons; + Instance addons; @Inject - private Instance alternativeProviders; + Instance alternativeProviders; @Inject - private Instance mavenAdapters; + Instance mavenAdapters; @Inject - private Instance gradleAdapters; + Instance gradleAdapters; public List getAddons(String addonName) { List result = new ArrayList<>(); for (JessieAddon addon : addons) { if (addonName.equalsIgnoreCase(addon.addonName())) { - // There are not that many addons that a break (or convertion to while) improves performance. + // There are not that many addons that a break (or conversion to while) improves performance. result.add(addon); } } diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/AbstractCreator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/AbstractCreator.java index 1cfa31d5..25adcf19 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/AbstractCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/AbstractCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/BuildToolCreator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/BuildToolCreator.java index 7b29d29e..a72eb1c9 100644 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/BuildToolCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/BuildToolCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2021 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/CDICreator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/CDICreator.java index 533160ce..6cef20b4 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/CDICreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/CDICreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/Creator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/Creator.java index 8de9028c..e619c2f8 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/Creator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/Creator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -37,16 +37,16 @@ public class Creator { @Inject - private MavenCreator mavenCreator; + MavenCreator mavenCreator; @Inject - private GradleCreator gradleCreator; + GradleCreator gradleCreator; @Inject - private CDICreator cdiCreator; + CDICreator cdiCreator; @Inject - private JavaCreator javaCreator; + JavaCreator javaCreator; public void createArtifacts(JessieModel model) { diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/DirectoryCreator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/DirectoryCreator.java index 0bdc6c4f..5f07e8c1 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/DirectoryCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/DirectoryCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/FileCreator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/FileCreator.java index 8dbb012a..c4f87058 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/FileCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/FileCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/GradleCreator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/GradleCreator.java index fc5e602e..65582184 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/GradleCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/GradleCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2021 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -46,10 +46,10 @@ public class GradleCreator extends BuildToolCreator { @Inject - private AddonManager addonManager; + AddonManager addonManager; @Inject - private TemplateEngine templateEngine; + TemplateEngine templateEngine; public void createGradleFiles(JessieModel model) { createDefaultDirectories(model, true); diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/JavaCreator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/JavaCreator.java index a4fb7a88..46e00f9f 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/JavaCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/JavaCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/MavenCreator.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/MavenCreator.java index 2d6ca863..05f8250a 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/MavenCreator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/MavenCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -47,10 +47,10 @@ public class MavenCreator extends BuildToolCreator { @Inject - private AddonManager addonManager; + AddonManager addonManager; @Inject - private MavenHelper mavenHelper; + MavenHelper mavenHelper; public void createMavenFiles(JessieModel model) { Model pomFile = createSingleModule(model); diff --git a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/TemplateEngine.java b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/TemplateEngine.java index efb4b8c3..f93dc675 100644 --- a/src/main/java/org/eclipse/microprofile/starter/core/artifacts/TemplateEngine.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/artifacts/TemplateEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2021 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/config/ConfigurationParameter.java b/src/main/java/org/eclipse/microprofile/starter/core/config/ConfigurationParameter.java index b25e028f..e2c5a5ef 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/config/ConfigurationParameter.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/config/ConfigurationParameter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/config/ConfigurationParameterProducer.java b/src/main/java/org/eclipse/microprofile/starter/core/config/ConfigurationParameterProducer.java index 559c87fb..fcf598aa 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/config/ConfigurationParameterProducer.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/config/ConfigurationParameterProducer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieConfigurationException.java b/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieConfigurationException.java index 161f15fe..bc9cf0f8 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieConfigurationException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieConfigurationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieException.java b/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieException.java index 5040f3d7..6abc2a68 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieUnexpectedException.java b/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieUnexpectedException.java index 7ffb9e7c..3e041ab0 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieUnexpectedException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/exception/JessieUnexpectedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/exception/TechnicalException.java b/src/main/java/org/eclipse/microprofile/starter/core/exception/TechnicalException.java index c32a4aaa..c1963404 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/exception/TechnicalException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/exception/TechnicalException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/file/ConfigFileNotFoundException.java b/src/main/java/org/eclipse/microprofile/starter/core/file/ConfigFileNotFoundException.java index 0ef0f6b4..d9c56d7e 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/file/ConfigFileNotFoundException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/file/ConfigFileNotFoundException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/file/ModelReader.java b/src/main/java/org/eclipse/microprofile/starter/core/file/ModelReader.java index 699c39c3..18c4681a 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/file/ModelReader.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/file/ModelReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -35,7 +35,7 @@ public class ModelReader { @Inject - private YAMLReader yamlReader; + YAMLReader yamlReader; public JessieModel readModel(InputStream in, String modelName) { diff --git a/src/main/java/org/eclipse/microprofile/starter/core/file/YAMLReader.java b/src/main/java/org/eclipse/microprofile/starter/core/file/YAMLReader.java index c3699c2d..71b3fbde 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/file/YAMLReader.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/file/YAMLReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/files/FileCopyEngine.java b/src/main/java/org/eclipse/microprofile/starter/core/files/FileCopyEngine.java index a6bd8547..0ed31c00 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/files/FileCopyEngine.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/files/FileCopyEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -39,7 +39,7 @@ public class FileCopyEngine { @Inject - private FilesLocator filesLocator; + FilesLocator filesLocator; public byte[] processFile(String file, Set alternatives) { diff --git a/src/main/java/org/eclipse/microprofile/starter/core/files/FileResolutionException.java b/src/main/java/org/eclipse/microprofile/starter/core/files/FileResolutionException.java index c9286002..d7418125 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/files/FileResolutionException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/files/FileResolutionException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/files/FilesLocator.java b/src/main/java/org/eclipse/microprofile/starter/core/files/FilesLocator.java index c489dda5..7596cf9e 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/files/FilesLocator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/files/FilesLocator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -25,7 +25,11 @@ import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Scanner; +import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -89,13 +93,13 @@ private int selectBasedOnAlternatives(List candidates, Set matches = candidates.stream() .filter(fi -> fi.getAlternatives().isEmpty()).collect(Collectors.toList()); @@ -103,7 +107,7 @@ private int selectBasedOnAlternatives(List candidates, Set> createAlternativeSets(List alternatives, int n } public String getTemplateFile(String index) { - return fileNames.get(Integer.valueOf(index)); + return fileNames.get(Integer.parseInt(index)); } private void defineResources(Pattern pattern) { @@ -178,8 +182,8 @@ private void defineResources(Pattern pattern) { private static class FileIdentification { private static final Pattern FILE_PATH_PATTERN_SPLIT = Pattern.compile("\\\\|/"); - private Set alternatives; - private String name; + private final Set alternatives; + private final String name; public FileIdentification(String fileName, String root) { alternatives = new HashSet<>(); diff --git a/src/main/java/org/eclipse/microprofile/starter/core/files/JessieFileTemplateResolver.java b/src/main/java/org/eclipse/microprofile/starter/core/files/JessieFileTemplateResolver.java index 2c37e983..4d8f8fce 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/files/JessieFileTemplateResolver.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/files/JessieFileTemplateResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -34,7 +34,7 @@ */ public class JessieFileTemplateResolver extends AbstractConfigurableTemplateResolver { - private FilesLocator filesLocator; + private final FilesLocator filesLocator; public JessieFileTemplateResolver(FilesLocator filesLocator) { this.filesLocator = filesLocator; diff --git a/src/main/java/org/eclipse/microprofile/starter/core/files/TemplateFileResolutionException.java b/src/main/java/org/eclipse/microprofile/starter/core/files/TemplateFileResolutionException.java index 95fdac96..31aa76a1 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/files/TemplateFileResolutionException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/files/TemplateFileResolutionException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/files/ThymeleafEngine.java b/src/main/java/org/eclipse/microprofile/starter/core/files/ThymeleafEngine.java index 4c50cc78..b129203f 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/files/ThymeleafEngine.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/files/ThymeleafEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -40,7 +40,7 @@ public class ThymeleafEngine { @Inject - private FilesLocator filesLocator; + FilesLocator filesLocator; private TemplateEngine engine; diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/BeansXMLMode.java b/src/main/java/org/eclipse/microprofile/starter/core/model/BeansXMLMode.java index 2f842931..ad57b3c5 100644 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/BeansXMLMode.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/BeansXMLMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -25,10 +25,9 @@ public enum BeansXMLMode { IMPLICIT("implicit"), ANNOTATED("annotated"), ALL("all"); - private String mode; + private final String mode; BeansXMLMode(String mode) { - this.mode = mode; } diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/BuildTool.java b/src/main/java/org/eclipse/microprofile/starter/core/model/BuildTool.java index 39ae9073..d2000257 100644 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/BuildTool.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/BuildTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2021 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/ComboBoxItem.java b/src/main/java/org/eclipse/microprofile/starter/core/model/ComboBoxItem.java index d594f384..a9bc4fec 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/ComboBoxItem.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/ComboBoxItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/JavaSEVersion.java b/src/main/java/org/eclipse/microprofile/starter/core/model/JavaSEVersion.java index ca0a8134..c0c31786 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/JavaSEVersion.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/JavaSEVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -32,8 +32,8 @@ public enum JavaSEVersion implements ComboBoxItem { SE11("11", "Java 11"); // @formatter:on - private String code; - private String label; + private final String code; + private final String label; JavaSEVersion(String code, String label) { this.code = code; diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/JessieMaven.java b/src/main/java/org/eclipse/microprofile/starter/core/model/JessieMaven.java index c608c7ed..6cbc1f65 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/JessieMaven.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/JessieMaven.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/JessieModel.java b/src/main/java/org/eclipse/microprofile/starter/core/model/JessieModel.java index 80eaa7d0..284cb8b3 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/JessieModel.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/JessieModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/JessieModelInitializer.java b/src/main/java/org/eclipse/microprofile/starter/core/model/JessieModelInitializer.java index 16395760..6aa6393b 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/JessieModelInitializer.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/JessieModelInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/JessieSpecification.java b/src/main/java/org/eclipse/microprofile/starter/core/model/JessieSpecification.java index fe363c6c..6184cb17 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/JessieSpecification.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/JessieSpecification.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -28,7 +28,6 @@ import org.eclipse.microprofile.starter.core.model.deserializer.MicroProfileVersionDeserializer; import org.eclipse.microprofile.starter.core.model.deserializer.ViewTypeDeserializer; - import java.util.List; /** diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/MicroProfileVersion.java b/src/main/java/org/eclipse/microprofile/starter/core/model/MicroProfileVersion.java index 5184b2cb..0bd17d78 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/MicroProfileVersion.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/MicroProfileVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -45,10 +45,10 @@ public enum MicroProfileVersion { , MP12("1.2", "MP 1.2"); // @formatter:on - private String code; - private String depVersion; - private String label; - private Set alternatives; + private final String code; + private final String depVersion; + private final String label; + private final Set alternatives; MicroProfileVersion(String code, String label) { this(code, label, code, new HashSet<>()); diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/ModelManager.java b/src/main/java/org/eclipse/microprofile/starter/core/model/ModelManager.java index e8df5eb0..05c906b0 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/ModelManager.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/ModelManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -33,7 +33,14 @@ import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; /** @@ -43,22 +50,22 @@ public class ModelManager { @Inject - private JessieModelInitializer modelInitializer; + JessieModelInitializer modelInitializer; @Inject - private ModelValidation modelValidation; + ModelValidation modelValidation; @Inject - private TemplateModelValues templateModelValues; + TemplateModelValues templateModelValues; @Inject - private AlternativesProvider alternativesProvider; + AlternativesProvider alternativesProvider; @Inject - private TemplateVariableProvider templateVariableProvider; + TemplateVariableProvider templateVariableProvider; @Inject - private AddonManager addonManager; + AddonManager addonManager; /** * @param model @@ -146,22 +153,17 @@ private void orderAddons(List allAddons) { } private void addDependentAddons(List allAddons, JessieModel model) { - Set dependents = allAddons.stream() - .map(a -> a.getDependentAddons(model)) + .map(a -> a.getDependentAddons(model)) .flatMap(Collection::stream) .filter(Objects::nonNull) .collect(Collectors.toSet()); - List addons = allAddons.stream().map(JessieAddon::addonName).collect(Collectors.toList()); - - dependents.removeAll(addons); - + allAddons.stream().map(JessieAddon::addonName).forEach(dependents::remove); if (!dependents.isEmpty()) { allAddons.addAll(getAddons(dependents)); addDependentAddons(allAddons, model); } - } private List getAddons(Collection addonList) { @@ -201,7 +203,7 @@ private boolean isAddonDisabled(String addonName, Map optio boolean result = false; String optionName = addonName + ".disable"; if (options.containsKey(optionName)) { - Boolean addonDisabled = Boolean.valueOf(options.get(optionName).getSingleValue()); + boolean addonDisabled = Boolean.parseBoolean(options.get(optionName).getSingleValue()); if (addonDisabled) { result = true; } diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/OptionValue.java b/src/main/java/org/eclipse/microprofile/starter/core/model/OptionValue.java index 44b49a20..a253286d 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/OptionValue.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/OptionValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -31,7 +31,7 @@ @JsonSerialize(using = OptionValueSerializer.class) public class OptionValue { - private List values; + private final List values; public OptionValue() { values = new ArrayList<>(); diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/OptionValueSingleValueException.java b/src/main/java/org/eclipse/microprofile/starter/core/model/OptionValueSingleValueException.java index 3b72178a..7712f157 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/OptionValueSingleValueException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/OptionValueSingleValueException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/ViewType.java b/src/main/java/org/eclipse/microprofile/starter/core/model/ViewType.java index beea5d6c..911e3199 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/ViewType.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/ViewType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -29,8 +29,8 @@ public enum ViewType implements ComboBoxItem { JSF("jsf", "JSF"), REST("rest", "JAX-RS"); - private String code; - private String label; + private final String code; + private final String label; ViewType(String code, String label) { this.code = code; diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/JavaSEVersionDeserializer.java b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/JavaSEVersionDeserializer.java index 9770f573..c5263231 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/JavaSEVersionDeserializer.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/JavaSEVersionDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/MicroProfileVersionDeserializer.java b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/MicroProfileVersionDeserializer.java index 888219e5..cb6df42e 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/MicroProfileVersionDeserializer.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/MicroProfileVersionDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/OptionsDeserializer.java b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/OptionsDeserializer.java index fc63a451..c8dad413 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/OptionsDeserializer.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/OptionsDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -30,7 +30,11 @@ import org.eclipse.microprofile.starter.core.model.OptionValue; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; public class OptionsDeserializer extends JsonDeserializer> { @Override diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/PropertyValueNotSupportedException.java b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/PropertyValueNotSupportedException.java index b09425f3..c9f25552 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/PropertyValueNotSupportedException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/PropertyValueNotSupportedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/ViewTypeDeserializer.java b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/ViewTypeDeserializer.java index 99c3105b..a5c0244f 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/ViewTypeDeserializer.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/deserializer/ViewTypeDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/model/serializer/OptionValueSerializer.java b/src/main/java/org/eclipse/microprofile/starter/core/model/serializer/OptionValueSerializer.java index 48967d0c..96a6547a 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/model/serializer/OptionValueSerializer.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/model/serializer/OptionValueSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/templates/TemplateModelLoader.java b/src/main/java/org/eclipse/microprofile/starter/core/templates/TemplateModelLoader.java index 44b4b32a..4ca30ff3 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/templates/TemplateModelLoader.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/templates/TemplateModelLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -44,12 +44,12 @@ public class TemplateModelLoader { @Inject - private ModelReader modelReader; + ModelReader modelReader; @Inject - private YAMLReader yamlReader; + YAMLReader yamlReader; - private List templates = new ArrayList<>(); + private final List templates = new ArrayList<>(); @PostConstruct public void init() { diff --git a/src/main/java/org/eclipse/microprofile/starter/core/templates/TemplateModelValues.java b/src/main/java/org/eclipse/microprofile/starter/core/templates/TemplateModelValues.java index 494cf79a..38a267cf 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/templates/TemplateModelValues.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/templates/TemplateModelValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -37,7 +37,7 @@ public class TemplateModelValues { @Inject - private TemplateModelLoader templateModelLoader; + TemplateModelLoader templateModelLoader; public void applyTemplateValues(JessieModel model) { if (model.getSpecification() == null) { diff --git a/src/main/java/org/eclipse/microprofile/starter/core/validation/ModelValidation.java b/src/main/java/org/eclipse/microprofile/starter/core/validation/ModelValidation.java index a2b958f6..503c9c81 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/validation/ModelValidation.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/validation/ModelValidation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -41,7 +41,7 @@ public class ModelValidation { @Inject - private TemplateModelLoader templateModelLoader; + TemplateModelLoader templateModelLoader; public void validate(JessieModel model) { if (!templateModelLoader.isValidTemplate(model.getTemplate())) { diff --git a/src/main/java/org/eclipse/microprofile/starter/core/validation/ModelValidationException.java b/src/main/java/org/eclipse/microprofile/starter/core/validation/ModelValidationException.java index d74d17ea..06c94642 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/validation/ModelValidationException.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/validation/ModelValidationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/core/validation/PackageNameValidator.java b/src/main/java/org/eclipse/microprofile/starter/core/validation/PackageNameValidator.java index 5347bf16..f21fc5e7 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/validation/PackageNameValidator.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/validation/PackageNameValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -30,7 +30,7 @@ public class PackageNameValidator { public static final String VALID_REGEX = "^(?:\\w+|\\w+[\\.-]\\w+)+$"; public static final int MAX_LENGTH = 200; - private Pattern pattern = Pattern.compile(VALID_REGEX, Pattern.CASE_INSENSITIVE); + private final Pattern pattern = Pattern.compile(VALID_REGEX, Pattern.CASE_INSENSITIVE); public boolean isValidPackageName(String name) { return name.length() < MAX_LENGTH && pattern.matcher(name).matches(); diff --git a/src/main/java/org/eclipse/microprofile/starter/exception/CustomExceptionHandler.java b/src/main/java/org/eclipse/microprofile/starter/exception/CustomExceptionHandler.java index 64475961..0692f98f 100644 --- a/src/main/java/org/eclipse/microprofile/starter/exception/CustomExceptionHandler.java +++ b/src/main/java/org/eclipse/microprofile/starter/exception/CustomExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -31,7 +31,7 @@ public class CustomExceptionHandler extends ExceptionHandlerWrapper { - private ExceptionHandler wrapped; + private final ExceptionHandler wrapped; @SuppressWarnings("deprecation") CustomExceptionHandler(ExceptionHandler exception) { diff --git a/src/main/java/org/eclipse/microprofile/starter/exception/CustomExceptionHandlerFactory.java b/src/main/java/org/eclipse/microprofile/starter/exception/CustomExceptionHandlerFactory.java index 4a5232c1..93270343 100644 --- a/src/main/java/org/eclipse/microprofile/starter/exception/CustomExceptionHandlerFactory.java +++ b/src/main/java/org/eclipse/microprofile/starter/exception/CustomExceptionHandlerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -24,7 +24,7 @@ public class CustomExceptionHandlerFactory extends ExceptionHandlerFactory { - private ExceptionHandlerFactory parent; + private final ExceptionHandlerFactory parent; @SuppressWarnings("deprecation") public CustomExceptionHandlerFactory(ExceptionHandlerFactory parent) { diff --git a/src/main/java/org/eclipse/microprofile/starter/log/DynamoDBLogger.java b/src/main/java/org/eclipse/microprofile/starter/log/DynamoDBLogger.java index 80d494a1..076f8ebd 100644 --- a/src/main/java/org/eclipse/microprofile/starter/log/DynamoDBLogger.java +++ b/src/main/java/org/eclipse/microprofile/starter/log/DynamoDBLogger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -19,7 +19,10 @@ */ package org.eclipse.microprofile.starter.log; +import io.quarkus.arc.Unremovable; +import org.apache.commons.lang3.StringUtils; import org.eclipse.microprofile.starter.view.EngineData; +import org.jboss.logging.Logger; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; @@ -37,8 +40,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -46,20 +47,33 @@ * @author Michal Karm Babacek */ @ApplicationScoped +@Unremovable public class DynamoDBLogger { private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); - private static final Logger LOG = Logger.getLogger(DynamoDBLogger.class.getName()); - private static final String ACCESS_KEY = System.getProperty("AWS_ACCESS_KEY_ID"); - private static final String SECRET_KEY = System.getProperty("AWS_SECRET_ACCESS_KEY"); - private static final String WEB_APP_INSTANCE_ID = System.getProperty("MP_STARTER_APP_ID", "test-instance"); - private static final String REGION = System.getProperty("AWS_REGION", "eu-west-1"); - private static final String TABLE_NAME = System.getProperty("AWS_DYNAMODB_TABLE_NAME", "microprofile_starter_log"); + private static final Logger LOG = Logger.getLogger(DynamoDBLogger.class); + private static final String ACCESS_KEY = getProperty("AWS_ACCESS_KEY_ID", null); + private static final String SECRET_KEY = getProperty("AWS_SECRET_ACCESS_KEY", null); + private static final String WEB_APP_INSTANCE_ID = getProperty("MP_STARTER_APP_ID", "test-instance"); + private static final String REGION = getProperty("AWS_REGION", "eu-west-1"); + private static final String TABLE_NAME = getProperty("AWS_DYNAMODB_TABLE_NAME", "microprofile_starter_log"); private static final String LOG_RECORD_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; private static final String HOST = "dynamodb" + "." + REGION + ".amazonaws.com"; private static final String ENDPOINT = "https://" + HOST + '/'; private static final String AMZ_TARGET = "DynamoDB_20120810.PutItem"; + public static String getProperty(String key, String def) { + String v = System.getProperty(key); + if (StringUtils.isNotBlank(v)) { + return v; + } + v = System.getenv().get(key); + if (StringUtils.isNotBlank(v)) { + return v; + } + return def; + } + private static byte[] sign(final byte[] key, final byte[] message) throws NoSuchAlgorithmException, InvalidKeyException { final Mac mac = Mac.getInstance("HmacSHA256"); mac.init(new SecretKeySpec(key, "HmacSHA256")); @@ -81,7 +95,7 @@ private static String preparePayload(final EngineData engineData, final Date dat try { sha1Hash = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { - LOG.log(Level.SEVERE, "SHA-1 not available.", e); + LOG.error("SHA-1 not available.", e); return null; } final String timestamp = logMessageTimeFormat.format(date); @@ -143,7 +157,7 @@ private static String authHeaderSignatureHash(final String amzDate, final String try { digest = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { - LOG.log(Level.SEVERE, "SHA-256 not available.", e); + LOG.error("SHA-256 not available.", e); return null; } digest.update(StandardCharsets.UTF_8.encode(dynamoDBJSON)); @@ -181,7 +195,7 @@ private static String createAuthHeader(final Date date, final String amzDate, fi mac = Mac.getInstance("HmacSHA256"); mac.init(new SecretKeySpec(signingKey, "HmacSHA256")); } catch (NoSuchAlgorithmException | InvalidKeyException e) { - LOG.log(Level.SEVERE, "HmacSHA256 key problem:", e); + LOG.error("HmacSHA256 key problem:", e); return null; } final String stringToSign = authHeaderSignatureHash(amzDate, dynamoDBJSON, credentialScope); @@ -209,37 +223,37 @@ private static void sendPayload(final String amzDate, final String authorization try (OutputStream os = myURLConnection.getOutputStream()) { os.write(dynamoDBJSON.getBytes(StandardCharsets.US_ASCII)); } - LOG.log(Level.FINE, myURLConnection.getResponseMessage()); + LOG.debug(myURLConnection.getResponseMessage()); } catch (IOException e) { - LOG.log(Level.SEVERE, "HttpURLConnection failed.", e); + LOG.error("HttpURLConnection failed.", e); return; } try { if (myURLConnection.getResponseCode() != HttpURLConnection.HTTP_OK) { - if (LOG.isLoggable(Level.FINE)) { + if (LOG.isDebugEnabled()) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(myURLConnection.getErrorStream()))) { String line; while ((line = reader.readLine()) != null) { - LOG.log(Level.FINE, line); + LOG.debug(line); } } } return; } } catch (IOException e) { - LOG.log(Level.SEVERE, "HttpURLConnection failed while reading error stream.", e); + LOG.error("HttpURLConnection failed while reading error stream.", e); return; } - if (LOG.isLoggable(Level.FINE)) { + if (LOG.isDebugEnabled()) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()))) { String line; while ((line = reader.readLine()) != null) { - LOG.log(Level.FINE, line); + LOG.debug(line); } } catch (IOException e) { - LOG.log(Level.SEVERE, "HttpURLConnection failed while reading input stream.", e); + LOG.error("HttpURLConnection failed while reading input stream.", e); } } } @@ -272,11 +286,11 @@ private static void validateEngineData(final EngineData engineData) { */ public void log(final EngineData engineData) { if (ACCESS_KEY == null || (ACCESS_KEY.length()) < 10) { - LOG.log(Level.FINE, "System property AWS_ACCESS_KEY_ID not defined. Log call dropped."); + LOG.warn("System property AWS_ACCESS_KEY_ID not defined. Log call dropped."); return; } if (SECRET_KEY == null || (SECRET_KEY.length()) < 32) { - LOG.log(Level.FINE, "System property AWS_SECRET_ACCESS_KEY not defined. Log call dropped."); + LOG.warn("System property AWS_SECRET_ACCESS_KEY not defined. Log call dropped."); return; } @@ -286,7 +300,7 @@ public void log(final EngineData engineData) { final String dynamoDBJSON = preparePayload(engineData, date); if (dynamoDBJSON == null) { - LOG.log(Level.SEVERE, "Failed to prepare DynamoDB JSON payload."); + LOG.error("Failed to prepare DynamoDB JSON payload."); return; } @@ -295,7 +309,7 @@ public void log(final EngineData engineData) { final String amzDate = amzDateFormat.format(date); final String authorizationHeader = createAuthHeader(date, amzDate, dynamoDBJSON); if (authorizationHeader == null) { - LOG.log(Level.SEVERE, "Failed to prepare authorizationHeader."); + LOG.error("Failed to prepare authorizationHeader."); return; } diff --git a/src/main/java/org/eclipse/microprofile/starter/log/ErrorLogger.java b/src/main/java/org/eclipse/microprofile/starter/log/ErrorLogger.java index f5495d55..dd45b125 100644 --- a/src/main/java/org/eclipse/microprofile/starter/log/ErrorLogger.java +++ b/src/main/java/org/eclipse/microprofile/starter/log/ErrorLogger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -22,6 +22,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.eclipse.microprofile.starter.core.model.JessieModel; +import org.jboss.logging.Logger; import javax.enterprise.context.ApplicationScoped; import java.io.PrintWriter; @@ -30,6 +31,8 @@ @ApplicationScoped public class ErrorLogger { + private static final Logger LOG = Logger.getLogger(ErrorLogger.class); + public void logError(Throwable e, JessieModel model) { ObjectMapper mapper = new ObjectMapper(); String json = null; @@ -38,8 +41,7 @@ public void logError(Throwable e, JessieModel model) { } catch (JsonProcessingException ex) { ex.printStackTrace(); } - - System.err.println(String.format("Error during generation of project: \n Model : %s \n Stacktrace %s", json, stacktrace(e))); + LOG.errorf("Error during generation of project: \n Model : %s \n Stacktrace %s%n", json, stacktrace(e)); } private String stacktrace(Throwable e) { diff --git a/src/main/java/org/eclipse/microprofile/starter/log/LoggingTask.java b/src/main/java/org/eclipse/microprofile/starter/log/LoggingTask.java index b3568df6..f4721730 100644 --- a/src/main/java/org/eclipse/microprofile/starter/log/LoggingTask.java +++ b/src/main/java/org/eclipse/microprofile/starter/log/LoggingTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -25,7 +25,7 @@ public class LoggingTask implements Runnable { - private EngineData engineData; + private final EngineData engineData; public LoggingTask(EngineData engineData) { this.engineData = engineData; diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/API.java b/src/main/java/org/eclipse/microprofile/starter/rest/API.java index 213c5121..b001db8b 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/API.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/API.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointLatest.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointLatest.java index b1fb4b5d..e64c1bb3 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointLatest.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointLatest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -46,7 +46,7 @@ public class APIEndpointLatest { @Inject - private APIService api; + APIService api; @Path("/") @GET diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV1.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV1.java index 2485fe18..7f54a681 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV1.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -47,7 +47,7 @@ public class APIEndpointV1 extends APIEndpointLatest { @Inject - private APIService api; + APIService api; @Path("/supportMatrix") @GET diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV2.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV2.java index 27d28d46..0526915a 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV2.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -48,7 +48,7 @@ public class APIEndpointV2 extends APIEndpointLatest { @Inject - private APIService api; + APIService api; @Path("/project") @GET diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV3.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV3.java index b7f5a00a..89c45b63 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV3.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV3.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -40,7 +40,7 @@ public class APIEndpointV3 extends APIEndpointLatest { @Inject - private APIService api; + APIService api; @Path("/supportMatrix/servers") @GET diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV4.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV4.java index c19bb2b0..a27ab745 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV4.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV4.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -39,7 +39,7 @@ @Path("/4") public class APIEndpointV4 extends APIEndpointLatest { @Inject - private APIService api; + APIService api; // The same as V5 @Path("/project") diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV5.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV5.java index a202cb49..9ff7040e 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV5.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV5.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -40,7 +40,7 @@ public class APIEndpointV5 extends APIEndpointLatest { @Inject - private APIService api; + APIService api; @Path("/project") @GET diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV6.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV6.java index fcb0512f..8b7cc483 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV6.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIService.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIService.java index 836db5f2..3f37e045 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIService.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -20,6 +20,7 @@ package org.eclipse.microprofile.starter.rest; import org.apache.commons.lang3.StringUtils; +import org.eclipse.microprofile.context.ManagedExecutor; import org.eclipse.microprofile.starter.Version; import org.eclipse.microprofile.starter.ZipFileCreator; import org.eclipse.microprofile.starter.addon.microprofile.servers.model.JDKSelector; @@ -46,10 +47,9 @@ import org.eclipse.microprofile.starter.rest.model.ServerOptions; import org.eclipse.microprofile.starter.rest.model.ServerOptionsV5; import org.eclipse.microprofile.starter.view.EngineData; +import org.jboss.logging.Logger; import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import javax.enterprise.concurrent.ManagedExecutorService; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.ws.rs.core.EntityTag; @@ -63,8 +63,6 @@ import java.util.Map; import java.util.Scanner; import java.util.TreeMap; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -74,7 +72,7 @@ @ApplicationScoped public class APIService { - private static final Logger LOG = Logger.getLogger(APIService.class.getName()); + private static final Logger LOG = Logger.getLogger(APIService.class); private Map specsDescriptions; @@ -88,16 +86,16 @@ public class APIService { private EntityTag readmeEtag; @Inject - private JDKSelector selector; + JDKSelector selector; @Inject - private Version version; + Version version; @Inject - private PackageNameValidator packageNameValidator; + PackageNameValidator packageNameValidator; @Inject - private ErrorLogger errorLogger; + ErrorLogger errorLogger; @PostConstruct public void init() { @@ -139,7 +137,7 @@ public void init() { readme = (s.hasNext() ? s.next() : "") + "\n" + version.getGit() + "\n"; readmeEtag = new EntityTag(Integer.toHexString(readme.hashCode())); } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); + LOG.error(e.getMessage()); } } @@ -197,16 +195,16 @@ private List defineStandaloneSpecs(MicroProfileVersion version "{\"error\":\"Selected runtime has no Gradle support \",\"code\":\"ERROR007\"}"; @Inject - private ModelManager modelManager; + ModelManager modelManager; @Inject - private Creator creator; + Creator creator; @Inject - private ZipFileCreator zipFileCreator; + ZipFileCreator zipFileCreator; - @Resource - private ManagedExecutorService managedExecutorService; + @Inject + ManagedExecutor executor; public Response readme(String ifNoneMatch) { if (ifNoneMatch != null) { @@ -607,7 +605,7 @@ private Response processProject(String ifNoneMatch, Project project) { EngineData ed = getEngineData(project); - managedExecutorService.submit(new LoggingTask(ed)); + executor.submit(new LoggingTask(ed)); EntityTag etag = new EntityTag(Integer.toHexString(31 * version.getGit().hashCode() + project.hashCode())); diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/model/MPOptionsAvailable.java b/src/main/java/org/eclipse/microprofile/starter/rest/model/MPOptionsAvailable.java index 3d65ca47..b00a1722 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/model/MPOptionsAvailable.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/model/MPOptionsAvailable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -39,7 +39,7 @@ public class MPOptionsAvailable { public MPOptionsAvailable(List supportedServers, List specs) { this.supportedServers = supportedServers; this.specs = specs; - this.specCodes = specs.stream().map(ms-> ms.getCode().toUpperCase()).collect(Collectors.toList()); + this.specCodes = specs.stream().map(ms -> ms.getCode().toUpperCase()).collect(Collectors.toList()); } public List getSupportedServers() { diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/model/Project.java b/src/main/java/org/eclipse/microprofile/starter/rest/model/Project.java index bd911a1d..52800ba6 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/model/Project.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/model/Project.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/model/ServerOptions.java b/src/main/java/org/eclipse/microprofile/starter/rest/model/ServerOptions.java index 4237cb37..34cf94b6 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/model/ServerOptions.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/model/ServerOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2020 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/model/ServerOptionsV5.java b/src/main/java/org/eclipse/microprofile/starter/rest/model/ServerOptionsV5.java index 8d139eb8..f2653953 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/model/ServerOptionsV5.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/model/ServerOptionsV5.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2020 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/spi/AbstractAddon.java b/src/main/java/org/eclipse/microprofile/starter/spi/AbstractAddon.java index 34c1b66d..0fbd5d91 100755 --- a/src/main/java/org/eclipse/microprofile/starter/spi/AbstractAddon.java +++ b/src/main/java/org/eclipse/microprofile/starter/spi/AbstractAddon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/spi/JessieAddon.java b/src/main/java/org/eclipse/microprofile/starter/spi/JessieAddon.java index 8a1eb4f6..3e65c035 100755 --- a/src/main/java/org/eclipse/microprofile/starter/spi/JessieAddon.java +++ b/src/main/java/org/eclipse/microprofile/starter/spi/JessieAddon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/spi/JessieAlternativesProvider.java b/src/main/java/org/eclipse/microprofile/starter/spi/JessieAlternativesProvider.java index 34642bf4..c94836e9 100755 --- a/src/main/java/org/eclipse/microprofile/starter/spi/JessieAlternativesProvider.java +++ b/src/main/java/org/eclipse/microprofile/starter/spi/JessieAlternativesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/spi/JessieGradleAdapter.java b/src/main/java/org/eclipse/microprofile/starter/spi/JessieGradleAdapter.java index ff73c4f7..6f090005 100755 --- a/src/main/java/org/eclipse/microprofile/starter/spi/JessieGradleAdapter.java +++ b/src/main/java/org/eclipse/microprofile/starter/spi/JessieGradleAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/spi/JessieMavenAdapter.java b/src/main/java/org/eclipse/microprofile/starter/spi/JessieMavenAdapter.java index 73736575..405d0c0f 100755 --- a/src/main/java/org/eclipse/microprofile/starter/spi/JessieMavenAdapter.java +++ b/src/main/java/org/eclipse/microprofile/starter/spi/JessieMavenAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/spi/MavenHelper.java b/src/main/java/org/eclipse/microprofile/starter/spi/MavenHelper.java index fb5991d0..f0440b5e 100755 --- a/src/main/java/org/eclipse/microprofile/starter/spi/MavenHelper.java +++ b/src/main/java/org/eclipse/microprofile/starter/spi/MavenHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -25,14 +25,15 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.microprofile.starter.StarterUnexpectedException; import javax.enterprise.context.ApplicationScoped; import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; +import java.util.Objects; /** * @@ -65,26 +66,16 @@ public void addDependency(Model pomFile, String groupId, String artifactId, Stri } public Model readModel(String pathToPom) { - InputStream stream = MavenHelper.class.getResourceAsStream(pathToPom); - + if (StringUtils.isBlank(pathToPom)) { + throw new IllegalArgumentException("pathToPom must not be blank."); + } Model model; - BufferedReader in = null; - try { - in = new BufferedReader(new InputStreamReader(stream)); - MavenXpp3Reader reader = new MavenXpp3Reader(); - model = reader.read(in); - in.close(); + try (BufferedReader in = new BufferedReader( + new InputStreamReader(Objects.requireNonNull(MavenHelper.class.getResourceAsStream(pathToPom))))) { + model = new MavenXpp3Reader().read(in); } catch (IOException | XmlPullParserException e) { - if (in != null) { - try { - in.close(); - } catch (IOException e1) { - - } - } throw new StarterUnexpectedException(e); } - return model; } diff --git a/src/main/java/org/eclipse/microprofile/starter/validation/PackageValidator.java b/src/main/java/org/eclipse/microprofile/starter/validation/PackageValidator.java index 8f562d47..40111255 100755 --- a/src/main/java/org/eclipse/microprofile/starter/validation/PackageValidator.java +++ b/src/main/java/org/eclipse/microprofile/starter/validation/PackageValidator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/view/EngineData.java b/src/main/java/org/eclipse/microprofile/starter/view/EngineData.java index dc52fd70..b465eda6 100644 --- a/src/main/java/org/eclipse/microprofile/starter/view/EngineData.java +++ b/src/main/java/org/eclipse/microprofile/starter/view/EngineData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2019 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/view/GeneratorDataBean.java b/src/main/java/org/eclipse/microprofile/starter/view/GeneratorDataBean.java index b663c149..f792906c 100755 --- a/src/main/java/org/eclipse/microprofile/starter/view/GeneratorDataBean.java +++ b/src/main/java/org/eclipse/microprofile/starter/view/GeneratorDataBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -22,6 +22,7 @@ */ package org.eclipse.microprofile.starter.view; +import org.eclipse.microprofile.context.ManagedExecutor; import org.eclipse.microprofile.starter.Version; import org.eclipse.microprofile.starter.ZipFileCreator; import org.eclipse.microprofile.starter.addon.microprofile.servers.model.JDKSelector; @@ -45,8 +46,6 @@ import org.eclipse.microprofile.starter.log.LoggingTask; import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import javax.enterprise.concurrent.ManagedExecutorService; import javax.faces.application.FacesMessage; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; @@ -72,25 +71,25 @@ public class GeneratorDataBean implements Serializable { @Inject - private JDKSelector jdkSelector; + JDKSelector jdkSelector; @Inject - private ModelManager modelManager; + ModelManager modelManager; @Inject - private Creator creator; + Creator creator; @Inject - private ZipFileCreator zipFileCreator; + ZipFileCreator zipFileCreator; @Inject - private Version version; + Version version; @Inject - private ErrorLogger errorLogger; + ErrorLogger errorLogger; - @Resource - private ManagedExecutorService managedExecutorService; + @Inject + ManagedExecutor executor; private EngineData engineData; @@ -210,7 +209,7 @@ private boolean standaloneSpecForVersion(List serverRestriction boolean result = false; for (ServerMPVersion serverRestriction : serverRestrictions) { if (serverRestriction.getMinimalMPVersion() == null) { - result = true; // When runtime has no MP version restriction, show it always. + result = true; // When runtime has no MP version restriction, always show it. } else { if (microProfileVersion != null && serverRestriction.getMinimalMPVersion().ordinal() > microProfileVersion.ordinal()) { result = true; @@ -276,7 +275,7 @@ private void randomizeSupportedServers() { private List generateUniqueRandomNumbers(int randomNumberSize) { Random rnd = new Random(); - List result = new ArrayList<>(); + List result = new ArrayList<>(randomNumberSize); while (result.size() < randomNumberSize) { int value = rnd.nextInt(500); if (!result.contains(value)) { @@ -329,7 +328,7 @@ public void generateProject() { modelManager.prepareModel(model, false); creator.createArtifacts(model); - managedExecutorService.submit(new LoggingTask(engineData)); + executor.submit(new LoggingTask(engineData)); download(zipFileCreator.createArchive()); } catch (Throwable e) { @@ -359,7 +358,7 @@ private void download(byte[] archive) { throw new JessieUnexpectedException("IO Error during download of ZIP"); } - // Important! Otherwise JSF will attempt to render the response which obviously will fail + // Important! Otherwise, JSF will attempt to render the response which obviously will fail // since it's already written with a file and closed. fc.responseComplete(); } diff --git a/src/main/java/org/eclipse/microprofile/starter/view/HeaderFilter.java b/src/main/java/org/eclipse/microprofile/starter/view/HeaderFilter.java index 7453a83b..5e44fbad 100644 --- a/src/main/java/org/eclipse/microprofile/starter/view/HeaderFilter.java +++ b/src/main/java/org/eclipse/microprofile/starter/view/HeaderFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/microprofile/starter/view/renderer/CustomSelectManyCheckboxRenderer.java b/src/main/java/org/eclipse/microprofile/starter/view/renderer/CustomSelectManyCheckboxRenderer.java index 4198a215..1d060686 100644 --- a/src/main/java/org/eclipse/microprofile/starter/view/renderer/CustomSelectManyCheckboxRenderer.java +++ b/src/main/java/org/eclipse/microprofile/starter/view/renderer/CustomSelectManyCheckboxRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2020 - 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -95,7 +95,7 @@ protected void encodeLabel(FacesContext context, SelectItem option, String targe newId = currentId + idPart; } tooltipFacet.setId(newId); - + // Add the tooltip for this option. Tooltip tooltip = new Tooltip(); tooltip.setFor(target); diff --git a/src/main/liberty/config/server.xml b/src/main/liberty/config/server.xml deleted file mode 100644 index 5cb28968..00000000 --- a/src/main/liberty/config/server.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - microprofile-3.3 - webprofile-8.0 - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/META-INF/beans.xml b/src/main/resources/META-INF/beans.xml index 9ba021ec..51cc6bda 100755 --- a/src/main/resources/META-INF/beans.xml +++ b/src/main/resources/META-INF/beans.xml @@ -1,7 +1,7 @@ + + 4.1 + + 1.2.2 + 1.7.36 + 3.2.2 + 3.1.0 + 3.5 - - - - ${quarkus.platform.group-id} - ${quarkus.platform.artifact-id} - ${quarkus.platform.version} - pom - import - - - - - + + ${packaging.type} - - org.apache.myfaces.core.extensions.quarkus - myfaces-quarkus - ${myfaces.version} - - - com.googlecode.owasp-java-html-sanitizer - owasp-java-html-sanitizer - - - com.github.librepdf - openpdf - - - commons-fileupload - commons-fileupload - - - org.apache.poi - poi - - - org.apache.poi - poi-ooxml - - - com.rometools - rome - - - - - org.apache.myfaces.core.extensions.quarkus - myfaces-quarkus-deployment - ${myfaces.version} - - - org.primefaces - primefaces - ${primefaces.version} - + + + quarkus + + true + + + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + + + - - io.quarkus - quarkus-resteasy-jsonb - - - io.quarkus - quarkus-resteasy - - - io.quarkus - quarkus-arc - + + org.apache.myfaces.core.extensions.quarkus + myfaces-quarkus + ${myfaces.version} + + + com.googlecode.owasp-java-html-sanitizer + owasp-java-html-sanitizer + + + com.github.librepdf + openpdf + + + commons-fileupload + commons-fileupload + + + org.apache.poi + poi + + + org.apache.poi + poi-ooxml + + + com.rometools + rome + + + + + org.apache.myfaces.core.extensions.quarkus + myfaces-quarkus-deployment + ${myfaces.version} + - + + io.quarkus + quarkus-resteasy-jsonb + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-arc + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + ${quarkus.platform.group-id} + quarkus-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + generate-code-tests + + + + + + + + + liberty + + true + war + + + + javax + javaee-api + 8.0 + provided + + + io.quarkus.arc + arc + ${quarkus.platform.version} + compile + + + org.eclipse.microprofile + microprofile + ${microprofile.spec.version} + pom + provided + + + io.smallrye + smallrye-context-propagation + ${smallrye-context-propagation.version} + pom + provided + + + org.slf4j + slf4j-api + ${sflj4.version} + + + org.slf4j + slf4j-jdk14 + ${sflj4.version} + + + + starter + + + + src/main/resources + + **/META-INF/resources/**/* + **/META-INF/faces-config.xml + **/META-INF/web.xml + application.properties + + + **/files/** + **/META-INF/beans.xml + files.lst + pom-servers.xml + REST-README.md + **/templates/** + + + + + + maven-war-plugin + ${maven.war.plugin.version} + + false + + + src/main/resources/META-INF/resources + + ** + + + + src/main/resources/META-INF/ + + **/*.xml + + + + + + + + maven-resources-plugin + ${maven.resources.plugin.version} + + + WEB-INF + validate + + copy-resources + + + ${basedir}/target/starter/WEB-INF + + + src/main/resources/META-INF + + beans.xml + + + *.xml + + true + + + + + + Website + validate + + copy-resources + + + ${basedir}/target/starter + + + src/main/resources/META-INF/resources + + + + + + + + io.openliberty.tools + liberty-maven-plugin + ${maven.liberty.plugin.version} + + + package-server + package + + create + install-feature + deploy + package + + + target/wlp-package + + + + + true + true + runnable + starter + + starter + starter + + + + + + + + + org.apache.maven maven-model-builder @@ -150,18 +364,10 @@ thymeleaf ${thymeleaf.version} - - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test + org.primefaces + primefaces + ${primefaces.version} @@ -175,21 +381,6 @@ - - ${quarkus.platform.group-id} - quarkus-maven-plugin - ${quarkus.platform.version} - true - - - - build - generate-code - generate-code-tests - - - - maven-compiler-plugin ${compiler-plugin.version} diff --git a/src/main/java/org/eclipse/microprofile/starter/Version.java b/src/main/java/org/eclipse/microprofile/starter/Version.java index af68577e..c6bd22df 100644 --- a/src/main/java/org/eclipse/microprofile/starter/Version.java +++ b/src/main/java/org/eclipse/microprofile/starter/Version.java @@ -24,9 +24,9 @@ import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; +import java.util.Objects; import java.util.Scanner; - /** * @author Michal Karm Babacek */ @@ -38,8 +38,8 @@ public class Version { @PostConstruct public void init() { - try (Scanner s = new Scanner(FilesLocator.class.getClassLoader() - .getResourceAsStream("/version.txt")).useDelimiter("\\A")) { + try (Scanner s = new Scanner(Objects.requireNonNull( + FilesLocator.class.getClassLoader().getResourceAsStream("/version.txt"))).useDelimiter("\\A")) { git = s.hasNext() ? s.next() : ""; } catch (Exception e) { LOG.error(e.getMessage()); diff --git a/src/main/java/org/eclipse/microprofile/starter/core/files/FileCopyEngine.java b/src/main/java/org/eclipse/microprofile/starter/core/files/FileCopyEngine.java index 0ed31c00..355c5f30 100755 --- a/src/main/java/org/eclipse/microprofile/starter/core/files/FileCopyEngine.java +++ b/src/main/java/org/eclipse/microprofile/starter/core/files/FileCopyEngine.java @@ -22,7 +22,6 @@ */ package org.eclipse.microprofile.starter.core.files; -import com.google.common.io.ByteStreams; import org.eclipse.microprofile.starter.core.exception.TechnicalException; import javax.enterprise.context.ApplicationScoped; @@ -30,6 +29,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Objects; import java.util.Set; /** @@ -49,16 +49,15 @@ public byte[] processFile(String file, Set alternatives) { throw new FileResolutionException(file, alternatives); } - String sourceFile = "/" + filesLocator.getTemplateFile(fileIndication); + final String sourceFile = "/" + filesLocator.getTemplateFile(fileIndication); + final ByteArrayOutputStream result = new ByteArrayOutputStream(); - InputStream resource = FileCopyEngine.class.getResourceAsStream(sourceFile); - ByteArrayOutputStream result = new ByteArrayOutputStream(); - - try { - ByteStreams.copy(resource, result); + try (InputStream resource = FileCopyEngine.class.getResourceAsStream(sourceFile)) { + Objects.requireNonNull(resource).transferTo(result); } catch (IOException e) { throw new TechnicalException(e); } + return result.toByteArray(); } diff --git a/src/main/java/org/eclipse/microprofile/starter/log/AppContext.java b/src/main/java/org/eclipse/microprofile/starter/log/AppContext.java new file mode 100644 index 00000000..88531d66 --- /dev/null +++ b/src/main/java/org/eclipse/microprofile/starter/log/AppContext.java @@ -0,0 +1,13 @@ +package org.eclipse.microprofile.starter.log; + +import javax.inject.Qualifier; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +public @interface AppContext { +} diff --git a/src/main/java/org/eclipse/microprofile/starter/log/ManagedExecutorProducer.java b/src/main/java/org/eclipse/microprofile/starter/log/ManagedExecutorProducer.java new file mode 100644 index 00000000..3bbeb1e9 --- /dev/null +++ b/src/main/java/org/eclipse/microprofile/starter/log/ManagedExecutorProducer.java @@ -0,0 +1,21 @@ +package org.eclipse.microprofile.starter.log; + +import org.eclipse.microprofile.context.ManagedExecutor; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Disposes; +import javax.enterprise.inject.Produces; + +@ApplicationScoped +public class ManagedExecutorProducer { + + @Produces + @AppContext + ManagedExecutor createExecutor() { + return ManagedExecutor.builder().build(); + } + + void disposeExecutor(@Disposes @AppContext ManagedExecutor exec) { + exec.shutdownNow(); + } +} diff --git a/src/main/java/org/eclipse/microprofile/starter/rest/APIService.java b/src/main/java/org/eclipse/microprofile/starter/rest/APIService.java index 3f37e045..8100d30f 100644 --- a/src/main/java/org/eclipse/microprofile/starter/rest/APIService.java +++ b/src/main/java/org/eclipse/microprofile/starter/rest/APIService.java @@ -40,6 +40,7 @@ import org.eclipse.microprofile.starter.core.model.ModelManager; import org.eclipse.microprofile.starter.core.model.OptionValue; import org.eclipse.microprofile.starter.core.validation.PackageNameValidator; +import org.eclipse.microprofile.starter.log.AppContext; import org.eclipse.microprofile.starter.log.ErrorLogger; import org.eclipse.microprofile.starter.log.LoggingTask; import org.eclipse.microprofile.starter.rest.model.MPOptionsAvailable; @@ -204,7 +205,8 @@ private List defineStandaloneSpecs(MicroProfileVersion version ZipFileCreator zipFileCreator; @Inject - ManagedExecutor executor; + @AppContext + transient ManagedExecutor executor; public Response readme(String ifNoneMatch) { if (ifNoneMatch != null) { diff --git a/src/main/java/org/eclipse/microprofile/starter/view/GeneratorDataBean.java b/src/main/java/org/eclipse/microprofile/starter/view/GeneratorDataBean.java index f792906c..a842f5b6 100755 --- a/src/main/java/org/eclipse/microprofile/starter/view/GeneratorDataBean.java +++ b/src/main/java/org/eclipse/microprofile/starter/view/GeneratorDataBean.java @@ -42,6 +42,7 @@ import org.eclipse.microprofile.starter.core.model.MicroProfileVersion; import org.eclipse.microprofile.starter.core.model.ModelManager; import org.eclipse.microprofile.starter.core.model.OptionValue; +import org.eclipse.microprofile.starter.log.AppContext; import org.eclipse.microprofile.starter.log.ErrorLogger; import org.eclipse.microprofile.starter.log.LoggingTask; @@ -89,7 +90,8 @@ public class GeneratorDataBean implements Serializable { ErrorLogger errorLogger; @Inject - ManagedExecutor executor; + @AppContext + transient ManagedExecutor executor; private EngineData engineData; diff --git a/src/main/java/org/eclipse/microprofile/starter/view/HeaderFilter.java b/src/main/java/org/eclipse/microprofile/starter/view/HeaderFilter.java index 5e44fbad..7d1c5753 100644 --- a/src/main/java/org/eclipse/microprofile/starter/view/HeaderFilter.java +++ b/src/main/java/org/eclipse/microprofile/starter/view/HeaderFilter.java @@ -41,8 +41,19 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha servletResponse.setHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains"); servletResponse.setHeader("X-Content-Type-Options", "nosniff"); servletResponse.setHeader("X-Frame-Options", "DENY"); - servletResponse.setHeader("Content-Security-Policy", "default-src: https: font-src 'https://fonts.googleapis.com';" + - "img-src 'self' https://microprofile.io; style-src 'self'; frame-ancestors 'none';"); + servletResponse.setHeader("Content-Security-Policy", "" + + "default-src 'self'; " + + "script-src 'self' 'unsafe-inline' 'unsafe-eval' " + + " https://use.fontawesome.com " + + " https://kit.fontsawesome.com; " + + "style-src 'self' 'unsafe-inline' " + + " fonts.gstatic.com " + + " fonts.googleapis.com " + + " *.fontawesome.com; " + + "img-src 'self' fonts.gstatic.com microprofile.io; " + + "font-src 'self' fonts.gstatic.com fonts.googleapis.com *.fontsawesome.com; " + + "connect-src 'self' fonts.gstatic.com fonts.googleapis.com *.fontsawesome.com; " + ); chain.doFilter(request, response); } diff --git a/src/main/liberty/config/server.xml b/src/main/liberty/config/server.xml new file mode 100644 index 00000000..d9e6d4a9 --- /dev/null +++ b/src/main/liberty/config/server.xml @@ -0,0 +1,14 @@ + + + + microProfile-4.1 + webprofile-8.0 + mpContextPropagation-1.2 + + + + + + diff --git a/src/main/resources/META-INF/resources/resources/css/starter-1.4.css b/src/main/resources/META-INF/resources/resources/css/starter-1.4.css index 1b63ce9f..49cdb710 100755 --- a/src/main/resources/META-INF/resources/resources/css/starter-1.4.css +++ b/src/main/resources/META-INF/resources/resources/css/starter-1.4.css @@ -276,7 +276,6 @@ span.ui-icon.ui-icon-triangle-1-s.ui-c::before { padding: 9px 15px; } - .ui-inputfield, .ui-selectonemenu.ui-widget.ui-state-default.ui-corner-all { border-radius: 5px; /* max-width: 280px; */ @@ -434,4 +433,4 @@ span.ui-chkbox-icon.ui-icon.ui-c.ui-icon-check { .social i.fa:hover { color: rgb(253, 183, 28); - } \ No newline at end of file +} diff --git a/src/test/java/org/eclipse/microprofile/starter/utils/Commands.java b/src/test/java/org/eclipse/microprofile/starter/utils/Commands.java index cb367a77..e60aa4a6 100644 --- a/src/test/java/org/eclipse/microprofile/starter/utils/Commands.java +++ b/src/test/java/org/eclipse/microprofile/starter/utils/Commands.java @@ -74,7 +74,8 @@ public static String getWorkspaceDir() { public static File unzip(String location, String artifactId) throws InterruptedException, IOException { ProcessBuilder pb; if (IS_THIS_WINDOWS) { - pb = new ProcessBuilder("powershell", "-c", "Expand-Archive", "-Path", location, "-DestinationPath", WORKSPACE_DIR, "-Force"); + pb = new ProcessBuilder( + "powershell", "-c", "Expand-Archive", "-Path", location, "-DestinationPath", WORKSPACE_DIR, "-Force"); } else { pb = new ProcessBuilder("unzip", "-o", location, "-d", WORKSPACE_DIR); } @@ -82,6 +83,9 @@ public static File unzip(String location, String artifactId) throws InterruptedE env.put("PATH", System.getenv("PATH")); pb.directory(new File(WORKSPACE_DIR)); File unzipLog = new File(WORKSPACE_DIR + File.separator + artifactId + "-unzip.log"); + if (unzipLog.exists()) { + unzipLog.delete(); + } pb.redirectErrorStream(true); pb.redirectOutput(ProcessBuilder.Redirect.to(unzipLog)); Process p = pb.start(); @@ -106,7 +110,8 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx try { Files.delete(dir); } catch (DirectoryNotEmptyException e) { - LOGGER.error(dir.toAbsolutePath() + " is not empty. That means someone is still writing to it. Stray Gradle daemon? Server?"); + LOGGER.error(dir.toAbsolutePath() + + " is not empty. That means someone is still writing to it. Stray Gradle daemon? Server?"); } return FileVisitResult.CONTINUE; } diff --git a/src/test/java/org/eclipse/microprofile/starter/utils/Logs.java b/src/test/java/org/eclipse/microprofile/starter/utils/Logs.java index e7bd6a10..a6284481 100644 --- a/src/test/java/org/eclipse/microprofile/starter/utils/Logs.java +++ b/src/test/java/org/eclipse/microprofile/starter/utils/Logs.java @@ -27,6 +27,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -110,10 +111,9 @@ public static void archiveLog(String testClass, String testMethod, File log) thr if (StringUtils.isBlank(testMethod)) { throw new IllegalArgumentException("testMethod must not be blank"); } - Path destDir = Path.of(System.getProperties().get("basedir").toString(), "target", "archived-logs", testClass, testMethod); + final Path destDir = Path.of(System.getProperties().get("basedir").toString(), "target", "archived-logs", testClass, testMethod); Files.createDirectories(destDir); - String filename = log.getName(); - Files.copy(log.toPath(), Paths.get(destDir.toString(), filename)); + Files.copy(log.toPath(), Paths.get(destDir.toString(), log.getName()), StandardCopyOption.REPLACE_EXISTING); } }