Skip to content

Commit 68041d6

Browse files
authored
Merge pull request #49 from neboskreb/48-migrate-the-publishing-to-the-new-maven-central-flow
Use JReleaser for publishing
2 parents 40ca07c + 7b9e922 commit 68041d6

File tree

9 files changed

+345
-84
lines changed

9 files changed

+345
-84
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="PUBLISH android-log4j2:junit4" type="GradleRunConfiguration" factoryName="Gradle" folderName="PUBLISH">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="~\Desktop\CONTRIB\android-log4j2\junit4" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list>
13+
<option value="jreleaserDeploy" />
14+
</list>
15+
</option>
16+
<option name="vmOptions" />
17+
</ExternalSystemSettings>
18+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
19+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
20+
<DebugAllEnabled>false</DebugAllEnabled>
21+
<RunAsTest>false</RunAsTest>
22+
<method v="2" />
23+
</configuration>
24+
</component>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="PUBLISH android-log4j2:junit5" type="GradleRunConfiguration" factoryName="Gradle" folderName="PUBLISH">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="$PROJECT_DIR$/junit5" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list>
13+
<option value="jreleaserDeploy" />
14+
</list>
15+
</option>
16+
<option name="vmOptions" />
17+
</ExternalSystemSettings>
18+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
19+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
20+
<DebugAllEnabled>false</DebugAllEnabled>
21+
<RunAsTest>false</RunAsTest>
22+
<method v="2" />
23+
</configuration>
24+
</component>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="PUBLISH android-log4j2:library" type="GradleRunConfiguration" factoryName="Gradle" folderName="PUBLISH">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="$PROJECT_DIR$/library" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list>
13+
<option value="jreleaserDeploy" />
14+
</list>
15+
</option>
16+
<option name="vmOptions" />
17+
</ExternalSystemSettings>
18+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
19+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
20+
<DebugAllEnabled>false</DebugAllEnabled>
21+
<RunAsTest>false</RunAsTest>
22+
<method v="2" />
23+
</configuration>
24+
</component>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="PUBLISH android-log4j2:migration" type="GradleRunConfiguration" factoryName="Gradle" folderName="PUBLISH">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="$PROJECT_DIR$/migration" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list>
13+
<option value="jreleaserDeploy" />
14+
</list>
15+
</option>
16+
<option name="vmOptions" />
17+
</ExternalSystemSettings>
18+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
19+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
20+
<DebugAllEnabled>false</DebugAllEnabled>
21+
<RunAsTest>false</RunAsTest>
22+
<method v="2" />
23+
</configuration>
24+
</component>

junit4/build.gradle

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,21 @@ plugins {
22
id 'com.android.library'
33
id 'de.mannodermaus.android-junit5'
44
id 'maven-publish'
5-
id 'signing'
5+
id 'org.jreleaser'
66
}
77

88
def libraryGroup = 'io.github.neboskreb'
99
def libraryArtifact = 'android-log4j2-junit4'
1010
def libraryVersion = '2.24.1-SNAPSHOT'
1111

