Skip to content

Commit b3ed87b

Browse files
authored
Merge pull request #127 from imsweb/gradle-to-mvn
Convert to Maven for builds and releases
2 parents 5a0b67e + 013a772 commit b3ed87b

File tree

4,872 files changed

+1618
-446716
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,872 files changed

+1618
-446716
lines changed
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
# Run the full CS ingration comparison
2-
#
3-
# This is just a proof of concept for now since the raw input is not available as it
4-
# is too large to include in repository.
5-
61
name: cs-comparison
72

83
on: workflow_dispatch
94

105
jobs:
116
build:
12-
137
runs-on: ubuntu-latest
148

159
steps:
@@ -19,11 +13,21 @@ jobs:
1913
- name: Set up JDK
2014
uses: actions/setup-java@v4
2115
with:
22-
distribution: 'adopt'
16+
distribution: 'temurin'
2317
java-version: '21'
24-
cache: 'gradle'
18+
cache: 'maven'
19+
20+
- name: Cache Maven packages
21+
uses: actions/cache@v4
22+
with:
23+
path: ~/.m2/repository
24+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
25+
restore-keys: |
26+
${{ runner.os }}-maven-
2527
26-
- name: CS Comparison
28+
# Run the comparison using the test classpath
29+
- name: Build and run CS Comparison
2730
run: |
28-
chmod +x gradlew
29-
./gradlew :staging-client-java-cs:csIntegrationTest
31+
chmod +x ./mvnw
32+
./mvnw -B test-compile -DskipTests
33+
./mvnw -B exec:java -DskipTests -Dexec.mainClass=com.imsweb.staging.cs.CsIntegrationTest -Dexec.classpathScope=test

.github/workflows/integration.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,30 @@ jobs:
1818
- name: Set up JDK
1919
uses: actions/setup-java@v4
2020
with:
21-
distribution: 'adopt'
21+
distribution: 'temurin'
2222
java-version: '21'
23-
cache: 'gradle'
23+
cache: 'maven'
24+
25+
- name: Cache Maven packages
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.m2/repository
29+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
30+
restore-keys: |
31+
${{ runner.os }}-maven-
2432
2533
- name: Cache SonarCloud packages
2634
uses: actions/cache@v4
2735
with:
2836
path: ~/.sonar/cache
2937
key: ${{ runner.os }}-sonar
30-
restore-keys: ${{ runner.os }}-sonar
38+
restore-keys: |
39+
${{ runner.os }}-sonar
3140
3241
- name: Build and test
3342
env:
3443
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
3544
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3645
run: |
37-
chmod +x gradlew
38-
./gradlew build sonar
46+
chmod +x ./mvnw
47+
./mvnw -B verify sonar:sonar

.github/workflows/publish.yml

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,76 @@
1-
# Publish to Maven Central
1+
# Publish to Maven Central (Maven)
2+
#
3+
# Non-SNAPSHOT releases are done automatically on Git tag. SNAPSHOT releases are not handled by CI; use
4+
# the following command to release a SNAPSHOT (ensure the version in pom.xml is a SNAPSHOT version):
5+
#
6+
# $ .\mvnw.cmd deploy -DskipTests
7+
#
8+
# Note that to release locally you will need to set up a settings.xml file in you user
9+
# home .m2 directory. The username and password is generated at:
10+
#
11+
# https://central.sonatype.com/usertoken.
12+
#
13+
# Here is the settings.xml file:
14+
#
15+
# <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
16+
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17+
# xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
18+
# https://maven.apache.org/xsd/settings-1.0.0.xsd">
19+
# <servers>
20+
# <server>
21+
# <!-- must match <id>ossrh</id> in distributionManagement -->
22+
# <id>central</id>
23+
# <username>USERNAME FROM GENERATED TOKEN</username>
24+
# <password>PASSWORD FROM GENERATED TOKEN</password>
25+
# </server>
26+
# </servers>
27+
# </settings>
228

329
name: publish
430

