├── .github ├── FUNDING.yml └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.adoc ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── it ├── announce-legacy │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── mappings │ │ │ └── success.json │ └── verify.groovy ├── announce │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── mappings │ │ │ └── success.json │ └── verify.groovy ├── default │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── mappings │ │ │ └── success.json │ └── verify.groovy ├── release │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── mappings │ │ │ └── success.json │ └── verify.groovy ├── release_major │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── mappings │ │ │ ├── announce_success.json │ │ │ ├── default_success.json │ │ │ └── release_success.json │ └── verify.groovy ├── release_minor │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── mappings │ │ │ ├── announce_success.json │ │ │ └── release_success.json │ └── verify.groovy ├── settings.xml └── skip │ ├── pom.xml │ └── verify.groovy └── main └── java └── io └── sdkman └── maven ├── AnnounceMojo.java ├── BaseMojo.java ├── DefaultMojo.java ├── MajorMojo.java ├── MinorMojo.java ├── ReleaseMojo.java └── infra └── ApiEndpoints.java /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: aalmiray 2 | github: aalmiray 3 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: Build 8 | runs-on: ubuntu-latest 9 | env: 10 | CI: true 11 | 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v2 15 | 16 | - name: Setup Java 17 | uses: actions/setup-java@v1 18 | with: 19 | java-version: 1.8 20 | 21 | - name: Cache Maven packages 22 | uses: actions/cache@v1 23 | with: 24 | path: ~/.m2 25 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 26 | restore-keys: ${{ runner.os }}-m2 27 | 28 | - name: Build 29 | run: | 30 | chmod +x mvnw 31 | ./mvnw -Pit -B verify --file pom.xml -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | Release: 9 | runs-on: ubuntu-latest 10 | if: github.event_name == 'push' && startsWith(github.event.head_commit.message, '[release]') 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v2 14 | 15 | - name: Setup Java 16 | uses: actions/setup-java@v1 17 | with: 18 | java-version: 1.8 19 | 20 | - name: Cache Maven 21 | uses: actions/cache@v1 22 | with: 23 | path: ~/.m2 24 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 25 | restore-keys: ${{ runner.os }}-m2 26 | 27 | - name: Build 28 | run: | 29 | chmod +x mvnw 30 | ./mvnw -Pit -B verify --file pom.xml 31 | 32 | - name: Set up Maven Central 33 | uses: actions/setup-java@v1 34 | with: 35 | java-version: 1.8 36 | server-id: central 37 | server-username: MAVEN_USERNAME 38 | server-password: MAVEN_CENTRAL_TOKEN 39 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} 40 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 41 | 42 | - name: Release 43 | env: 44 | MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 45 | MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} 46 | MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 47 | run: | 48 | git config user.name "${{ github.event.head_commit.committer.name }}" 49 | git config user.email "${{ github.event.head_commit.committer.email }}" 50 | mvn -B --file pom.xml release:prepare release:perform -Drepository.url=https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .extract 2 | .DS_Store 3 | target 4 | *.releaseBackup 5 | release.properties 6 | .idea 7 | *.iml 8 | derby.log 9 | nul 10 | .classpath 11 | .project 12 | org.eclipse.m2e.core.prefs 13 | org.eclipse.core.resources.prefs 14 | org.eclipse.jdt.core.prefs 15 | dependency-reduced-pom.xml 16 | out 17 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdkman/sdkman-vendor-maven-plugin/c12021e2c729356b555212356a84d4769139d0d8/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Maven Plugin for SDKMAN! 2 | :project-owner: aalmiray 3 | :project-name: sdkman-vendor-maven-plugin 4 | :project-groupId: io.sdkman 5 | :project-artifactId: sdkman-maven-plugin 6 | :project-version: 2.0.0 7 | 8 | image:https://github.com/{project-owner}/{project-name}/workflows/Build/badge.svg["Build Status", link="https://github.com/{project-owner}/{project-name}/actions"] 9 | image:https://img.shields.io/maven-central/v/{project-groupId}/{project-artifactId}.svg[Download, link="https://search.maven.org/#search|ga|1|{project-artifactId}"] 10 | 11 | --- 12 | 13 | The link:http://sdkman.io[SDKMAN!] Maven Plugin. 14 | 15 | == Release a new Candidate Version 16 | 17 | Usage in a `pom.xml`: 18 | 19 | [source,xml,subs="attributes,verbatim"] 20 | ---- 21 | 22 | io.sdkman 23 | sdkman-maven-plugin 24 | {project-version} 25 | 26 | 27 | 28 | release 29 | 30 | deploy 31 | 32 | the-api-host 33 | the-candidate 34 | the-version 35 | the-url 36 | 37 | 38 | 39 | 40 | ---- 41 | 42 | The `consumerKey` and `consumerToken` could also be specified in the `configuration` tag but these should not be there. These 43 | values have corresponding properties that should be used from the command line or configured in the `settings.xml`. 44 | 45 | The `apiHost` specifies the SDKMAN! server to use, the default value is _vendors.sdkman.io_. 46 | 47 | Usage from command line: 48 | 49 | [source,subs="attributes,verbatim"] 50 | ---- 51 | mvn -e io.sdkman:sdkman-maven-plugin:{project-version}:release \ 52 | -Dsdkman.api.host=${api_host} \ 53 | -Dsdkman.consumer.key=${my_key} \ 54 | -Dsdkman.consumer.token=${my_token} \ 55 | -Dsdkman.candidate=${my_candidate} \ 56 | -Dsdkman.version=${my_version} \ 57 | -Dsdkman.url=${my_url} 58 | ---- 59 | 60 | == Set existing Version as Default for Candidate 61 | 62 | Usage in a `pom.xml`: 63 | 64 | [source,xml,subs="attributes,verbatim"] 65 | ---- 66 | 67 | io.sdkman 68 | sdkman-maven-plugin 69 | {project-version} 70 | 71 | 72 | 73 | default 74 | 75 | deploy 76 | 77 | the-api-host 78 | the-candidate 79 | the-version 80 | 81 | 82 | 83 | 84 | ---- 85 | 86 | Usage from command line: 87 | 88 | [source,subs="attributes,verbatim"] 89 | ---- 90 | mvn -e io.sdkman:sdkman-maven-plugin:{project-version}:default \ 91 | -Dsdkman.api.host=${api_host} \ 92 | -Dsdkman.consumer.key=${my_key} \ 93 | -Dsdkman.consumer.token=${my_token} \ 94 | -Dsdkman.candidate=${my_candidate} \ 95 | -Dsdkman.version=${my_version} 96 | ---- 97 | 98 | == Broadcast a Structured Message 99 | 100 | Usage in a `pom.xml`: 101 | 102 | [source,xml,subs="attributes,verbatim"] 103 | ---- 104 | 105 | io.sdkman 106 | sdkman-maven-plugin 107 | {project-version} 108 | 109 | 110 | 111 | announce 112 | 113 | deploy 114 | 115 | the-api-host 116 | the-candidate 117 | the-version 118 | my_release_notes_url 119 | 120 | 121 | 122 | 123 | ---- 124 | 125 | Usage from command line: 126 | 127 | [source,subs="attributes,verbatim"] 128 | ---- 129 | mvn -e io.sdkman:sdkman-maven-plugin:{project-version}:announce \ 130 | -Dsdkman.api.host=${api_host} \ 131 | -Dsdkman.consumer.key=${my_key} \ 132 | -Dsdkman.consumer.token=${my_token} \ 133 | -Dsdkman.candidate=${my_candidate} \ 134 | -Dsdkman.version=${my_version} \ 135 | -Dsdkman.sdkman.release.notes.url=${my_release_notes_url} 136 | ---- 137 | 138 | == Publish a Minor Release 139 | 140 | This is a convenience goal for issuing a release plus an announcement 141 | 142 | [source,xml,subs="attributes,verbatim"] 143 | ---- 144 | 145 | io.sdkman 146 | sdkman-maven-plugin 147 | {project-version} 148 | 149 | 150 | 151 | minor-release 152 | 153 | deploy 154 | 155 | the-api-host 156 | the-candidate 157 | the-version 158 | the-url 159 | my_release_notes_url 160 | 161 | 162 | 163 | 164 | ---- 165 | 166 | [source,subs="attributes,verbatim"] 167 | ---- 168 | mvn -e io.sdkman:sdkman-maven-plugin:{project-version}:minor-release \ 169 | -Dsdkman.api.host=${api_host} \ 170 | -Dsdkman.consumer.key=${my_key} \ 171 | -Dsdkman.consumer.token=${my_token} \ 172 | -Dsdkman.candidate=${my_candidate} \ 173 | -Dsdkman.version=${my_version} \ 174 | -Dsdkman.url=${my_url} \ 175 | -Dsdkman.sdkman.release.notes.url=${my_release_notes_url} 176 | ---- 177 | 178 | == Publish a Major Release 179 | 180 | This is a convenience goal for issuing a release, announcement, and setting the default version. 181 | 182 | [source,xml,subs="attributes,verbatim"] 183 | ---- 184 | 185 | io.sdkman 186 | sdkman-maven-plugin 187 | {project-version} 188 | 189 | 190 | 191 | major-release 192 | 193 | deploy 194 | 195 | the-api-host 196 | the-candidate 197 | the-version 198 | the-url 199 | my_release_notes_url 200 | 201 | 202 | 203 | 204 | ---- 205 | 206 | [source,subs="attributes,verbatim"] 207 | ---- 208 | mvn -e io.sdkman:sdkman-maven-plugin:{project-version}:major-release \ 209 | -Dsdkman.api.host=${api_host} \ 210 | -Dsdkman.consumer.key=${my_key} \ 211 | -Dsdkman.consumer.token=${my_token} \ 212 | -Dsdkman.candidate=${my_candidate} \ 213 | -Dsdkman.version=${my_version} \ 214 | -Dsdkman.url=${my_url} \ 215 | -Dsdkman.sdkman.release.notes.url=${my_release_notes_url} 216 | ---- 217 | 218 | == External configuration 219 | 220 | The consumer key/token and the api host can be specified in the _settings.xml_ Maven configuration, most likely with 221 | a profile to activate when necessary: 222 | 223 | .~/.m2/repository/settings.xml 224 | [source,xml,subs="attributes,verbatim"] 225 | ---- 226 | 227 | sdkman 228 | 229 | the-api-host 230 | my-key 231 | my-token 232 | 233 | 234 | ---- 235 | 236 | It can be used activating the _sdkman_ profile. 237 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | io.sdkman 7 | sdkman-maven-plugin 8 | 2.0.1-SNAPSHOT 9 | maven-plugin 10 | 11 | SDKMAN! Maven Plugin 12 | SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems 13 | http://sdkman.io 14 | 2015 15 | 16 | 17 | SDKMAN! 18 | http://sdkman.io 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 1.8 25 | 3.6.3 26 | 3.4 27 | 2.11.3 28 | ${project.build.directory}/repository 29 | https://oss.sonatype.org 30 | sdkman/sdkman-vendor-maven-plugin 31 | git@github.com:${project.repository}.git 32 | 33 | 34 | 35 | 36 | Apache-2.0 37 | https://spdx.org/licenses/Apache-2.0.html 38 | repo 39 | 40 | 41 | 42 | 43 | scm:git:${repository.url} 44 | scm:git:${repository.url} 45 | ${repository.url} 46 | HEAD 47 | 48 | 49 | 50 | 51 | julien.viet 52 | Julien Viet 53 | julien@julienviet.com 54 | 55 | Owner 56 | 57 | 58 | 59 | aalmiray 60 | Andres Almiray 61 | 62 | 63 | 64 | 65 | github.com 66 | https://github.com/${project.repository}/issues 67 | 68 | 69 | 70 | 71 | ossrh 72 | ${nexus.url}/content/repositories/snapshots 73 | 74 | 75 | ossrh 76 | ${nexus.url}/service/local/staging/deploy/maven2/ 77 | 78 | 79 | 80 | 81 | 82 | com.fasterxml.jackson.core 83 | jackson-core 84 | ${jackson.version} 85 | 86 | 87 | com.fasterxml.jackson.core 88 | jackson-databind 89 | ${jackson.version} 90 | 91 | 92 | org.apache.httpcomponents 93 | httpclient 94 | 4.5.1 95 | 96 | 97 | org.apache.maven.shared 98 | file-management 99 | 3.0.0 100 | 101 | 102 | javax.inject 103 | javax.inject 104 | 1 105 | 106 | 107 | org.apache.maven 108 | maven-plugin-api 109 | ${maven.version} 110 | provided 111 | 112 | 113 | javax.annotation 114 | jsr250-api 115 | 116 | 117 | 118 | 119 | org.apache.maven 120 | maven-core 121 | ${maven.version} 122 | provided 123 | 124 | 125 | org.apache.maven 126 | maven-artifact 127 | ${maven.version} 128 | provided 129 | 130 | 131 | org.apache.maven.plugin-tools 132 | maven-plugin-annotations 133 | 3.6.0 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | org.apache.maven.plugins 142 | maven-clean-plugin 143 | 3.1.0 144 | 145 | 146 | org.apache.maven.plugins 147 | maven-resources-plugin 148 | 3.1.0 149 | 150 | 151 | org.apache.maven.plugins 152 | maven-compiler-plugin 153 | 3.8.1 154 | 155 | 156 | org.apache.maven.plugins 157 | maven-surefire-plugin 158 | 2.22.2 159 | 160 | 161 | org.apache.maven.plugins 162 | maven-jar-plugin 163 | 3.1.2 164 | 165 | 166 | 167 | ${java.version} (${java.vendor} ${java.vm.version}) 168 | ${git.build.time} 169 | ${git.commit.id} 170 | ${os.name} ${os.arch} ${os.version} 171 | 172 | 173 | true 174 | 175 | 176 | 177 | 178 | 179 | org.apache.maven.plugins 180 | maven-install-plugin 181 | 3.0.0-M1 182 | 183 | 184 | org.apache.maven.plugins 185 | maven-deploy-plugin 186 | 3.0.0-M1 187 | 188 | 189 | org.apache.maven.plugins 190 | maven-invoker-plugin 191 | 3.2.1 192 | 193 | 194 | org.apache.maven.plugins 195 | maven-dependency-plugin 196 | 3.1.2 197 | 198 | 199 | org.apache.maven.plugins 200 | maven-source-plugin 201 | 3.2.1 202 | 203 | 204 | org.apache.maven.plugins 205 | maven-javadoc-plugin 206 | 3.2.0 207 | 208 | 209 | org.apache.maven.plugins 210 | maven-plugin-plugin 211 | 3.6.0 212 | 213 | true 214 | 215 | 216 | 217 | mojo-descriptor 218 | 219 | descriptor 220 | 221 | 222 | 223 | help-goal 224 | 225 | helpmojo 226 | 227 | 228 | 229 | 230 | 231 | org.codehaus.mojo 232 | versions-maven-plugin 233 | 2.8.1 234 | 235 | 236 | pl.project13.maven 237 | git-commit-id-plugin 238 | 3.0.1 239 | 240 | 241 | collect-git-properties 242 | 243 | revision 244 | 245 | validate 246 | 247 | 248 | 249 | false 250 | false 251 | true 252 | ${project.build.directory}/git.properties 253 | 254 | yyyy-MM-dd'T'HH:mm:ssXXX 255 | 256 | 257 | 258 | org.apache.maven.plugins 259 | maven-enforcer-plugin 260 | 3.0.0-M3 261 | 262 | 263 | 264 | enforce 265 | 266 | 267 | 268 | 269 | 270 | 271 | ${maven.version} 272 | 273 | 274 | ${maven.compiler.source} 275 | 276 | 277 | ${maven.compiler.source} 278 | 279 | 280 | 281 | 282 | 283 | org.codehaus.mojo 284 | extra-enforcer-rules 285 | 1.3 286 | 287 | 288 | 289 | 290 | org.apache.maven.plugins 291 | maven-release-plugin 292 | 3.0.0-M1 293 | 294 | false 295 | publication,gpg 296 | true 297 | v@{project.version} 298 | 299 | 300 | 301 | org.sonatype.plugins 302 | nexus-staging-maven-plugin 303 | 1.6.8 304 | true 305 | 306 | central 307 | ${nexus.url} 308 | true 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | it 317 | 318 | verify 319 | 320 | 321 | org.apache.maven.plugins 322 | maven-invoker-plugin 323 | 324 | false 325 | ${project.build.directory}/it 326 | 327 | */pom.xml 328 | 329 | verify 330 | ${project.build.directory}/local-repo 331 | src/it/settings.xml 332 | true 333 | 334 | verify 335 | 336 | 337 | 338 | 339 | org.codehaus.groovy 340 | groovy-all 341 | 3.0.6 342 | pom 343 | 344 | 345 | 346 | 347 | integration-test 348 | 349 | install 350 | integration-test 351 | verify 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | publication 362 | 363 | false 364 | 365 | 366 | 367 | 368 | org.apache.maven.plugins 369 | maven-source-plugin 370 | 371 | 372 | attach-sources 373 | 374 | jar 375 | 376 | 377 | true 378 | 379 | 380 | 381 | 382 | 383 | org.apache.maven.plugins 384 | maven-javadoc-plugin 385 | 386 | 387 | attach-javadocs 388 | 389 | jar 390 | 391 | 392 | true 393 | 394 | 395 | 396 | 397 | 398 | com.coderplus.maven.plugins 399 | copy-rename-maven-plugin 400 | 1.0.1 401 | 402 | 403 | copy-license-file 404 | generate-sources 405 | 406 | copy 407 | 408 | 409 | ${project.basedir}/LICENSE 410 | ${project.build.outputDirectory}/META-INF/LICENSE-sdkman 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | gpg 421 | 422 | false 423 | 424 | 425 | 426 | 427 | org.apache.maven.plugins 428 | maven-gpg-plugin 429 | 1.6 430 | 431 | 432 | verify 433 | 434 | sign 435 | 436 | 437 | 438 | --pinentry-mode 439 | loopback 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | local-deploy 451 | 452 | false 453 | 454 | 455 | 456 | local-snapshot 457 | file://${local.repository.path}/snapshot 458 | 459 | 460 | local-release 461 | file://${local.repository.path}/release 462 | 463 | 464 | 465 | 466 | 467 | org.apache.maven.plugins 468 | maven-clean-plugin 469 | false 470 | 471 | 472 | 473 | ${local.repository.path} 474 | 475 | 476 | 477 | 478 | 479 | org.apache.maven.plugins 480 | maven-antrun-plugin 481 | 3.0.0 482 | false 483 | 484 | 485 | generate-repository-directories 486 | generate-sources 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | run 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | -------------------------------------------------------------------------------- /src/it/announce-legacy/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.sdkman.it 7 | announce-legacy 8 | 1.0.0-SNAPSHOT 9 | 10 | Post an announcement (legacy) 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | @project.groupId@ 20 | @project.artifactId@ 21 | @project.version@ 22 | 23 | 24 | announce 25 | integration-test 26 | 27 | announce 28 | 29 | 30 | SOME_KEY 31 | SOME_TOKEN 32 | localhost:8081 33 | false 34 | it 35 | 1.0.0-SNAPSHOT 36 | it 37 | 38 | 39 | 40 | 41 | 42 | uk.co.automatictester 43 | wiremock-maven-plugin 44 | 6.0.0 45 | 46 | 47 | 48 | run 49 | stop 50 | 51 | 52 | target/classes 53 | --port=8081 --disable-banner 54 | 55 | 56 | 57 | 58 | 59 | com.github.tomakehurst 60 | wiremock 61 | 2.27.2 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/it/announce-legacy/src/main/resources/mappings/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "POST", 4 | "url": "/announce/struct", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT", 24 | "hashtag": "it" 25 | } 26 | } 27 | ] 28 | }, 29 | "response": { 30 | "status": 200, 31 | "headers": { 32 | "Content-Type": "application/json", 33 | "Accept": "application/json", 34 | "Consumer-Key": "SOME_KEY", 35 | "Consumer-Token": "SOME_TOKEN" 36 | }, 37 | "body": "{\"message\":\"success\"}" 38 | } 39 | } -------------------------------------------------------------------------------- /src/it/announce-legacy/verify.groovy: -------------------------------------------------------------------------------- 1 | import java.nio.file.Files 2 | import java.nio.file.Path 3 | import java.nio.file.Paths 4 | 5 | Path path = Paths.get(basedir.toString(), 'build.log') 6 | String buildLog = new String(Files.readAllBytes(path)) 7 | assert buildLog.contains('http://localhost:8081/announce/struct') 8 | assert buildLog.contains('"candidate":"it"') 9 | assert buildLog.contains('"version":"1.0.0-SNAPSHOT"') 10 | assert buildLog.contains('"hashtag":"it"') 11 | assert buildLog.contains('Sdk vendor operation successful') -------------------------------------------------------------------------------- /src/it/announce/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.sdkman.it 7 | announce 8 | 1.0.0-SNAPSHOT 9 | 10 | Post an announcement 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | @project.groupId@ 20 | @project.artifactId@ 21 | @project.version@ 22 | 23 | 24 | announce 25 | integration-test 26 | 27 | announce 28 | 29 | 30 | SOME_KEY 31 | SOME_TOKEN 32 | localhost:8081 33 | false 34 | it 35 | 1.0.0-SNAPSHOT 36 | https://host/it-1.0.0-SNAPSHOT.zip 37 | 38 | 39 | 40 | 41 | 42 | uk.co.automatictester 43 | wiremock-maven-plugin 44 | 6.0.0 45 | 46 | 47 | 48 | run 49 | stop 50 | 51 | 52 | target/classes 53 | --port=8081 --disable-banner 54 | 55 | 56 | 57 | 58 | 59 | com.github.tomakehurst 60 | wiremock 61 | 2.27.2 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/it/announce/src/main/resources/mappings/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "POST", 4 | "url": "/announce/struct", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT", 24 | "url": "https://host/it-1.0.0-SNAPSHOT.zip" 25 | } 26 | } 27 | ] 28 | }, 29 | "response": { 30 | "status": 200, 31 | "headers": { 32 | "Content-Type": "application/json", 33 | "Accept": "application/json", 34 | "Consumer-Key": "SOME_KEY", 35 | "Consumer-Token": "SOME_TOKEN" 36 | }, 37 | "body": "{\"message\":\"success\"}" 38 | } 39 | } -------------------------------------------------------------------------------- /src/it/announce/verify.groovy: -------------------------------------------------------------------------------- 1 | import java.nio.file.Files 2 | import java.nio.file.Path 3 | import java.nio.file.Paths 4 | 5 | Path path = Paths.get(basedir.toString(), 'build.log') 6 | String buildLog = new String(Files.readAllBytes(path)) 7 | assert buildLog.contains('http://localhost:8081/announce/struct') 8 | assert buildLog.contains('"candidate":"it"') 9 | assert buildLog.contains('"version":"1.0.0-SNAPSHOT"') 10 | assert buildLog.contains('"url":"https://host/it-1.0.0-SNAPSHOT.zip"') 11 | assert buildLog.contains('Sdk vendor operation successful') -------------------------------------------------------------------------------- /src/it/default/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.sdkman.it 7 | default 8 | 1.0.0-SNAPSHOT 9 | 10 | Make a version the default one 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | @project.groupId@ 20 | @project.artifactId@ 21 | @project.version@ 22 | 23 | 24 | announce 25 | integration-test 26 | 27 | default 28 | 29 | 30 | SOME_KEY 31 | SOME_TOKEN 32 | localhost:8081 33 | false 34 | it 35 | 1.0.0-SNAPSHOT 36 | 37 | 38 | 39 | 40 | 41 | uk.co.automatictester 42 | wiremock-maven-plugin 43 | 6.0.0 44 | 45 | 46 | 47 | run 48 | stop 49 | 50 | 51 | target/classes 52 | --port=8081 --disable-banner 53 | 54 | 55 | 56 | 57 | 58 | com.github.tomakehurst 59 | wiremock 60 | 2.27.2 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/it/default/src/main/resources/mappings/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "PUT", 4 | "url": "/candidates/default", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT" 24 | } 25 | } 26 | ] 27 | }, 28 | "response": { 29 | "status": 200, 30 | "headers": { 31 | "Content-Type": "application/json", 32 | "Accept": "application/json", 33 | "Consumer-Key": "SOME_KEY", 34 | "Consumer-Token": "SOME_TOKEN" 35 | }, 36 | "body": "{\"message\":\"success\"}" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/it/default/verify.groovy: -------------------------------------------------------------------------------- 1 | import java.nio.file.Files 2 | import java.nio.file.Path 3 | import java.nio.file.Paths 4 | 5 | Path path = Paths.get(basedir.toString(), 'build.log') 6 | String buildLog = new String(Files.readAllBytes(path)) 7 | assert buildLog.contains('http://localhost:8081/candidates/default') 8 | assert buildLog.contains('"candidate":"it"') 9 | assert buildLog.contains('"version":"1.0.0-SNAPSHOT"') 10 | assert buildLog.contains('Sdk vendor operation successful') 11 | -------------------------------------------------------------------------------- /src/it/release/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.sdkman.it 7 | release 8 | 1.0.0-SNAPSHOT 9 | 10 | Post a release 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | @project.groupId@ 20 | @project.artifactId@ 21 | @project.version@ 22 | 23 | 24 | announce 25 | integration-test 26 | 27 | release 28 | 29 | 30 | SOME_KEY 31 | SOME_TOKEN 32 | localhost:8081 33 | false 34 | it 35 | 1.0.0-SNAPSHOT 36 | https://host/it-1.0.0-SNAPSHOT.zip 37 | 38 | 39 | 40 | 41 | 42 | uk.co.automatictester 43 | wiremock-maven-plugin 44 | 6.0.0 45 | 46 | 47 | 48 | run 49 | stop 50 | 51 | 52 | target/classes 53 | --port=8081 --disable-banner 54 | 55 | 56 | 57 | 58 | 59 | com.github.tomakehurst 60 | wiremock 61 | 2.27.2 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/it/release/src/main/resources/mappings/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "POST", 4 | "url": "/versions", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT", 24 | "platform" : "UNIVERSAL", 25 | "url": "https://host/it-1.0.0-SNAPSHOT.zip" 26 | } 27 | } 28 | ] 29 | }, 30 | "response": { 31 | "status": 200, 32 | "headers": { 33 | "Content-Type": "application/json", 34 | "Accept": "application/json", 35 | "Consumer-Key": "SOME_KEY", 36 | "Consumer-Token": "SOME_TOKEN" 37 | }, 38 | "body": "{\"message\":\"success\"}" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/it/release/verify.groovy: -------------------------------------------------------------------------------- 1 | import java.nio.file.Files 2 | import java.nio.file.Path 3 | import java.nio.file.Paths 4 | 5 | Path path = Paths.get(basedir.toString(), 'build.log') 6 | String buildLog = new String(Files.readAllBytes(path)) 7 | assert buildLog.contains('http://localhost:8081/versions') 8 | assert buildLog.contains('"candidate":"it"') 9 | assert buildLog.contains('"version":"1.0.0-SNAPSHOT"') 10 | assert buildLog.contains('"url":"https://host/it-1.0.0-SNAPSHOT.zip"') 11 | assert buildLog.contains('Sdk vendor operation successful') 12 | -------------------------------------------------------------------------------- /src/it/release_major/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.sdkman.it 7 | release_major 8 | 1.0.0-SNAPSHOT 9 | 10 | Post a major release 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | @project.groupId@ 20 | @project.artifactId@ 21 | @project.version@ 22 | 23 | 24 | announce 25 | integration-test 26 | 27 | major-release 28 | 29 | 30 | SOME_KEY 31 | SOME_TOKEN 32 | localhost:8081 33 | false 34 | it 35 | 1.0.0-SNAPSHOT 36 | 37 | https://host/it-1.0.0-SNAPSHOT.zip 38 | 39 | https://host/it-1.0.0-SNAPSHOT.zip 40 | 41 | 42 | 43 | 44 | 45 | uk.co.automatictester 46 | wiremock-maven-plugin 47 | 6.0.0 48 | 49 | 50 | 51 | run 52 | stop 53 | 54 | 55 | target/classes 56 | --port=8081 --disable-banner 57 | 58 | 59 | 60 | 61 | 62 | com.github.tomakehurst 63 | wiremock 64 | 2.27.2 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/it/release_major/src/main/resources/mappings/announce_success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "POST", 4 | "url": "/announce/struct", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT", 24 | "url": "https://host/it-1.0.0-SNAPSHOT.zip" 25 | } 26 | } 27 | ] 28 | }, 29 | "response": { 30 | "status": 200, 31 | "headers": { 32 | "Content-Type": "application/json", 33 | "Accept": "application/json", 34 | "Consumer-Key": "SOME_KEY", 35 | "Consumer-Token": "SOME_TOKEN" 36 | }, 37 | "body": "{\"message\":\"success\"}" 38 | } 39 | } -------------------------------------------------------------------------------- /src/it/release_major/src/main/resources/mappings/default_success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "PUT", 4 | "url": "/candidates/default", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT" 24 | } 25 | } 26 | ] 27 | }, 28 | "response": { 29 | "status": 200, 30 | "headers": { 31 | "Content-Type": "application/json", 32 | "Accept": "application/json", 33 | "Consumer-Key": "SOME_KEY", 34 | "Consumer-Token": "SOME_TOKEN" 35 | }, 36 | "body": "{\"message\":\"success\"}" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/it/release_major/src/main/resources/mappings/release_success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "POST", 4 | "url": "/versions", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT", 24 | "platform": "UNIVERSAL", 25 | "url": "https://host/it-1.0.0-SNAPSHOT.zip" 26 | } 27 | } 28 | ] 29 | }, 30 | "response": { 31 | "status": 200, 32 | "headers": { 33 | "Content-Type": "application/json", 34 | "Accept": "application/json", 35 | "Consumer-Key": "SOME_KEY", 36 | "Consumer-Token": "SOME_TOKEN" 37 | }, 38 | "body": "{\"message\":\"success\"}" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/it/release_major/verify.groovy: -------------------------------------------------------------------------------- 1 | import java.nio.file.Files 2 | import java.nio.file.Path 3 | import java.nio.file.Paths 4 | 5 | Path path = Paths.get(basedir.toString(), 'build.log') 6 | String buildLog = new String(Files.readAllBytes(path)) 7 | assert buildLog.contains('http://localhost:8081/versions') 8 | assert buildLog.contains('"candidate":"it"') 9 | assert buildLog.contains('"version":"1.0.0-SNAPSHOT"') 10 | assert buildLog.contains('"url":"https://host/it-1.0.0-SNAPSHOT.zip"') 11 | assert buildLog.contains('http://localhost:8081/announce/struct') 12 | assert buildLog.contains('http://localhost:8081/candidates/default') 13 | assert buildLog.contains('Sdk vendor operation successful') 14 | -------------------------------------------------------------------------------- /src/it/release_minor/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.sdkman.it 7 | release_minor 8 | 1.0.0-SNAPSHOT 9 | 10 | Post a minor release 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | @project.groupId@ 20 | @project.artifactId@ 21 | @project.version@ 22 | 23 | 24 | announce 25 | integration-test 26 | 27 | minor-release 28 | 29 | 30 | SOME_KEY 31 | SOME_TOKEN 32 | localhost:8081 33 | false 34 | it 35 | 1.0.0-SNAPSHOT 36 | https://host/it-1.0.0-SNAPSHOT.zip 37 | https://host/it-1.0.0-SNAPSHOT.zip 38 | 39 | 40 | 41 | 42 | 43 | uk.co.automatictester 44 | wiremock-maven-plugin 45 | 6.0.0 46 | 47 | 48 | 49 | run 50 | stop 51 | 52 | 53 | target/classes 54 | --port=8081 --disable-banner 55 | 56 | 57 | 58 | 59 | 60 | com.github.tomakehurst 61 | wiremock 62 | 2.27.2 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/it/release_minor/src/main/resources/mappings/announce_success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "POST", 4 | "url": "/announce/struct", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT", 24 | "url": "https://host/it-1.0.0-SNAPSHOT.zip" 25 | } 26 | } 27 | ] 28 | }, 29 | "response": { 30 | "status": 200, 31 | "headers": { 32 | "Content-Type": "application/json", 33 | "Accept": "application/json", 34 | "Consumer-Key": "SOME_KEY", 35 | "Consumer-Token": "SOME_TOKEN" 36 | }, 37 | "body": "{\"message\":\"success\"}" 38 | } 39 | } -------------------------------------------------------------------------------- /src/it/release_minor/src/main/resources/mappings/release_success.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "method": "POST", 4 | "url": "/versions", 5 | "headers": { 6 | "Content-Type": { 7 | "matches": "application/json" 8 | }, 9 | "Accept": { 10 | "matches": "application/json" 11 | }, 12 | "Consumer-Key": { 13 | "matches": "SOME_KEY" 14 | }, 15 | "Consumer-Token": { 16 | "matches": "SOME_TOKEN" 17 | } 18 | }, 19 | "bodyPatterns": [ 20 | { 21 | "equalToJson": { 22 | "candidate": "it", 23 | "version": "1.0.0-SNAPSHOT", 24 | "platform" : "UNIVERSAL", 25 | "url": "https://host/it-1.0.0-SNAPSHOT.zip" 26 | } 27 | } 28 | ] 29 | }, 30 | "response": { 31 | "status": 200, 32 | "headers": { 33 | "Content-Type": "application/json", 34 | "Accept": "application/json", 35 | "Consumer-Key": "SOME_KEY", 36 | "Consumer-Token": "SOME_TOKEN" 37 | }, 38 | "body": "{\"message\":\"success\"}" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/it/release_minor/verify.groovy: -------------------------------------------------------------------------------- 1 | import java.nio.file.Files 2 | import java.nio.file.Path 3 | import java.nio.file.Paths 4 | 5 | Path path = Paths.get(basedir.toString(), 'build.log') 6 | String buildLog = new String(Files.readAllBytes(path)) 7 | assert buildLog.contains('http://localhost:8081/versions') 8 | assert buildLog.contains('"candidate":"it"') 9 | assert buildLog.contains('"version":"1.0.0-SNAPSHOT"') 10 | assert buildLog.contains('"url":"https://host/it-1.0.0-SNAPSHOT.zip"') 11 | assert buildLog.contains('http://localhost:8081/announce/struct') 12 | assert buildLog.contains('Sdk vendor operation successful') 13 | -------------------------------------------------------------------------------- /src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it-repo 7 | 8 | true 9 | 10 | 11 | 12 | local.central 13 | @localRepositoryUrl@ 14 | 15 | true 16 | 17 | 18 | true 19 | 20 | 21 | 22 | 23 | 24 | local.central 25 | @localRepositoryUrl@ 26 | 27 | true 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/it/skip/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.sdkman.it 7 | skip 8 | 1.0.0-SNAPSHOT 9 | 10 | Skip execution 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | @project.groupId@ 20 | @project.artifactId@ 21 | @project.version@ 22 | 23 | 24 | announce 25 | integration-test 26 | 27 | announce 28 | 29 | 30 | true 31 | SOME_KEY 32 | SOME_TOKEN 33 | it 34 | 1.0.0-SNAPSHOT 35 | it 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/it/skip/verify.groovy: -------------------------------------------------------------------------------- 1 | import java.nio.file.Files 2 | import java.nio.file.Path 3 | import java.nio.file.Paths 4 | 5 | Path path = Paths.get(basedir.toString(), 'build.log' ) 6 | assert new String(Files.readAllBytes(path)).contains('Skipping plugin execution') -------------------------------------------------------------------------------- /src/main/java/io/sdkman/maven/AnnounceMojo.java: -------------------------------------------------------------------------------- 1 | package io.sdkman.maven; 2 | 3 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 4 | import org.apache.http.client.methods.HttpPost; 5 | import org.apache.maven.plugins.annotations.Mojo; 6 | import org.apache.maven.plugins.annotations.Parameter; 7 | 8 | import java.net.URISyntaxException; 9 | import java.util.Map; 10 | 11 | import static io.sdkman.maven.infra.ApiEndpoints.ANNOUNCE_ENDPOINT; 12 | 13 | /** 14 | * Posts an announcment 15 | * 16 | * @author Julien Viet 17 | */ 18 | @Mojo(name = "announce") 19 | public class AnnounceMojo extends BaseMojo { 20 | 21 | /** The hashtag to use (legacy) */ 22 | @Parameter(property = "sdkman.hashtag") 23 | protected String hashtag; 24 | 25 | /** The URL where the release notes can be found */ 26 | @Parameter(property = "sdkman.release.notes.url") 27 | protected String releaseNotesUrl; 28 | 29 | @Override 30 | protected Map getPayload() { 31 | Map payload = super.getPayload(); 32 | if (hashtag != null && !hashtag.isEmpty()) payload.put("hashtag", hashtag); 33 | if (releaseNotesUrl != null && !releaseNotesUrl.isEmpty()) payload.put("url", releaseNotesUrl); 34 | return payload; 35 | } 36 | 37 | @Override 38 | protected HttpEntityEnclosingRequestBase createHttpRequest() { 39 | try { 40 | return new HttpPost(createURI(ANNOUNCE_ENDPOINT)); 41 | } catch (URISyntaxException e) { 42 | throw new IllegalArgumentException(e); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/sdkman/maven/BaseMojo.java: -------------------------------------------------------------------------------- 1 | package io.sdkman.maven; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.apache.http.HttpResponse; 5 | import org.apache.http.client.methods.CloseableHttpResponse; 6 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 7 | import org.apache.http.entity.StringEntity; 8 | import org.apache.http.impl.client.CloseableHttpClient; 9 | import org.apache.http.impl.client.HttpClientBuilder; 10 | import org.apache.maven.plugin.AbstractMojo; 11 | import org.apache.maven.plugin.MojoExecutionException; 12 | import org.apache.maven.plugins.annotations.Parameter; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.net.URI; 17 | import java.net.URISyntaxException; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | /** 22 | * @author Julien Viet 23 | */ 24 | public abstract class BaseMojo extends AbstractMojo { 25 | 26 | /** The SDK consumer key */ 27 | @Parameter(property = "sdkman.consumer.key", required = true) 28 | protected String consumerKey; 29 | 30 | /** The SDK consumer token */ 31 | @Parameter(property = "sdkman.consumer.token", required = true) 32 | protected String consumerToken; 33 | 34 | /** candidate identifier */ 35 | @Parameter(property = "sdkman.candidate", required = true) 36 | protected String candidate; 37 | 38 | /** candidate version */ 39 | @Parameter(property = "sdkman.version", required = true) 40 | protected String version; 41 | 42 | /** SDK service hostname */ 43 | @Parameter(property = "sdkman.api.host", defaultValue = "vendors.sdkman.io") 44 | protected String apiHost; 45 | 46 | /** Use HTTPS */ 47 | @Parameter(property = "sdkman.use.https", defaultValue = "true") 48 | protected boolean https; 49 | 50 | /** Skip this execution */ 51 | @Parameter(property = "sdkman.skip") 52 | private boolean skip; 53 | 54 | protected Map getPayload() { 55 | Map payload = new HashMap<>(); 56 | payload.put("candidate", candidate); 57 | payload.put("version", version); 58 | return payload; 59 | } 60 | 61 | protected abstract HttpEntityEnclosingRequestBase createHttpRequest(); 62 | 63 | @Override 64 | public final void execute() throws MojoExecutionException { 65 | if (skip) { 66 | getLog().info("Skipping plugin execution"); 67 | return; 68 | } 69 | doExecute(); 70 | getLog().info("Sdk vendor operation successful"); 71 | } 72 | 73 | protected void doExecute() throws MojoExecutionException { 74 | try { 75 | HttpResponse resp = execCall(getPayload(), createHttpRequest()); 76 | int statusCode = resp.getStatusLine().getStatusCode(); 77 | if (statusCode < 200 || statusCode >= 300) { 78 | throw new IllegalStateException("Server returned error " + resp.getStatusLine()); 79 | } 80 | } catch (Exception e) { 81 | throw new MojoExecutionException("Sdk vendor operation failed", e); 82 | } 83 | } 84 | 85 | protected HttpResponse execCall(Map payload, HttpEntityEnclosingRequestBase req) throws IOException { 86 | ObjectMapper mapper = new ObjectMapper(); 87 | String json = mapper.writeValueAsString(payload); 88 | 89 | getLog().info(req.getURI().toString()); 90 | getLog().info(json); 91 | 92 | req.addHeader("Consumer-Key", consumerKey); 93 | req.addHeader("Consumer-Token", consumerToken); 94 | req.addHeader("Content-Type", "application/json"); 95 | req.addHeader("Accept", "application/json"); 96 | req.setEntity(new StringEntity(json)); 97 | 98 | CloseableHttpClient client = HttpClientBuilder.create().build(); 99 | CloseableHttpResponse resp = client.execute(req); 100 | try(InputStream in = resp.getEntity().getContent()) { 101 | Map sdkmanResp = (Map) mapper.readValue(in, Map.class); 102 | for (Map.Entry prop : sdkmanResp.entrySet()) { 103 | getLog().debug(prop.getKey() + ":" + prop.getValue()); 104 | } 105 | } 106 | return resp; 107 | } 108 | 109 | protected URI createURI(String endpoint) throws URISyntaxException { 110 | String host = apiHost; 111 | int i = host.indexOf("://"); 112 | if (i > -1) { 113 | host = host.substring(i + 3); 114 | } 115 | 116 | String[] parts = host.split(":"); 117 | if (parts.length == 1) { 118 | return new URI(https ? "https" : "http", host, endpoint, null); 119 | } else if (parts.length == 2) { 120 | return new URI(https ? "https" : "http", null, parts[0], Integer.parseInt(parts[1]), endpoint, null, null); 121 | } else { 122 | throw new URISyntaxException(apiHost, "Invalid"); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/io/sdkman/maven/DefaultMojo.java: -------------------------------------------------------------------------------- 1 | package io.sdkman.maven; 2 | 3 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 4 | import org.apache.http.client.methods.HttpPut; 5 | import org.apache.maven.plugins.annotations.Mojo; 6 | 7 | import java.net.URISyntaxException; 8 | 9 | import static io.sdkman.maven.infra.ApiEndpoints.DEFAULT_ENDPOINT; 10 | 11 | /** 12 | * Mark a version as default. 13 | * 14 | * @author Julien Viet 15 | */ 16 | @Mojo(name = "default") 17 | public class DefaultMojo extends BaseMojo { 18 | @Override 19 | protected HttpEntityEnclosingRequestBase createHttpRequest() { 20 | try { 21 | return new HttpPut(createURI(DEFAULT_ENDPOINT)); 22 | } catch (URISyntaxException e) { 23 | throw new IllegalArgumentException(e); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/sdkman/maven/MajorMojo.java: -------------------------------------------------------------------------------- 1 | package io.sdkman.maven; 2 | 3 | import org.apache.http.HttpResponse; 4 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 5 | import org.apache.http.client.methods.HttpPost; 6 | import org.apache.http.client.methods.HttpPut; 7 | import org.apache.maven.plugin.MojoExecutionException; 8 | import org.apache.maven.plugins.annotations.Mojo; 9 | import org.apache.maven.plugins.annotations.Parameter; 10 | 11 | import java.io.IOException; 12 | import java.net.URISyntaxException; 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | import static io.sdkman.maven.infra.ApiEndpoints.ANNOUNCE_ENDPOINT; 18 | import static io.sdkman.maven.infra.ApiEndpoints.DEFAULT_ENDPOINT; 19 | import static io.sdkman.maven.infra.ApiEndpoints.RELEASE_ENDPOINT; 20 | 21 | /** 22 | * Release, announce, and make default. 23 | * 24 | * @author Andres Almiray 25 | */ 26 | @Mojo(name = "major-release") 27 | public class MajorMojo extends BaseMojo { 28 | 29 | /** The hashtag to use (legacy) */ 30 | @Parameter(property = "sdkman.hashtag") 31 | protected String hashtag; 32 | 33 | /** The URL from where the candidate version can be downloaded */ 34 | @Parameter(property = "sdkman.url") 35 | protected String url; 36 | 37 | /** 38 | * Platform to downloable URL mappings. 39 | * Supported platforms are: 40 | *
    41 | *
  • MAC_OSX
  • 42 | *
  • WINDOWS_64
  • 43 | *
  • LINUX_64
  • 44 | *
  • LINUX_32
  • 45 | *
