Hi guys, I’d like to use gradle to install a library into the a local maven repository other than the one specified in maven’s settings.xml. The location of this repository is defined in a system variable called M2_REPO. Changing the settings.xml is not an option, so it needs to be done from gradle only. So far i’ve come up with:
apply plugin: 'java'
apply plugin: 'maven'
group = 'gtest'
version = '1.0'
sourceCompatibility = '1.6'
log4jV='1.2.16'
m2_repo = System.getenv()['M2_REPO']
dependencies {
compile "log4j:log4j:$log4jV"
}
repositories {
mavenRepo urls: "file://" + m2_repo
mavenCentral()
}
uploadArchives.repositories.mavenDeployer {
repository(url: "file://" + m2_repo)
}
task wrapper(type: Wrapper) {
gradleVersion = '0.9.2'
}
and get the following output:
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:uploadArchives
Uploading: gtest/gtest/1.0/gtest-1.0.jar to repository remote at file:///home/user/test-repo
Transferring 1K from remote
Uploaded 1K
BUILD SUCCESSFUL
Total time: 3.294 secs
So in principal it works. But unfortunately the library is not only installed in M2_REPO but also in /home/user/.m2/repository. Is there any way to prevent uploadArchives from doing this? Or any way to use the install task to do this? Either way is fine.
I’m currently using gradle 0.9.2 but it does the same with 1.0, and if i need to use 1.0 to get this to work, i won’t mind either.
Thanks in advance,
Myke