531
on:
632
repository_dispatch:
733
types: manual-publish
834
release:
9-
types: [ created ]
35+
types: [ published ]
1036

1137
jobs:
1238
publish:
13-
1439
runs-on: ubuntu-latest
1540

41+
permissions:
42+
contents: read
43+
1644
steps:
1745
- name: Checkout
1846
uses: actions/checkout@v4
1947

20-
- name: Set up JDK
48+
- name: Set up JDK 21 for Maven Central
2149
uses: actions/setup-java@v4
2250
with:
23-
distribution: 'adopt'
51+
distribution: 'temurin'
2452
java-version: '21'
25-
cache: 'gradle'
53+
cache: 'maven'
54+
55+
# Must match <id> in <distributionManagement>
56+
server-id: central
57+
58+
# These are Maven properties in settings.xml; values come from env below
59+
server-username: MAVEN_CENTRAL_USERNAME
60+
server-password: MAVEN_CENTRAL_PASSWORD
2661

27-
- name: Publish to Maven Central (Portal)
28-
run: |
29-
chmod +x gradlew
30-
./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
62+
# GPG setup (uses your in-memory private key)
63+
gpg-private-key: ${{ secrets.SIGNING_KEY }}
64+
65+
# Name of env var that holds the passphrase (see pom passphraseEnvName)
66+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
67+
68+
- name: Publish to Maven Central
69+
run: mvn -B -ntp clean deploy -P release -DskipTests -Dspotbugs.skip=true -Djacoco.skip=true
3170
env:
32-
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
33-
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
34-
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
35-
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
71+
# Sonatype / Central credentials
72+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
73+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
74+
75+
# GPG passphrase (referenced by MAVEN_GPG_PASSPHRASE name)
76+
MAVEN_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}

.github/workflows/upload-algorithms.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,22 @@
33
name: upload-algorithms
44

55
on:
6-
repository_dispatch:
7-
types: manual-publish
86
release:
9-
types: [ created ]
7+
types: [published]
108

119
jobs:
1210
publish:
13-
1411
runs-on: ubuntu-latest
1512

1613
steps:
1714
- name: Checkout
1815
uses: actions/checkout@v4
1916

20-
- name: Set up JDK
21-
uses: actions/setup-java@v4
22-
with:
23-
distribution: 'adopt'
24-
java-version: '21'
25-
26-
- name: Create algorithm zips
27-
if: ${{startsWith(github.ref, 'refs/tags/v') }}
28-
run: |
29-
chmod +x gradlew
30-
./gradlew zipAlgorithms
31-
3217
- name: Add algorithms to release
3318
uses: softprops/action-gh-release@v1
34-
if: ${{startsWith(github.ref, 'refs/tags/v') }}
3519
with:
3620
files: |
37-
algorithm-cs/build/algorithms/*.zip
38-
algorithm-eod/build/algorithms/*.zip
39-
algorithm-tnm/build/algorithms/*.zip
40-
algorithm-pediatric/build/algorithms/*.zip
21+
src/test/resources/algorithms/cs-*.zip
22+
src/test/resources/algorithms/eod_public-*.zip
23+
src/test/resources/algorithms/pediatric-*.zip
24+
src/test/resources/algorithms/tnm-*.zip

.gitignore

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
1-
target
2-
build
3-
classes
4-
dist
5-
out
6-
/.idea
1+
HELP.md
2+
target/
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### STS ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
15+
### IntelliJ IDEA ###
16+
.idea
17+
*.iws
718
*.iml
8-
.dbshell
9-
.gradle
19+
*.ipr
20+
21+
### NetBeans ###
22+
/nbproject/private/
23+
/nbbuild/
24+
/dist/
25+
/nbdist/
26+
/.nb-gradle/
27+
build/
28+
!**/src/main/**/build/
29+
!**/src/test/**/build/
30+
31+
### VS Code ###
32+
.vscode/
33+
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
}

.mvn/wrapper/maven-wrapper.jar

49.5 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

0 commit comments

Comments
 (0)