From 1a9030102da6190cba966b0bc2c4b0551e16a714 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 27 Jul 2022 08:31:52 +0200 Subject: [PATCH] Add gradle & CI stuffs --- .gitlab-ci.yml | 21 ++++++++++++-------- build.gradle | 54 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index def08d8..bb74320 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,20 @@ -image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:latest +image: "registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:latest" -stages: # List of stages for jobs, and their order of execution - - build +stages: +- build +- deploy -build-job: # This job runs in the build stage, which runs first. +build-job: stage: build script: - - gradle build + - gradle build artifacts: paths: - - build/libs/ - - + - build/libs +deploy: + stage: deploy + script: + - gradle publish + only: + - master diff --git a/build.gradle b/build.gradle index a3c2994..40c7540 100644 --- a/build.gradle +++ b/build.gradle @@ -26,6 +26,7 @@ plugins { id("java-library") id("com.google.protobuf") version("0.8.12") id("org.jetbrains.kotlin.jvm") version("1.4.10") + id("maven-publish") } group("com.aurora") @@ -69,4 +70,55 @@ protobuf { protoc { artifact = ("com.google.protobuf:protoc:3.10.0") } -} \ No newline at end of file +} + +publishing { + publications { + maven(MavenPublication) { + groupId 'foundation.e' + artifactId 'gplayapi' + version version + artifact "$buildDir/libs/gplayapi-${version}.jar" + + //generate pom nodes for dependencies + pom.withXml { + def dependenciesNode = asNode().appendNode('dependencies') + configurations.implementation.allDependencies.each { dependency -> + if (dependency.name != 'unspecified') { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', dependency.group) + dependencyNode.appendNode('artifactId', dependency.name) + dependencyNode.appendNode('version', dependency.version) + } + } + } + repositories { + def ciJobToken = System.getenv("CI_JOB_TOKEN") + def ciApiV4Url = System.getenv("CI_API_V4_URL") + if (ciJobToken != null) { + maven { + url "${ciApiV4Url}/projects/1269/packages/maven" + credentials(HttpHeaderCredentials) { + name = 'Job-Token' + value = ciJobToken + } + authentication { + header(HttpHeaderAuthentication) + } + } + } else { + maven { + url "https://gitlab.e.foundation/api/v4/projects/1269/packages/maven" + credentials(HttpHeaderCredentials) { + name = "Private-Token" + value = gitLabPrivateToken + } + authentication { + header(HttpHeaderAuthentication) + } + } + } + } + } + } +} -- GitLab