Skip to content

Commit

Permalink
Restructure into Maven
Browse files Browse the repository at this point in the history
  • Loading branch information
RhysB committed Dec 21, 2024
1 parent cd950ce commit 27430e3
Show file tree
Hide file tree
Showing 15 changed files with 800 additions and 6 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: build-and-test
on:
pull_request:
types:
- opened
- synchronize
- reopened
push:
branches:
- master
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 1.8
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 8

- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: 3.9.1

- name: build application
shell: bash
run: |
mvn clean install
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ github.event.repository.name }}-artifact
path: target/*.jar
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release Workflow

on:
push:
branches:
- main
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 1.8
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 8

- name: Get the version from pom.xml
id: get_version
run: echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV

- name: Fail if snapshot version
run: |
if [[ $PROJECT_VERSION == *"-SNAPSHOT"* ]]; then
echo "Snapshot versions are not releasable"
exit 0
fi
- name: Build with Maven
run: mvn clean package

- name: Create GitHub Release
if: ${{ !endsWith(env.PROJECT_VERSION, '-SNAPSHOT') }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.PROJECT_VERSION }}
files: |
target/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,5 @@ modules.xml
hs_err_pid*

# End of https://www.gitignore.io/api/java,intellij,intellij+all,intellij+iml

target/
93 changes: 93 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.johnymuffin.beta</groupId>
<artifactId>jdetector</artifactId>
<version>1.0.1-SNAPSHOT</version>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.apache.hc</pattern>
<shadedPattern>com.johnymuffin.beta.jdetector.dependencies.apache.hc</shadedPattern>
</relocation>
<relocation>
<pattern>mozilla</pattern>
<shadedPattern>com.johnymuffin.beta.jdetector.dependencies.mozilla</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>com.johnymuffin.beta.jdetector.dependencies.slf4j</shadedPattern>
</relocation>
</relocations>
<artifactSet>
<includes>
<include>org.apache.httpcomponents.client5:httpclient5</include>
<include>org.apache.httpcomponents.core5:httpcore5</include>
<include>org.apache.httpcomponents.core5:httpcore5-h2</include>
<include>org.slf4j:slf4j-api</include>
<include>org.apache.httpcomponents.client5:httpclient5-fluent</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<releases />
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>johnymuffin-nexus-releases</id>
<url>https://repository.johnymuffin.com/repository/maven-public/</url>
</repository>
<repository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots />
<id>johnymuffin-nexus-snapshots</id>
<url>https://repository.johnymuffin.com/repository/maven-snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.legacyminecraft.poseidon</groupId>
<artifactId>poseidon-craftbukkit</artifactId>
<version>1.1.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>
149 changes: 149 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.johnymuffin.beta</groupId>
<artifactId>jdetector</artifactId>
<version>2.0.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>src/test/java/</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version> <!-- Use the latest version available -->
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<!-- Define the relocation of httpclient5 -->
<relocation>
<pattern>org.apache.hc</pattern>
<shadedPattern>com.johnymuffin.beta.jdetector.dependencies.apache.hc</shadedPattern>
</relocation>
<relocation>
<pattern>mozilla</pattern>
<shadedPattern>com.johnymuffin.beta.jdetector.dependencies.mozilla</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>com.johnymuffin.beta.jdetector.dependencies.slf4j</shadedPattern>
</relocation>
</relocations>
<artifactSet>
<includes>
<!-- Include the httpclient5 dependency -->
<include>org.apache.httpcomponents.client5:httpclient5</include>
<include>org.apache.httpcomponents.core5:httpcore5</include>
<include>org.apache.httpcomponents.core5:httpcore5-h2</include>
<include>org.slf4j:slf4j-api</include>
<include>org.apache.httpcomponents.client5:httpclient5-fluent</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

<repositories>
<!-- Repository for resolving release dependencies -->
<repository>
<id>johnymuffin-nexus-releases</id>
<url>https://repository.johnymuffin.com/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Repository for resolving snapshot dependencies -->
<repository>
<id>johnymuffin-nexus-snapshots</id>
<url>https://repository.johnymuffin.com/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.legacyminecraft.poseidon</groupId>
<artifactId>poseidon-craftbukkit</artifactId>
<version>1.1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Loading

0 comments on commit 27430e3

Please sign in to comment.