46 | * Example: 47 | *
 48 |    *     "MAC_OSX"   :"https://host/micronaut-x.y.z-macosx.zip"
 49 |    *     "LINUX_64"  :"https://host/micronaut-x.y.z-linux64.zip"
 50 |    *     "WINDOWS_64":"https://host/micronaut-x.y.z-win.zip"
 51 |    * 
52 | */ 53 | @Parameter(property = "sdkman.platforms") 54 | protected Map platforms; 55 | 56 | /** The URL where the release notes can be found */ 57 | @Parameter(property = "sdkman.release.notes.url") 58 | protected String releaseNotesUrl; 59 | 60 | @Override 61 | protected HttpEntityEnclosingRequestBase createHttpRequest() { 62 | try { 63 | return new HttpPost(createURI(RELEASE_ENDPOINT)); 64 | } catch (URISyntaxException e) { 65 | throw new IllegalArgumentException(e); 66 | } 67 | } 68 | 69 | @Override 70 | protected void doExecute() throws MojoExecutionException { 71 | try { 72 | HttpResponse resp = executeMajorRelease(); 73 | int statusCode = resp.getStatusLine().getStatusCode(); 74 | if (statusCode < 200 || statusCode >= 300) { 75 | throw new IllegalStateException("Server returned error " + resp.getStatusLine()); 76 | } 77 | } catch (Exception e) { 78 | throw new MojoExecutionException("Sdk major release failed", e); 79 | } 80 | } 81 | 82 | protected HttpResponse executeMajorRelease() throws IOException { 83 | List responses = new ArrayList<>(); 84 | 85 | if (platforms == null || platforms.isEmpty()) { 86 | responses.add(execCall(getReleasePayload(), createHttpRequest())); 87 | } else { 88 | for (Map.Entry platform : platforms.entrySet()) { 89 | Map payload = super.getPayload(); 90 | payload.put("platform", platform.getKey()); 91 | payload.put("url", platform.getValue()); 92 | responses.add(execCall(payload, createHttpRequest())); 93 | } 94 | } 95 | 96 | responses.add(execCall(getAnnouncePayload(), createAnnounceHttpRequest())); 97 | responses.add(execCall(getPayload(), createDefaultHttpRequest())); 98 | 99 | return responses.stream() 100 | .filter(resp -> { 101 | int statusCode = resp.getStatusLine().getStatusCode(); 102 | return statusCode < 200 || statusCode >= 300; 103 | }) 104 | .findFirst() 105 | .orElse(responses.get(responses.size() - 1)); 106 | } 107 | 108 | protected Map getAnnouncePayload() { 109 | Map payload = super.getPayload(); 110 | if (hashtag != null && !hashtag.isEmpty()) payload.put("hashtag", hashtag); 111 | if (releaseNotesUrl != null && !releaseNotesUrl.isEmpty()) payload.put("url", releaseNotesUrl); 112 | return payload; 113 | } 114 | 115 | protected Map getReleasePayload() { 116 | Map payload = super.getPayload(); 117 | payload.put("platform", "UNIVERSAL"); 118 | payload.put("url", url); 119 | return payload; 120 | } 121 | 122 | protected HttpEntityEnclosingRequestBase createAnnounceHttpRequest() { 123 | try { 124 | return new HttpPost(createURI(ANNOUNCE_ENDPOINT)); 125 | } catch (URISyntaxException e) { 126 | throw new IllegalArgumentException(e); 127 | } 128 | } 129 | 130 | protected HttpEntityEnclosingRequestBase createDefaultHttpRequest() { 131 | try { 132 | return new HttpPut(createURI(DEFAULT_ENDPOINT)); 133 | } catch (URISyntaxException e) { 134 | throw new IllegalArgumentException(e); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/io/sdkman/maven/MinorMojo.java: -------------------------------------------------------------------------------- 1 | package io.sdkman.maven; 2 | 3 | import org.apache.http.HttpResponse; 4 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 5 | import org.apache.http.client.methods.HttpPost; 6 | import org.apache.maven.plugin.MojoExecutionException; 7 | import org.apache.maven.plugins.annotations.Mojo; 8 | import org.apache.maven.plugins.annotations.Parameter; 9 | 10 | import java.io.IOException; 11 | import java.net.URISyntaxException; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | import static io.sdkman.maven.infra.ApiEndpoints.ANNOUNCE_ENDPOINT; 17 | import static io.sdkman.maven.infra.ApiEndpoints.RELEASE_ENDPOINT; 18 | 19 | /** 20 | * Release and announce. 21 | * 22 | * @author Andres Almiray 23 | */ 24 | @Mojo(name = "minor-release") 25 | public class MinorMojo extends BaseMojo { 26 | 27 | /** The hashtag to use (legacy) */ 28 | @Parameter(property = "sdkman.hashtag") 29 | protected String hashtag; 30 | 31 | /** The URL from where the candidate version can be downloaded */ 32 | @Parameter(property = "sdkman.url") 33 | protected String url; 34 | 35 | /** 36 | * Platform to downloable URL mappings. 37 | * Supported platforms are: 38 | *
    39 | *
  • MAC_OSX
  • 40 | *
  • WINDOWS_64
  • 41 | *
  • LINUX_64
  • 42 | *
  • LINUX_32
  • 43 | *
44 | * Example: 45 | *
 46 |    *     "MAC_OSX"   :"https://host/micronaut-x.y.z-macosx.zip"
 47 |    *     "LINUX_64"  :"https://host/micronaut-x.y.z-linux64.zip"
 48 |    *     "WINDOWS_64":"https://host/micronaut-x.y.z-win.zip"
 49 |    * 
50 | */ 51 | @Parameter(property = "sdkman.platforms") 52 | protected Map platforms; 53 | 54 | /** The URL where the release notes can be found */ 55 | @Parameter(property = "sdkman.release.notes.url") 56 | protected String releaseNotesUrl; 57 | 58 | @Override 59 | protected HttpEntityEnclosingRequestBase createHttpRequest() { 60 | try { 61 | return new HttpPost(createURI(RELEASE_ENDPOINT)); 62 | } catch (URISyntaxException e) { 63 | throw new IllegalArgumentException(e); 64 | } 65 | } 66 | 67 | @Override 68 | protected void doExecute() throws MojoExecutionException { 69 | try { 70 | HttpResponse resp = executeMinorRelease(); 71 | int statusCode = resp.getStatusLine().getStatusCode(); 72 | if (statusCode < 200 || statusCode >= 300) { 73 | throw new IllegalStateException("Server returned error " + resp.getStatusLine()); 74 | } 75 | } catch (Exception e) { 76 | throw new MojoExecutionException("Sdk minor release failed", e); 77 | } 78 | } 79 | 80 | protected HttpResponse executeMinorRelease() throws IOException { 81 | List responses = new ArrayList<>(); 82 | 83 | if (platforms == null || platforms.isEmpty()) { 84 | responses.add(execCall(getReleasePayload(), createHttpRequest())); 85 | } else { 86 | for (Map.Entry platform : platforms.entrySet()) { 87 | Map payload = super.getPayload(); 88 | payload.put("platform", platform.getKey()); 89 | payload.put("url", platform.getValue()); 90 | responses.add(execCall(payload, createHttpRequest())); 91 | } 92 | } 93 | 94 | responses.add(execCall(getAnnouncePayload(), createAnnounceHttpRequest())); 95 | 96 | return responses.stream() 97 | .filter(resp -> { 98 | int statusCode = resp.getStatusLine().getStatusCode(); 99 | return statusCode < 200 || statusCode >= 300; 100 | }) 101 | .findFirst() 102 | .orElse(responses.get(responses.size() - 1)); 103 | } 104 | 105 | protected Map getAnnouncePayload() { 106 | Map payload = super.getPayload(); 107 | if (hashtag != null && !hashtag.isEmpty()) payload.put("hashtag", hashtag); 108 | if (releaseNotesUrl != null && !releaseNotesUrl.isEmpty()) payload.put("url", releaseNotesUrl); 109 | return payload; 110 | } 111 | 112 | protected Map getReleasePayload() { 113 | Map payload = super.getPayload(); 114 | payload.put("platform", "UNIVERSAL"); 115 | payload.put("url", url); 116 | return payload; 117 | } 118 | 119 | protected HttpEntityEnclosingRequestBase createAnnounceHttpRequest() { 120 | try { 121 | return new HttpPost(createURI(ANNOUNCE_ENDPOINT)); 122 | } catch (URISyntaxException e) { 123 | throw new IllegalArgumentException(e); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/io/sdkman/maven/ReleaseMojo.java: -------------------------------------------------------------------------------- 1 | package io.sdkman.maven; 2 | 3 | import org.apache.http.HttpResponse; 4 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 5 | import org.apache.http.client.methods.HttpPost; 6 | import org.apache.maven.plugin.MojoExecutionException; 7 | import org.apache.maven.plugins.annotations.Mojo; 8 | import org.apache.maven.plugins.annotations.Parameter; 9 | 10 | import java.io.IOException; 11 | import java.net.URISyntaxException; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | import static io.sdkman.maven.infra.ApiEndpoints.RELEASE_ENDPOINT; 17 | 18 | /** 19 | * Release a candidate. 20 | * 21 | * @author Julien Viet 22 | */ 23 | @Mojo(name = "release") 24 | public class ReleaseMojo extends BaseMojo { 25 | 26 | /** The URL from where the candidate version can be downloaded */ 27 | @Parameter(property = "sdkman.url") 28 | protected String url; 29 | 30 | /** 31 | * Platform to downloable URL mappings. 32 | * Supported platforms are: 33 | *
    34 | *
  • MAC_OSX
  • 35 | *
  • WINDOWS_64
  • 36 | *
  • LINUX_64
  • 37 | *
  • LINUX_32
  • 38 | *
39 | * Example: 40 | *
 41 |    *     "MAC_OSX"   :"https://host/micronaut-x.y.z-macosx.zip"
 42 |    *     "LINUX_64"  :"https://host/micronaut-x.y.z-linux64.zip"
 43 |    *     "WINDOWS_64":"https://host/micronaut-x.y.z-win.zip"
 44 |    * 
45 | */ 46 | @Parameter(property = "sdkman.platforms") 47 | protected Map platforms; 48 | 49 | @Override 50 | protected Map getPayload() { 51 | // url is required if platforms is empty 52 | if ((platforms == null || platforms.isEmpty()) && (url == null || url.isEmpty())) { 53 | throw new IllegalArgumentException("Missing url"); 54 | } 55 | 56 | Map payload = super.getPayload(); 57 | payload.put("platform", "UNIVERSAL"); 58 | payload.put("url", url); 59 | return payload; 60 | } 61 | 62 | @Override 63 | protected HttpEntityEnclosingRequestBase createHttpRequest() { 64 | try { 65 | return new HttpPost(createURI(RELEASE_ENDPOINT)); 66 | } catch (URISyntaxException e) { 67 | throw new IllegalArgumentException(e); 68 | } 69 | } 70 | 71 | @Override 72 | protected void doExecute() throws MojoExecutionException { 73 | try { 74 | HttpResponse resp = executeRelease(); 75 | int statusCode = resp.getStatusLine().getStatusCode(); 76 | if (statusCode < 200 || statusCode >= 300) { 77 | throw new IllegalStateException("Server returned error " + resp.getStatusLine()); 78 | } 79 | } catch (Exception e) { 80 | throw new MojoExecutionException("Sdk release failed", e); 81 | } 82 | } 83 | 84 | protected HttpResponse executeRelease() throws IOException { 85 | if (platforms == null || platforms.isEmpty()) { 86 | return execCall(getPayload(), createHttpRequest()); 87 | } 88 | 89 | List responses = new ArrayList<>(); 90 | for (Map.Entry platform : platforms.entrySet()) { 91 | Map payload = super.getPayload(); 92 | payload.put("platform", platform.getKey()); 93 | payload.put("url", platform.getValue()); 94 | responses.add(execCall(payload, createHttpRequest())); 95 | } 96 | 97 | return responses.stream() 98 | .filter(resp -> { 99 | int statusCode = resp.getStatusLine().getStatusCode(); 100 | return statusCode < 200 || statusCode >= 300; 101 | }) 102 | .findFirst() 103 | .orElse(responses.get(responses.size() - 1)); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/io/sdkman/maven/infra/ApiEndpoints.java: -------------------------------------------------------------------------------- 1 | package io.sdkman.maven.infra; 2 | 3 | /** 4 | * @author Andres Almiray 5 | */ 6 | public class ApiEndpoints { 7 | public static final String ANNOUNCE_ENDPOINT = "/announce/struct"; 8 | public static final String DEFAULT_ENDPOINT = "/candidates/default"; 9 | public static final String RELEASE_ENDPOINT = "/versions"; 10 | } 11 | --------------------------------------------------------------------------------