diff --git a/.gitignore b/.gitignore index ac692a0..3f34a29 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .qodana build local.properties +updatePlugins_tmp.xml \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index cf2fbb9..39bee26 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,11 +15,15 @@ plugins { id("org.jetbrains.changelog") version "1.3.1" // Gradle Qodana Plugin id("org.jetbrains.qodana") version "0.1.13" + + id("maven-publish") } group = properties("pluginGroup") version = properties("pluginVersion") +apply(from="./gradle/publish.gradle") + // Configure project's dependencies repositories { mavenCentral() @@ -121,4 +125,4 @@ tasks { channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" } .split('.').first())) } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index de54d6f..fd4b6fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ pluginGroup = com.comuto.androidtemplates pluginName = Android Templates Plugin pluginRepositoryUrl = https://github.com/blablacar/android-template-plugin # SemVer format -> https://semver.org -pluginVersion = 0.0.1 +pluginVersion = 0.2.5 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. @@ -37,7 +37,12 @@ kotlin.stdlib.default.dependency = false PROJECT_NAME=Android template plugin PROJECT_DESCRIPTION=Android template plugin -VERSION_NAME=0.2 GROUP=com.comuto ARTIFACT_ID=android-template-plugin LIBRARY_NAME=android-template-plugin +PACKAGING=jar +DEVELOPER_ID=blablacar +DEVELOPER_NAME=BlaBlaCar +DEVELOPER_EMAIL=android-devs@blablacar.com + +repository_url = https://maven.pkg.github.com/blablacar/java-packages \ No newline at end of file diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 6e6071c..40392b5 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -1,6 +1,34 @@ -task letsgo(dependsOn: ['lint', 'publish']) { +def versionToDeploy = pluginVersion + +task fillTemplate { + // fill the updatePlugins template + String fileContents = new File('updatePlugins_template.xml').text + + String fileUrl = "${repository_url}/com/comuto/android-template-plugin/android-template-plugin-${version}.jar" + + def binding = [ + "plugin_url":fileUrl, + "pluginVersion":pluginVersion, + "pluginSinceBuild":pluginSinceBuild, + "pluginUntilBuild":pluginUntilBuild + ] + + def engine = new groovy.text.SimpleTemplateEngine() + def filledTemplate = engine.createTemplate(fileContents).make(binding) + + def result = filledTemplate + def destFile = new File('updatePlugins_tmp.xml') + destFile.createNewFile() + destFile.text = result +} + +tasks.publish.dependsOn(fillTemplate) + +task letsgo(dependsOn: ['publish']) { doFirst { println 'Let\'s go template plugin !' + + } } @@ -15,20 +43,28 @@ artifacts { publishing { publications { + def xmlFile = layout.projectDirectory.file('updatePlugins_tmp.xml') + def xmlArtifact = artifacts.add('archives', xmlFile) { + type 'xml' + } + + maven(MavenPublication) { + artifact xmlArtifact + groupId = GROUP + artifactId = ARTIFACT_ID + version = "index" + } + mavenJava(MavenPublication) { groupId = GROUP artifactId = ARTIFACT_ID - version = isReleaseBuild() ? VERSION_NAME : VERSION_NAME + generateSnapshotSuffix() + version = versionToDeploy - afterEvaluate { - artifact bundleReleaseAar - artifact sourcesJar - } + from components.java pom { name = PROJECT_NAME description = PROJECT_DESCRIPTION - url = WEBSITE_URL packaging = PACKAGING groupId = GROUP artifactId = ARTIFACT_ID @@ -44,15 +80,19 @@ publishing { } repositories { + /* + mavenLocal() + */ maven { - name "githubBlablacar" - url "https://maven.pkg.github.com/blablacar/java-packages" - credentials(PasswordCredentials) - } + name "githubBlablacar" + url "{repository_ur}" + credentials(PasswordCredentials) + } } } tasks.withType(AbstractPublishToMaven) { + doLast { def name = "${publication.groupId}:${publication.artifactId}:${publication.version}" if (it instanceof PublishToMavenRepository) { @@ -61,12 +101,4 @@ tasks.withType(AbstractPublishToMaven) { println "******************** Published $name to local repository *****************" } } -} - -static def generateSnapshotSuffix() { - return "-" + new Date().format("yyyyMMddHHmmssSSS", TimeZone.getTimeZone("UTC")) + "-SNAPSHOT" -} - -def isReleaseBuild() { - return project.hasProperty('env') && project.property('env') == "RELEASE" } \ No newline at end of file diff --git a/jenkins/JenkinsfilePublishDebug b/jenkins/JenkinsfilePublishDebug deleted file mode 100644 index e9e5e0b..0000000 --- a/jenkins/JenkinsfilePublishDebug +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env groovy - -pipeline { - agent { - docker { - label 'docker' - image 'eu.gcr.io/bbc-registry/android:1.20201108.114924-6c08d93' - args '-v ${HOME}/.gradle/gradle.properties:/root/.gradle/gradle.properties:ro' - } - } - - options { - buildDiscarder(logRotator(numToKeepStr: "10")) - timeout(time: 60, unit: 'MINUTES') - } - - stages { - stage('Compile and publish a version') { - environment { - GIT_SSH_COMMAND = 'ssh -o StrictHostKeyChecking=no' - GIT_AUTHOR_NAME = 'Jenkins' - EMAIL = 'svc-git@blablacar.com' - } - steps { - sshagent(credentials: ['github-blablacarbot-ssh']) { - sh 'git fetch origin' - sh "git checkout ${params.branch}" - sh "./gradlew clean letsgo --rerun-tasks" - } - } - } - } -} diff --git a/jenkins/jobs.groovy b/jenkins/jobs.groovy index b1a5696..07c8605 100644 --- a/jenkins/jobs.groovy +++ b/jenkins/jobs.groovy @@ -2,17 +2,6 @@ final String rootFolder = 'android-jobs/template-plugin' final String pipelinesFolder = 'jenkins' final String mainBranch = 'master' -final String debugParameters = ''' - parameters { - stringParam('branch', '', 'branch to publish, e.g. feature/BBC-XXXX or bugfix/BBC-XXXX') - } -''' - -return [[name : "$rootFolder/template-plugin-publish-debug", - jenkinsfile: "$pipelinesFolder/JenkinsfilePublishDebug", - branch : mainBranch, - extra : debugParameters], - - [name : "$rootFolder/template-plugin-publish-release", +return [[name : "$rootFolder/template-plugin-publish-release", jenkinsfile: "$pipelinesFolder/JenkinsfilePublishRelease", branch : mainBranch]] diff --git a/updatePlugins_template.xml b/updatePlugins_template.xml new file mode 100644 index 0000000..70031ad --- /dev/null +++ b/updatePlugins_template.xml @@ -0,0 +1,28 @@ + + + + + + + + + +