Skip to content

Commit 3bc8a6d

Browse files
committed
useless build-step removed.
1 parent f153051 commit 3bc8a6d

File tree

5 files changed

+119
-70
lines changed

5 files changed

+119
-70
lines changed

.github/workflows/gradle.yml

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Gradle
1+
name: CI
22

33
on:
44
push:
@@ -7,65 +7,74 @@ on:
77
- '**/README.md'
88
- '**/.gitignore'
99
- '.run/**'
10-
pull_request:
11-
branches: [ master ]
12-
paths-ignore:
13-
- '**/README.md'
14-
- '**/.gitignore'
15-
- '.run/**'
10+
tags:
11+
- "[0-9]+.[0-9]+.[0-9]+"
1612

1713
jobs:
1814
build:
19-
name: 🎉 Build
15+
name: Build Gradle Plugin
2016
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
2120
steps:
2221

23-
# Testing the plugin source requires checking out into `buildSrc`.
2422
- name: 🚚 Get latest code
2523
uses: actions/checkout@v4
2624

27-
# https://github.com/actions/setup-java
28-
- name: ☕ Set up AWS Corretto JDK 17
25+
- name: ☕ Setup JDK
2926
uses: actions/setup-java@v4
3027
with:
28+
architecture: x64
3129
distribution: corretto
3230
java-version: '17'
33-
architecture: x64
3431

