Skip to content

Commit 10ccf09

Browse files
committed
Added publishing
1 parent 111fb26 commit 10ccf09

File tree

4 files changed

+53
-21
lines changed

4 files changed

+53
-21
lines changed

.github/publish.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Publish package to the Maven Central Repository
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Set up Java
11+
uses: actions/setup-java@v2
12+
with:
13+
java-version: '8'
14+
distribution: 'adopt'
15+
- name: Validate Gradle wrapper
16+
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
17+
- name: Publish package
18+
run: gradle publish
19+
env:
20+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
21+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

application/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dependencies {
22
implementation project(":common")
3-
compile "com.google.code.gson:gson:$gsonVersion"
3+
implementation "com.google.code.gson:gson:$gsonVersion"
44
}

build.gradle

+30-19
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
plugins {
2-
id 'java'
3-
id 'com.github.johnrengelman.shadow' version '6.1.0'
4-
}
5-
6-
repositories {
7-
mavenCentral()
8-
}
9-
101
allprojects {
112
apply plugin: "java"
12-
apply plugin: 'com.github.johnrengelman.shadow'
3+
apply plugin: "maven-publish"
134

145
ext {
156
husbylibVersion = "0.1." + ('git rev-list --count HEAD'.execute().text.trim())
@@ -20,7 +11,7 @@ allprojects {
2011
lombokVersion = "1.18.20"
2112
}
2213

23-
group "com.noahhusby"
14+
group "com.noahhusby.lib"
2415
version "$husbylibVersion"
2516

2617
tasks.withType(JavaCompile) {
@@ -42,16 +33,36 @@ allprojects {
4233
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
4334
}
4435

45-
task sourcesJar(type: Jar, dependsOn: classes) {
46-
classifier = 'sources'
47-
from sourceSets.main.allSource
48-
}
36+
publishing {
37+
repositories {
38+
if (System.getenv("MAVEN_USERNAME") != null && System.getenv("MAVEN_PASSWORD")) {
39+
maven {
40+
credentials {
41+
username = "$MAVEN_USERNAME"
42+
password = "$MAVEN_PASSWORD"
43+
}
44+
name = "HusbyLib"
45+
url = "https://maven.noahhusby.com/releases"
46+
}
47+
}
48+
}
49+
50+
publications {
51+
maven(MavenPublication) {
52+
groupId = "com.noahhusby.lib"
53+
artifactId = "HusbyLib".equalsIgnoreCase(project.name) ? "all" : project.name
54+
version = project.version
4955

50-
shadowJar{
51-
archiveFileName = "HusbyLib-${baseName}-${version}.jar"
56+
from components.java
57+
}
58+
}
5259
}
60+
}
5361

54-
artifacts {
55-
archives shadowJar
62+
dependencies {
63+
for (Project prj : project.allprojects) {
64+
if (!"HusbyLib".equalsIgnoreCase(prj.name) && prj.parent.name.equalsIgnoreCase("HusbyLib")) {
65+
implementation project(":" + prj.name)
66+
}
5667
}
5768
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)