Skip to content

Commit f449799

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

File tree

5 files changed

+117
-70
lines changed

5 files changed

+117
-70
lines changed

.github/workflows/gradle.yml

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,78 @@
1-
name: Gradle
2-
1+
name: CI
32
on:
43
push:
54
branches: [ master ]
65
paths-ignore:
76
- '**/README.md'
87
- '**/.gitignore'
98
- '.run/**'
10-
pull_request:
11-
branches: [ master ]
12-
paths-ignore:
13-
- '**/README.md'
14-
- '**/.gitignore'
15-
- '.run/**'
9+
tags:
10+
- "[0-9]+.[0-9]+.[0-9]+"
1611

1712
jobs:
1813
build:
19-
name: 🎉 Build
14+
name: Build Gradle Plugin
2015
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
2119
steps:
2220

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

2724
# 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: Setup Gradle
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 Build
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 }}
46+
4447
run: |
48+
mkdir build
4549
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
50+
gradle --no-daemon -Pversion=${{ github.event.push.tag_name }} :build
51+
cd ./build/libs
52+
ls -la | grep jar
53+
54+
PLUGIN_VERSION=$(git describe --tags --abbrev=0)
55+
PACKAGE=https://maven.pkg.github.com/${{ env.GITHUB_ACTOR }}/${{ env.PLUGIN_NAME }}/${{ env.PLUGIN_NS }}/${{ env.PLUGIN_NAME }}/${{ env.PLUGIN_VERSION }}/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.jar
56+
if wget --user ${{ env.GITHUB_ACTOR }} --password ${{ env.GITHUB_TOKEN }} -q --method=HEAD $PACKAGE; then
57+
echo "PUBLISHED=true" >> "$GITHUB_ENV"
58+
echo "::notice::URL exists: $PACKAGE"
59+
else
60+
echo "PUBLISHED=false" >> "$GITHUB_ENV"
61+
echo "::notice::URL does not exist: $PACKAGE"
62+
fi
5663
57-
- name: Build with Gradle
64+
- name: Gradle Publish
65+
if: ${{ env.PUBLISHED == 'false' }}
5866
env:
59-
AGC_PACKAGE_ID: ${{ secrets.AGC_PACKAGE_ID }}
67+
GITHUB_ACTOR: ${{ GITHUB.REPOSITORY_OWNER }}
68+
GITHUB_TOKEN: ${{ SECRETS.GITHUB_TOKEN }}
6069
run: |
61-
./gradlew :build
62-
cd ./build/libs
63-
ls -la | grep jar
70+
gradle --no-daemon -Pversion=${{ github.event.push.tag_name }} :publishGPRPublicationToGitHubPackagesRepository
6471
6572
- name: 📦 Retain Artifact (JAR)
6673
id: retain-plugin-jar
6774
uses: actions/upload-artifact@v4
6875
with:
69-
name: buildSrc
76+
name: agconnect-publishing-gradle-plugin
7077
path: ./build/libs/*.jar
7178
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)