35-
- name: 🔢 Configure build
36-
shell: bash
32+
- name: 🐘 Gradle Setup
33+
uses: gradle/actions/setup-gradle@v4
34+
with:
35+
gradle-version: '9.0.0'
36+
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
37+
build-scan-terms-of-use-agree: "yes"
38+
build-scan-publish: false
39+
40+
- name: 🐘 Gradle Prepare
3741
env:
38-
JAVA_KEYSTORE_DEBUG: ${{ secrets.JAVA_KEYSTORE_DEBUG }}
39-
JAVA_KEYSTORE_UPLOAD: ${{ secrets.JAVA_KEYSTORE_UPLOAD }}
40-
JAVA_KEYSTORE_PROPERTIES: ${{ secrets.JAVA_KEYSTORE_PROPERTIES }}
41-
AGC_API_CONFIG: ${{ secrets.AGC_API_CONFIG }}
42-
AGC_APP_RELEASE_CONFIG: ${{ secrets.AGC_APP_RELEASE_CONFIG }}
43-
AGC_APP_DEBUG_CONFIG: ${{ secrets.AGC_APP_DEBUG_CONFIG }}
42+
PLUGIN_NS: 'io/syslogic'
43+
PLUGIN_NAME: 'agconnect-publishing-gradle-plugin'
44+
GITHUB_ACTOR: ${{ GITHUB.REPOSITORY_OWNER }}
45+
GITHUB_TOKEN: ${{ SECRETS.GITHUB_TOKEN }}
4446
run: |
47+
mkdir build
4548
chmod +x ./gradlew
46-
mkdir ~/.android
47-
mkdir $GITHUB_WORKSPACE/distribution
48-
mkdir -p $GITHUB_WORKSPACE/mobile/src/huaweiDebug
49-
mkdir -p $GITHUB_WORKSPACE/mobile/src/huaweiRelease
50-
echo $JAVA_KEYSTORE_DEBUG > ~/.android/debug.keystore
51-
echo $JAVA_KEYSTORE_UPLOAD > ~/.android/upload.keystore
52-
echo $JAVA_KEYSTORE_PROPERTIES > $GITHUB_WORKSPACE/keystore.properties
53-
echo $AGC_API_CONFIG > $GITHUB_WORKSPACE/distribution/agc-apiclient.json
54-
echo $AGC_APP_DEBUG_CONFIG > $GITHUB_WORKSPACE/mobile/src/huaweiDebug/agconnect-services.json
55-
echo $AGC_APP_RELEASE_CONFIG > $GITHUB_WORKSPACE/mobile/src/huaweiRelease/agconnect-services.json
49+
PLUGIN_VERSION=$(cat ./gradle/libs.versions.toml | grep plugin_version | grep -Po '[\d.]+' | head -n1)
50+
PACKAGE=https://maven.pkg.github.com/${{ env.GITHUB_ACTOR }}/${{ env.PLUGIN_NAME }}/${{ env.PLUGIN_NS }}/${{ env.PLUGIN_NAME }}/$PLUGIN_VERSION/${{ env.PLUGIN_NAME }}-$PLUGIN_VERSION.jar
51+
if wget --user ${{ env.GITHUB_ACTOR }} --password ${{ env.GITHUB_TOKEN }} -q --method=HEAD $PACKAGE; then
52+
echo "::notice::Version $PLUGIN_VERSION already published."
53+
echo "PUBLISHED=true" >> "$GITHUB_ENV"
54+
else
55+
echo "::notice::Version $PLUGIN_VERSION not yet published."
56+
echo "PUBLISHED=false" >> "$GITHUB_ENV"
57+
fi
58+
59+
- name: 🐘 Gradle Build
60+
if: ${{ env.PUBLISHED == 'true' }}
61+
run: |
62+
gradle --no-daemon :build
63+
ls -la ./build/libs | grep jar
5664
57-
- name: Build with Gradle
65+
- name: 🐘 Gradle Build & Publish
66+
if: ${{ env.PUBLISHED == 'false' }}
5867
env:
59-
AGC_PACKAGE_ID: ${{ secrets.AGC_PACKAGE_ID }}
68+
GITHUB_ACTOR: ${{ GITHUB.REPOSITORY_OWNER }}
69+
GITHUB_TOKEN: ${{ SECRETS.GITHUB_TOKEN }}
6070
run: |
61-
./gradlew :build
62-
cd ./build/libs
63-
ls -la | grep jar
71+
gradle --no-daemon :build :publishGPRPublicationToGitHubPackagesRepository
72+
ls -la ./build/libs | grep jar
6473
6574
- name: 📦 Retain Artifact (JAR)
6675
id: retain-plugin-jar
6776
uses: actions/upload-artifact@v4
6877
with:
69-
name: buildSrc
78+
name: agconnect-publishing-gradle-plugin
7079
path: ./build/libs/*.jar
7180
retention-days: 14

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ buildscript {
3535
maven { url 'https://jitpack.io' }
3636
}
3737
dependencies {
38-
classpath "com.android.tools.build:gradle:8.11.0"
39-
classpath "com.huawei.agconnect:agcp:1.9.3.300"
38+
classpath "com.android.tools.build:gradle:8.11.1"
39+
classpath "com.huawei.agconnect:agcp:1.9.3.302"
4040
classpath "io.syslogic:agconnect-publishing-gradle-plugin:1.4.1"
4141
}
4242
}
@@ -73,13 +73,20 @@ plugins {
7373
````groovy
7474
/** Huawei AppGallery Connect: agc-apiclient.json */
7575
def json_agc = "distribution${File.separator}agconnect_apiclient.json"
76-
if (rootProject.file(json_agc).exists()) {
77-
agcPublishing {
78-
configFile = rootProject.file(json_agc).absolutePath
79-
releaseType = 1
80-
verbose = false
81-
logHttp = true
82-
}
76+
77+
agcPublishing {
78+
configFile = rootProject.file(json_agc).absolutePath
79+
releaseType = 1
80+
verbose = false
81+
logHttp = true
82+
}
83+
````
84+
85+
````kotlin
86+
configure<PublishingExtensionImpl> {
87+
configFile = rootProject.file(json_agc).absolutePath
88+
verbose = false
89+
logHttp = true
8390
}
8491
````
8592

build.gradle.kts

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.codehaus.groovy.runtime.DefaultGroovyMethods.head
2+
13
// :buildSrc
24
plugins {
35
alias(buildSrc.plugins.maven.publish)
@@ -43,7 +45,6 @@ gradlePlugin {
4345
}
4446
}
4547

46-
4748
tasks.withType<Test>().configureEach {
4849
useJUnitPlatform()
4950
}
@@ -62,7 +63,7 @@ val implCls: Configuration by configurations.creating {
6263
val javadocs by tasks.registering(Javadoc::class) {
6364
title = "${project.ext.get("plugin_display_name")} ${project.ext.get("plugin_version")} API"
6465
classpath += implCls.asFileTree.filter {it.extension == "jar"}
65-
setDestinationDir(project.file("/build/javadoc"))
66+
destinationDir = rootProject.file("build/javadoc")
6667
source = sourceSets.main.get().allJava
6768
// options.links = "https://docs.oracle.com/en/java/javase/17/docs/api/"
6869
// options.linkSource = true
@@ -72,7 +73,7 @@ val javadocs by tasks.registering(Javadoc::class) {
7273

7374
val javadocJar by tasks.registering(Jar::class) {
7475
archiveClassifier.set("javadoc")
75-
from(project.file("/build/javadoc"))
76+
from(rootProject.file("build/javadoc"))
7677
dependsOn(javadocs)
7778
}
7879

@@ -89,25 +90,54 @@ artifacts {
8990
archives(sourcesJar)
9091
}
9192

92-
afterEvaluate {
93-
publishing {
94-
publications {
95-
create<MavenPublication>("release") {
96-
from(components.getByName("java"))
97-
groupId = "${project.ext.get("group_id")}"
98-
artifactId = "${project.ext.get("plugin_identifier")}"
99-
version = "${project.ext.get("plugin_version")}"
100-
pom {
101-
name = "${project.ext.get("plugin_display_name")}"
102-
description = "${project.ext.get("plugin_description")}"
103-
url = "https://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}"
104-
scm {
105-
connection = "scm:git:git://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}.git"
106-
developerConnection = "scm:git:ssh://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}.git"
107-
url = "https://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}/"
108-
}
93+
configure<PublishingExtension> {
94+
repositories {
95+
maven {
96+
name = "GitHubPackages"
97+
url = uri("https://maven.pkg.github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}")
98+
credentials {
99+
username = System.getenv("GITHUB_ACTOR")
100+
password = System.getenv("GITHUB_TOKEN")
101+
}
102+
}
103+
}
104+
105+
publications {
106+
register<MavenPublication>("GPR") {
107+
from(components.getByName("java"))
108+
groupId = "${project.ext.get("group_id")}"
109+
artifactId = "${project.ext.get("plugin_identifier")}"
110+
version = "${project.ext.get("plugin_version")}"
111+
pom {
112+
name = "${project.ext.get("plugin_display_name")}"
113+
description = "${project.ext.get("plugin_description")}"
114+
url = "https://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}"
115+
scm {
116+
connection = "scm:git:git://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}.git"
117+
developerConnection = "scm:git:ssh://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}.git"
118+
url = "https://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}/"
119+
}
120+
}
121+
}
122+
123+
register<MavenPublication>("JitPack") {
124+
from(components.getByName("java"))
125+
groupId = "${project.ext.get("group_id")}"
126+
artifactId = "${project.ext.get("plugin_identifier")}"
127+
version = "${project.ext.get("plugin_version")}"
128+
pom {
129+
name = "${project.ext.get("plugin_display_name")}"
130+
description = "${project.ext.get("plugin_description")}"
131+
url = "https://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}"
132+
scm {
133+
connection = "scm:git:git://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}.git"
134+
developerConnection = "scm:git:ssh://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}.git"
135+
url = "https://github.com/${project.ext.get("github_handle")}/${project.ext.get("plugin_identifier")}/"
109136
}
110137
}
111138
}
112139
}
113140
}
141+
142+
// tasks.withType<MavenPublication>().forEach { pub: MavenPublication ->
143+
// }

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# buildSrc Gradle Settings
22
# @see https://docs.gradle.org/current/userguide/build_environment.html
33
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
4+
org.gradle.configuration-cache=true
45
org.gradle.welcome=never
6+
# org.gradle.debug=true

settings.gradle.kts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
// settings.gradle.kts
2+
23
pluginManagement {
34
repositories {
4-
mavenCentral {
5-
content {
6-
includeGroupByRegex("org.apache.*")
7-
}
8-
}
95
gradlePluginPortal {
106
content {
117
excludeGroupByRegex("org.apache.*")
128
includeGroupByRegex("com.gradle.*")
139
}
1410
}
11+
mavenCentral {
12+
content {
13+
includeGroupByRegex("org.apache.*")
14+
}
15+
}
1516
}
1617
}
1718

0 commit comments

Comments
 (0)