How to export dependencies to different locations with Gradle? -


i wanted avoid creating different configurations because have many different behaviors associated dependencies, not one.

so 'ext' properties able associate own data dependencies:

runtime 'org.apache.logging.log4j:log4j-api:2.5' runtime 'org.apache.lucene:lucene-core:5.4.1' runtime('hsqldb:hsqldb:1.8.0.10') { ext.exportto = 'jdbc' } 

now want exploit copy dependencies 'libs/' default, , 'libs/${exportto}/' if exportto specified.

task copyruntimelibs(type: copy) {   "build/dependencies"   configurations.runtime } 

so i'm trying create dynamically created configuration special dependencies, , dynamically created task job, link main task 'copyruntimelibs':

configurations.runtime.alldependencies.withtype(externalmoduledependency).each { d ->   if (d.hasproperty("exportto")) {     def key = "${d.group}:${d.name}:${d.version}"     def configname = "config-${key}"      def c = project.configurations.create(configname)     c.getdependencies().add(d)      def task = task "task-${key}"(type: copy) {       "build/dependencies/${d.ext.exportto}"       c     }     project.tasks.add(task)     copyruntimelibs.dependson task   } } 

so dynamic tasks executed, nothing copied. when add 'eachfiles' debug, doesn't go there.

any clue?

task copyruntimelibs  copyruntimelibs << {   configurations.runtime.alldependencies.withtype(externalmoduledependency).each { d ->     def exportfolder = 'build/dependencies'     def exportsub = ''     if (d.hasproperty("exportto")) {       exportsub = d.ext.exportto     }     def key = "${d.group}:${d.name}:${d.version}"     def c = project.configurations.create("config-${key}")     c.getdependencies().add(d)      copy {       c       "${exportfolder}/${exportsub}/"     }   } } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -