From 2f116de05efc1fc28cfffcb7ad086b9164e05b7e Mon Sep 17 00:00:00 2001 From: Greg Bowering <526473+gb96@users.noreply.github.com> Date: Tue, 27 Mar 2018 13:53:42 +1030 Subject: [PATCH] build.gradle to publish both sources and javadoc Current gradle build only publishes compiled Java classes to maven repository. It helps java developers if sources and javadoc are also published as most Java IDEs can leverage those to provide better assistance (particularly during run-time debugging, static code analysis, and also for developers learning new api) --- .../templates/genjava_project/build.gradle.in | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/genjava/templates/genjava_project/build.gradle.in b/src/genjava/templates/genjava_project/build.gradle.in index 20681fb..920270a 100644 --- a/src/genjava/templates/genjava_project/build.gradle.in +++ b/src/genjava/templates/genjava_project/build.gradle.in @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 %(author)s + * Copyright (C) 2014, 2018 %(author)s * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -55,6 +55,30 @@ task generateSources (type: JavaExec) { tasks.compileJava.source outputs.files } +task docsJar(type: Jar, dependsOn: 'javadoc') { + description = 'Archive JavaDoc for %(project_name)s' + from javadoc.destinationDir + classifier = 'javadoc' +} + +task sourceJar(type: Jar, dependsOn: 'classes') { + description = 'Archive Source files for %(project_name)s' + from sourceSets.main.allSource + classifier = 'sources' +} + +publishing { + publications { + mavenJava(MavenPublication) { + // compiled classes jar is published to maven by default + // also publish -sources.jar + artifact sourceJar + // also publish -javadoc.jar + artifact docsJar + } + } +} + dependencies { compile 'org.ros.rosjava_bootstrap:message_generation:[0.2,0.3)' %(msg_dependencies)s