From 2840fea7516b57a602ca273c0db7e101b0afb552 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 2 Apr 2021 19:19:21 +0200 Subject: [PATCH] fix publish configuration publish is now possible with the tasks publishToMavenLocal and publishMavenJavaPublicationToMyRepoRepository --- build.gradle | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 17f71a9..51bfca8 100644 --- a/build.gradle +++ b/build.gradle @@ -45,28 +45,34 @@ subprojects { mavenCentral() jcenter() } - - uploadArchives { - repositories { - mavenDeployer { - if (!project.hasProperty('mavenDeployRepo')){ - throw new IllegalStateException("Set the property 'mavenDeployRepo' to the repository URL. A good place is ~/.gradle/gradle.properties") + + /** + * Publish the to a local repository. + * Use 'gradlew publishToMavenLocal' to publish to the local maven repo. + * If the property 'mavenDeployRepo' is set in gradle.properties, then you can use + * 'gradlew publishMavenJavaPublicationToMyRepoRepository' to publish to that repository. + */ + publishing { + if (project.hasProperty('mavenDeployRepo')){ + repositories { + maven { + name = "MyRepo" // optional target repository name + url = "${mavenDeployRepo}" } - repository(url: "${mavenDeployRepo}") - println "publishing to: ${mavenDeployRepo}" } } + publications { + mavenJava(MavenPublication) { + from components.java + } + } } - task sourcesJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource + java { + withSourcesJar() } - artifacts { - archives sourcesJar - } // dependencies that all sub-projects have dependencies {