12+
final stagingDirectory = layout.buildDirectory.dir('staging-deploy')
13+
1214
afterEvaluate {
1315
publishing {
1416
repositories {
1517
maven {
16-
name = "github-packages"
17-
url = uri("https://maven.pkg.github.com/neboskreb/android-log4j2")
18-
credentials {
19-
username = project.findProperty("github_packages_user") ?: System.getenv("PACKAGES_USERNAME")
20-
password = project.findProperty("github_packages_token") ?: System.getenv("PACKAGES_TOKEN")
21-
}
22-
}
23-
maven {
24-
name "MavenCentral"
25-
if (version.endsWith('SNAPSHOT')) {
26-
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
27-
} else {
28-
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
29-
}
30-
credentials {
31-
username = project.findProperty("mavenCentralUser") ?: System.getenv("MAVEN_USERNAME")
32-
password = project.findProperty("mavenCentralPass") ?: System.getenv("MAVEN_PASSWORD")
33-
}
18+
name = 'staging'
19+
url = stagingDirectory
3420
}
3521
}
3622

@@ -71,8 +57,58 @@ afterEvaluate {
7157
}
7258
}
7359

74-
signing {
75-
sign publishing.publications.release
60+
jreleaser {
61+
gitRootSearch = true
62+
signing {
63+
active = 'RELEASE'
64+
armored = true
65+
verify = false
66+
67+
version = libraryVersion
68+
69+
secretKey = getConfiguredValue('signing.key.armored', 'PGP_SIGNING_KEY_ARMORED')
70+
passphrase = getConfiguredValue('signing.password', 'PGP_SIGNING_PASSWORD')
71+
}
72+
deploy {
73+
maven {
74+
final String staging = stagingDirectory.get().toString()
75+
76+
github {
77+
packages {
78+
active = 'RELEASE'
79+
url = 'https://maven.pkg.github.com/neboskreb/android-log4j2'
80+
stagingRepository(staging)
81+
82+
sign = true
83+
84+
username = getConfiguredValue('github_packages_user', 'PACKAGES_USERNAME')
85+
password = getConfiguredValue('github_packages_token', 'PACKAGES_TOKEN')
86+
}
87+
}
88+
89+
mavenCentral {
90+
sonatype {
91+
active = 'RELEASE'
92+
url = 'https://central.sonatype.com/api/v1/publisher'
93+
stagingRepository(staging)
94+
95+
sign = true
96+
97+
username = getConfiguredValue('mavenCentralUser', 'MAVEN_USERNAME')
98+
password = getConfiguredValue('mavenCentralPass', 'MAVEN_PASSWORD')
99+
100+
// Android release contains .aar instead of .jar, which is not currently supported by the rules validator.
101+
// See https://github.com/jreleaser/jreleaser.github.io/issues/85
102+
// TODO re-enable the rules check once the .aar is supported
103+
applyMavenCentralRules = false
104+
}
105+
}
106+
}
107+
}
108+
}
109+
110+
tasks.named('jreleaserDeploy') {
111+
dependsOn publishReleasePublicationToStagingRepository
76112
}
77113
}
78114

@@ -121,3 +157,8 @@ dependencies {
121157
androidTestImplementation 'androidx.test:runner:1.7.0'
122158
androidTestImplementation 'junit:junit:4.13.2'
123159
}
160+
161+
162+
private String getConfiguredValue(String projectProperty, String environmentVariable) {
163+
return project.findProperty(projectProperty) ?: System.getenv(environmentVariable)
164+
}

junit5/build.gradle

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,21 @@ plugins {
22
id 'com.android.library'
33
id 'de.mannodermaus.android-junit5'
44
id 'maven-publish'
5-
id 'signing'
5+
id 'org.jreleaser'
66
}
77

88
def libraryGroup = 'io.github.neboskreb'
99
def libraryArtifact = 'android-log4j2-junit5'
1010
def libraryVersion = '2.24.1-SNAPSHOT'
1111

12+
final stagingDirectory = layout.buildDirectory.dir('staging-deploy')
13+
1214
afterEvaluate {
1315
publishing {
1416
repositories {
1517
maven {
16-
name = "github-packages"
17-
url = uri("https://maven.pkg.github.com/neboskreb/android-log4j2")
18-
credentials {
19-
username = project.findProperty("github_packages_user") ?: System.getenv("PACKAGES_USERNAME")
20-
password = project.findProperty("github_packages_token") ?: System.getenv("PACKAGES_TOKEN")
21-
}
22-
}
23-
maven {
24-
name "MavenCentral"
25-
if (version.endsWith('SNAPSHOT')) {
26-
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
27-
} else {
28-
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
29-
}
30-
credentials {
31-
username = project.findProperty("mavenCentralUser") ?: System.getenv("MAVEN_USERNAME")
32-
password = project.findProperty("mavenCentralPass") ?: System.getenv("MAVEN_PASSWORD")
33-
}
18+
name = 'staging'
19+
url = stagingDirectory
3420
}
3521
}
3622

@@ -71,8 +57,58 @@ afterEvaluate {
7157
}
7258
}
7359

74-
signing {
75-
sign publishing.publications.release
60+
jreleaser {
61+
gitRootSearch = true
62+
signing {
63+
active = 'RELEASE'
64+
armored = true
65+
verify = false
66+
67+
version = libraryVersion
68+
69+
secretKey = getConfiguredValue('signing.key.armored', 'PGP_SIGNING_KEY_ARMORED')
70+
passphrase = getConfiguredValue('signing.password', 'PGP_SIGNING_PASSWORD')
71+
}
72+
deploy {
73+
maven {
74+
final String staging = stagingDirectory.get().toString()
75+
76+
github {
77+
packages {
78+
active = 'RELEASE'
79+
url = 'https://maven.pkg.github.com/neboskreb/android-log4j2'
80+
stagingRepository(staging)
81+
82+
sign = true
83+
84+
username = getConfiguredValue('github_packages_user', 'PACKAGES_USERNAME')
85+
password = getConfiguredValue('github_packages_token', 'PACKAGES_TOKEN')
86+
}
87+
}
88+
89+
mavenCentral {
90+
sonatype {
91+
active = 'RELEASE'
92+
url = 'https://central.sonatype.com/api/v1/publisher'
93+
stagingRepository(staging)
94+
95+
sign = true
96+
97+
username = getConfiguredValue('mavenCentralUser', 'MAVEN_USERNAME')
98+
password = getConfiguredValue('mavenCentralPass', 'MAVEN_PASSWORD')
99+
100+
// Android release contains .aar instead of .jar, which is not currently supported by the rules validator.
101+
// See https://github.com/jreleaser/jreleaser.github.io/issues/85
102+
// TODO re-enable the rules check once the .aar is supported
103+
applyMavenCentralRules = false
104+
}
105+
}
106+
}
107+
}
108+
}
109+
110+
tasks.named('jreleaserDeploy') {
111+
dependsOn publishReleasePublicationToStagingRepository
76112
}
77113
}
78114

@@ -125,3 +161,8 @@ dependencies {
125161
androidTestImplementation 'org.junit.jupiter:junit-jupiter'
126162
androidTestImplementation 'org.junit.platform:junit-platform-launcher'
127163
}
164+
165+
166+
private String getConfiguredValue(String projectProperty, String environmentVariable) {
167+
return project.findProperty(projectProperty) ?: System.getenv(environmentVariable)
168+
}

0 commit comments

Comments
 (0)