From d1d5524acf0511c3e860d6d0ab34d72c1df2e38d Mon Sep 17 00:00:00 2001 From: Yohan BITTAN Date: Wed, 4 Jan 2023 15:05:15 +0100 Subject: [PATCH 1/4] Publishing artefact to maven [WIP] Jira: BBC-23342 --- build.gradle.kts | 6 +++++- gradle.properties | 6 +++++- gradle/publish.gradle | 30 ++++++++++++++++++++++++------ updatePlugins.xml | 28 ++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 updatePlugins.xml 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..244c4ae 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 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. @@ -41,3 +41,7 @@ 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 diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 6e6071c..fade2a5 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -1,7 +1,8 @@ -task letsgo(dependsOn: ['lint', 'publish']) { +task letsgo(dependsOn: ['publish']) { doFirst { println 'Let\'s go template plugin !' } + } task sourcesJar(type: Jar) { @@ -13,6 +14,13 @@ artifacts { archives sourcesJar } + +def xmlFile = layout.projectDirectory.file('updatePlugins.xml') +println "gooo ${xmlFile}" +def xmlArtifact = artifacts.add('archives', xmlFile.get().asFile) { + type 'xml' +} + publishing { publications { mavenJava(MavenPublication) { @@ -20,15 +28,14 @@ publishing { artifactId = ARTIFACT_ID version = isReleaseBuild() ? VERSION_NAME : VERSION_NAME + generateSnapshotSuffix() - afterEvaluate { - artifact bundleReleaseAar - artifact sourcesJar - } + + from components.java + + artifact xmlArtifact pom { name = PROJECT_NAME description = PROJECT_DESCRIPTION - url = WEBSITE_URL packaging = PACKAGING groupId = GROUP artifactId = ARTIFACT_ID @@ -44,15 +51,26 @@ publishing { } repositories { + mavenLocal() + /* + flatDir { + dirs "${project.rootDir}/libs" + } + + */ + /* maven { name "githubBlablacar" url "https://maven.pkg.github.com/blablacar/java-packages" credentials(PasswordCredentials) } + */ } } tasks.withType(AbstractPublishToMaven) { + + doLast { def name = "${publication.groupId}:${publication.artifactId}:${publication.version}" if (it instanceof PublishToMavenRepository) { diff --git a/updatePlugins.xml b/updatePlugins.xml new file mode 100644 index 0000000..70f8d2c --- /dev/null +++ b/updatePlugins.xml @@ -0,0 +1,28 @@ + + + + + + + + + + From 2959c7f8868c2191f89f98f1d877df5c05966e0d Mon Sep 17 00:00:00 2001 From: Yohan BITTAN Date: Fri, 6 Jan 2023 12:00:57 +0100 Subject: [PATCH 2/4] WIP --- gradle.properties | 3 ++- gradle/publish.gradle | 54 +++++++++++++++++++++++++++---------------- updatePlugins.xml | 2 +- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/gradle.properties b/gradle.properties index 244c4ae..48c43df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -37,7 +37,6 @@ 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 @@ -45,3 +44,5 @@ 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 fade2a5..4d3cfa1 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -1,8 +1,27 @@ +def xmlFile = layout.projectDirectory.file('updatePlugins.xml') +def xmlArtifact = artifacts.add('archives', xmlFile) { + type 'xml' +} + task letsgo(dependsOn: ['publish']) { doFirst { println 'Let\'s go template plugin !' - } + def text = 'Dear "$firstname $lastname",\nSo nice to meet you in <% print city %>.\nSee you in ${month},\n${signed}' + + def binding = [ + "plugin_url":TODO(), + "pluginVersion":pluginVersion, + "pluginSinceBuild":pluginSinceBuild, + "pluginUntilBuild":pluginUntilBuild + ] + + def engine = new groovy.text.SimpleTemplateEngine() + def template = engine.createTemplate(text).make(binding) + + def result = 'Dear "Sam Pullara",\nSo nice to meet you in San Francisco.\nSee you in December,\nGroovy-Dev' + println(result) + } } task sourcesJar(type: Jar) { @@ -14,25 +33,21 @@ artifacts { archives sourcesJar } - -def xmlFile = layout.projectDirectory.file('updatePlugins.xml') -println "gooo ${xmlFile}" -def xmlArtifact = artifacts.add('archives', xmlFile.get().asFile) { - type 'xml' -} - publishing { publications { + 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 = isReleaseBuild() ? pluginVersion : pluginVersion + generateSnapshotSuffix() from components.java - artifact xmlArtifact - pom { name = PROJECT_NAME description = PROJECT_DESCRIPTION @@ -58,19 +73,18 @@ publishing { } */ - /* - maven { - name "githubBlablacar" - url "https://maven.pkg.github.com/blablacar/java-packages" - credentials(PasswordCredentials) - } - */ + /* + maven { + name "githubBlablacar" + url "https://maven.pkg.github.com/blablacar/java-packages" + credentials(PasswordCredentials) + } + */ } } tasks.withType(AbstractPublishToMaven) { - doLast { def name = "${publication.groupId}:${publication.artifactId}:${publication.version}" if (it instanceof PublishToMavenRepository) { diff --git a/updatePlugins.xml b/updatePlugins.xml index 70f8d2c..70031ad 100644 --- a/updatePlugins.xml +++ b/updatePlugins.xml @@ -15,7 +15,7 @@ available at this repository. in the plugin.xml file. -->