@@ -17,6 +17,11 @@ props.load(new FileInputStream("$projectDir/all-modules.properties"))
1717project. ext. allModuleNames = props[' modules.common.all' ]
1818project. ext. modulesDistsDir = file(" ${ project.buildDir} /modulesZip" )
1919
20+ // Jenkins sets BUILD_NUMBER incrementally. It can be overridden in the command line
21+ // (E.g.: ./gradlew -Pbuild_number=127 info). If not provided, it gets a default 'manual'
22+ String buildNumber = project. hasProperty(' build_number' ) ? build_number
23+ : (System . env[" BUILD_NUMBER" ] ?: ' manual' )
24+
2025repositories {
2126 mavenLocal()
2227 if (project. hasProperty(' additional_repositories' )){
@@ -338,12 +343,78 @@ install {
338343 }
339344}
340345
346+ // Configure zip artifacts for publishing
347+ if (project. hasProperty(' publish_repository' )) {
348+ // Add all distributables modules
349+ artifacts {
350+ tasks. findAll { task -> task. name. startsWith(' dist_' ) }. each { distTask ->
351+ archives distTask
352+ }
353+ }
354+
355+ uploadArchives {
356+ repositories {
357+ mavenDeployer {
358+ repository(url : publish_repository) {
359+ authentication(userName : publish_user, password : publish_password)
360+ }
361+ tasks. findAll { task -> task. name. startsWith(' dist_' ) }. each { distTask ->
362+ // E.g. distTask ":dist_org.opencms.apollo.template.core"
363+ // distTask.baseName = "org.opencms.apollo.template.core"
364+ String filterName = distTask. baseName
365+ addFilter(filterName) { artifact , file ->
366+ // E.g. artifact:
367+ // artifact.name = "org.opencms.apollo.template.core"
368+ // artifact.ext = "zip"
369+ // artifact.type = "zip"
370+ artifact. name == filterName
371+ }
372+ pom(filterName). project {
373+ name " The OpenCms Apollo Template - $filterName "
374+ version = " ${ distTask.version} .${ buildNumber} "
375+ description " The OpenCms Apollo Template - $filterName "
376+ packaging ' zip'
377+ groupId ' org.opencms'
378+ url ' http://www.alkacon.com'
379+ scm {
380+ url ' scm:git@github.com:alkacon/apollo-template.git'
381+ connection ' scm:git@github.com:alkacon/apollo-template.git'
382+ developerConnection ' scm:git@github.com:alkacon/apollo-template.git'
383+ }
384+ licenses {
385+ license {
386+ name ' GNU General Public License'
387+ url ' http://www.gnu.org/licenses/gpl.html'
388+ distribution ' repo'
389+ }
390+ }
391+ organization {
392+ name ' Alkacon Software'
393+ url ' http://www.alkacon.com'
394+ }
395+ developers {
396+ developer {
397+ name ' Alkacon Software'
398+ url ' http://www.alkacon.com'
399+ }
400+ }
401+ }
402+ }
403+ }
404+ }
405+ }
406+ }
407+
341408// Configure versioning for jar artifacts
342409tasks. findAll { task -> task. name. startsWith(' jar_org.opencms.' ) }. each { jarTask ->
343410 String filterName = jarTask. baseName
411+ def uploaders = [install. repositories. mavenInstaller]
412+ if (project. hasProperty(' publish_repository' )) {
413+ uploaders << uploadArchives. repositories. mavenDeployer
414+ }
344415
345- install . repositories . mavenInstaller . pom(filterName)* . project {
346- version = jarTask. moduleVersion
416+ uploaders * . pom(filterName)* . project {
417+ version = " ${ jarTask.moduleVersion} . ${ buildNumber } "
347418 }
348419}
349420
0 commit comments