Skip to content

Commit

Permalink
build: added flatten pom to resolve all variables, deploy snapshot to…
Browse files Browse the repository at this point in the history
… maven central for test
  • Loading branch information
PeterPaul-Perfana committed Jul 1, 2024
1 parent a39d340 commit badae48
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defaults:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

Expand All @@ -28,21 +28,22 @@ jobs:
echo "TAG_NAME=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
# if no tag exists, this is expected to fail
- name: Switch to git tag for release
- name: Check if tag contains SNAPSHOT
if: contains(env.TAG_NAME, 'SNAPSHOT') != true
run: |
git fetch --all --tags -f
git checkout tags/${{ env.TAG_NAME }} -b ${{ env.TAG_NAME }}-tmp-branch
echo "Tag '$TAG_NAME' does not contain 'SNAPSHOT', failing build."
exit 1
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11

# push SNAPSHOT to maven central for testing
- name: Build
run: |
./mvnw clean verify
./mvnw clean deploy
- name: Upload jar
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defaults:
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ Thumbs.db
# Folder config file
Desktop.ini
.java-version

.flattened-pom.xml
37 changes: 32 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
<system>Github</system>
<url>https://github.com/jborgers/sonar-pmd/issues</url>
</issueManagement>
<ciManagement>
<system>Travis</system>
<url>https://travis-ci.org/jborgers/sonar-pmd</url>
</ciManagement>

<licenses>
<license>
Expand Down Expand Up @@ -78,7 +74,7 @@

<properties>
<!-- use -Drevision=x.y.z to override in build -->
<revision>3.5.1-SNAPSHOT</revision>
<revision>3.5.2-SNAPSHOT</revision>
<license.owner>SonarSource SA and others</license.owner>
<license.mailto>mailto:jborgers AT jpinpoint DOT com; peter.paul.bakker AT stokpop DOT nl</license.mailto>
<pmd.version>6.55.0</pmd.version>
Expand Down Expand Up @@ -113,6 +109,7 @@
<sonar.maven.plugin.version>3.11.0.3922</sonar.maven.plugin.version>
<jacoco.maven.plugin.version>0.8.12</jacoco.maven.plugin.version>
<nexus-staging.plugin.version>1.6.13</nexus-staging.plugin.version>
<flatten.maven.plugin.version>1.6.0</flatten.maven.plugin.version>
<!-- Code Coverage -->
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.coverage.jacoco.xmlReportPaths>sonar-pmd-plugin/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
Expand Down Expand Up @@ -237,6 +234,11 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten.maven.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>

Expand Down Expand Up @@ -353,6 +355,31 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<configuration>
<flattenMode>oss</flattenMode>
</configuration>
<executions>
<!-- enable flattening -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- ensure proper cleanup -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit badae48

Please sign in to comment.