How do we focus on androidTest on a peer-to-peer project?

I am helping the Guardian project on NetCipher . For obsolete reasons, they want to keep the existing project structure based on Eclipse. However, instead of having tests in the tests/ library subdirectory, they came with a peer-to-peer design model. Thus, from the root of the libnetcipher/ repo root is the library, and netciphertest/ is the control tests.

Instrument tests have never been configured to build Gradle, unlike libnetcipher/ . So, I am adding stuff to the libnetcipher/build.gradle file so that it points its androidTest sourceset to the netciphertest/ directory, and not to its normal location.

It works:

  androidTest { manifest.srcFile '../netciphertest/AndroidManifest.xml' java.srcDirs = ['../netciphertest/src'] resources.srcDirs = ['../netciphertest/src'] aidl.srcDirs = ['../netciphertest/src'] renderscript.srcDirs = ['../netciphertest/src'] res.srcDirs = ['../netciphertest/res'] assets.srcDirs = ['../netciphertest/assets'] } 

However, the repeated bits of ../netciphertest are fuzzy. I could define this as a constant to minimize duplication, of course. I am trying to find out if there is a better approach to the whole problem.

For example, this does not work:

  androidTest.setRoot('../netciphertest') androidTest { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } 

I thought that perhaps the material srcDirs and srcFile could be interpreted with respect to the value of setRoot() , but they seem to be interpreted with respect to the native root of the project.

Is there a more elegant solution than mine?

+7
android android-gradle gradle
source share
1 answer

Reading the Gradle documentation, I couldn't find anything about the relative absolute paths for srcDirs , but it seems that if you just give src it will read ./src regardless of the root that was set. Perhaps it could be a request to the Gradle function, or it might work as expected in later versions of Gradle? Not sure, did not look at her.

If you think that you do not need aidl , renderscripts or resources (since they are not displayed in the project), is this less "bad"?

 androidTest { setRoot '../netciphertest' java.srcDirs = ['../netciphertest/src'] } 

All others will be automatically configured this way if you do not override them and set the root.

 androidTest.manifest.srcFile = /NetCipher/netciphertest/AndroidManifest.xml androidTest.res.srcDirs = [/NetCipher/netciphertest/res] androidTest.assets.srcDirs = [/NetCipher/netciphertest/assets] // Override these, if you wish androidTest.resources.srcDirs = [/NetCipher/netciphertest/resources] androidTest.aidl.srcDirs = [/NetCipher/netciphertest/aidl] androidTest.renderscript.srcDirs = [/NetCipher/netciphertest/rs] 

You can print the paths in Gradle and play with it more if you like by including this section in the sourceSets block.

 println "androidTest.manifest.srcFile = ${androidTest.manifest.srcFile}" println "androidTest.java.srcDirs = ${androidTest.java.srcDirs}" println "androidTest.resources.srcDirs = ${androidTest.resources.srcDirs}" println "androidTest.aidl.srcDirs = ${androidTest.aidl.srcDirs}" println "androidTest.renderscript.srcDirs = ${androidTest.renderscript.srcDirs}" println "androidTest.res.srcDirs = ${androidTest.res.srcDirs}" println "androidTest.assets.srcDirs = ${androidTest.assets.srcDirs}" 
+5
source share

All Articles