Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
Update pom to ignore provided dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Nov 23, 2022
1 parent d34b0b4 commit beae57e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 12 deletions.
38 changes: 26 additions & 12 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,43 @@ jobs:
with:
java-version: 8
distribution: temurin
- name: Install required software
run: |
sudo apt install xmlstarlet
- name: Get project settings
run: |
shortname=$(xmlstarlet sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "//x:project/x:artifactId/text()" pom.xml)
version=$(xmlstarlet sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "//x:project/x:version/text()" pom.xml)
echo "BUILD_NAME=${shortname}" >> $GITHUB_ENV
echo "BUILD_VERSION=${version}" >> $GITHUB_ENV
echo "BUILD_ARTIFACT=$shortname}-${version}" >> $GITHUB_ENV"
- name: Validate version number
if: ${{ ! inputs.skip_validation }}
run: |
[ "${{ inputs.version }}" == "$(cat pom.xml | grep -m 1 '<version>' | tr -d '<>/[:alpha:][:space:]')" ] || (>&2 echo "Version does not match value in pom.xml"; exit -1)
[ "${{ inputs.version }}" == "${BUILD_VERSION}" ] || (>&2 echo "Version does not match value in pom.xml"; exit -1)
[ "${{ inputs.version }}" == "$(cat README.md | grep -m 1 '<version>' | tr -d '<>/[:alpha:][:space:]')" ] || (>&2 echo "Version does not match value in README.md"; exit -1)
- name: Build artifact
run: mvn package javadoc:jar
- name: Sign Maven artifacts and create bundle
if: ${{ inputs.publish_maven }}
run: |
echo -n "${GPG_SIGNING_KEY}" | base64 --decode | gpg --import
mkdir maven
cp pom.xml maven/gd-${{ inputs.version }}.pom
cp target/gd-${{ inputs.version }}.jar maven/gd-${{ inputs.version }}.jar
cp target/gd-${{ inputs.version }}-sources.jar maven/gd-${{ inputs.version }}-sources.jar
cp target/gd-${{ inputs.version }}-javadoc.jar maven/gd-${{ inputs.version }}-javadoc.jar
cp pom.xml maven/${BUILD_ARTIFACT}.pom
cp target/${BUILD_ARTIFACT}.jar maven/
cp target/${BUILD_ARTIFACT}-jar-all-dependencies.jar maven/
cp target/${BUILD_ARTIFACT}-sources.jar maven/
cp target/${BUILD_ARTIFACT}-javadoc.jar maven/
pushd maven
gpg -ab gd-${{ inputs.version }}.pom
gpg -ab gd-${{ inputs.version }}.jar
gpg -ab gd-${{ inputs.version }}-sources.jar
gpg -ab gd-${{ inputs.version }}-javadoc.jar
gpg -ab ${BUILD_ARTIFACT}.pom
gpg -ab ${BUILD_ARTIFACT}.jar
gpg -ab ${BUILD_ARTIFACT}-jar-all-dependencies.jar
gpg -ab ${BUILD_ARTIFACT}-sources.jar
gpg -ab ${BUILD_ARTIFACT}-javadoc.jar
jar -cvf gd-${{ inputs.version }}-bundle.jar *
jar -cvf ${BUILD_ARTIFACT}-bundle.jar *
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
- name: Upload Maven bundle
Expand All @@ -65,11 +78,12 @@ jobs:
- name: Stage GitHub release
if: ${{ inputs.publish_github }}
run: |
gh release create "v${{ inputs.version }}" --draft --title "Version ${{ inputs.version }}" target/gd-${{ inputs.version }}.jar
gh release create "v${{ inputs.version }}" --draft --title "Version ${{ inputs.version }}" \
target/${BUILD_ARTIFACT}.jar target/${BUILD_ARTIFACT}-jar-all-dependencies.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release artifacts
uses: actions/upload-artifact@v3
with:
name: Release artifacts
path: target/gd-${{ inputs.version }}.jar
path: target/*.jar
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.settings/
target/
dependency-reduced-pom.xml
47 changes: 47 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,33 @@
<groupId>org.moeaframework</groupId>
<artifactId>moeaframework</artifactId>
<version>3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.joptimizer</groupId>
<artifactId>joptimizer</artifactId>
<version>5.0.0</version>
</dependency>

<!-- defining some transitive dependencies as provided so they're not included in jar-all-dependencies -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -75,6 +96,32 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<artifactSet>
<excludes>
<!-- exclude JUnit -->
<exclude>org.junit:junit</exclude>
<exclude>org.hamcrest:hamcrest</exclude>
</excludes>
</artifactSet>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit beae57e

Please sign in to comment.