Gradle, create and copy javadoc jars from multiple dependencies -


i have following project structure:

  • project 1
  • project 2 depends on project 1
  • project 3 depends on project 1

(there external dependencies)

i create source jars , javadoc jars with

task sourcesjar(type: jar) {     destinationdir = file("./../../build/export/$project.name")     classifier 'sources'     sourcesets.main.allsource }  task javadocjar(type: jar, dependson: javadoc) {     destinationdir = file("./../../build/export/$project.name")     classifier 'javadoc'     javadoc.destinationdir }  artifacts {     archives sourcesjar     archives javadocjar } 

now need create folder contains jar file of project , jar files of dependencies. current version is

task makelibsdir(type: copy, dependson: ['jar', 'sourcesjar', 'javadocjar']) {    description 'builds relevant jar files use project dependency , copies them libs folder'     jar // copying jar configuration     file outdir = file("./../../build/$project.name/libs/")    outdir.mkdirs()    outdir     into('/') {           configurations.runtime   } } 

when call project2:makelibsdir folder contains

project1.jar project2.jar extdept1.jar ...

but there 2 problems

  • sources jar , javadoc jar project1 not build
  • sources jar , javadoch jar project2 build, not copied libs folder

any idea how can

  1. ensure jars dependent projects build
  2. copy them final location

edit: minimized version of full build.gradle

builddir = "../build/$project.name"  subprojects { apply plugin: 'java' apply plugin: 'application' apply plugin: 'eclipse'  repositories {     mavencentral() }  sourcesets {        ....          }  jar {      destinationdir = file("./../../build/export/$project.name")        destinationdir.mkdirs()      basename = project.name             }     task makelibsdir(type: copy, dependson: ['jar', 'sourcesjar', 'javadocjar']) {        jar        file outdir = file("./../../build/$project.name/libs/")       outdir.mkdirs()       outdir        into('/') {              configurations.runtime      }    }     task sourcesjar(type: jar) {           destinationdir = file("./../../build/export/$project.name")        classifier 'sources'        sourcesets.main.allsource    }     task javadocjar(type: jar, dependson: javadoc) {       destinationdir = file("./../../build/export/$project.name")       classifier 'javadoc'       javadoc.destinationdir    }     artifacts {        archives sourcesjar        archives javadocjar    }        project(':project1') {         dependencies {           ...         }       }        project(':project2') {         dependencies {             ...             compile project(':project1')           }       }        project(':project2') {         dependencies {               ...               compile project(':project1')           }       }  } 


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -