Copy file from one project into another


(Sean Van Buggenum) #1

Hi all,

I have a multi-project build.

Structured so:

root:

:API

:mainApp

The mainApp depends on the API, and both of these projects are obfuscated.

The obfuscation of mainApp depends on output from the obfuscation of the API ( a Change-log file).

How do I copy that file from API project build, into the mainApp ?

i.e., at the moment, I was trying something like this

File apiZelixDir = new File(Project[':api'].buildDir, "unobfuscated-classes-extra")
  println "The api zelix dir was found to be: " + apiZelixDir.getAbsolutePath()
    copy {
   from new File(apiZelixDir, "APIChangeLog.txt")
   into "$buildDir/unobfuscated-classes-extra"
  }

I couldn’t really find a concrete example of “Project[’:api’]” … but I thought it looks like it might work :wink:

But it didn’t.

The API project is of course also mentioned in the dependencies block of the mainApp project, like this:

compile project(':api').sourceSets.test.compileClasspath
 // the unobfuscated class files

how should I best do this?

thanks in advance

sean


(Luke Daley) #2

It should be ‘project(’:api’).buildDir’.


(Sean Van Buggenum) #3

Great! Thanks! That worked (of course)