Hello,
I am trying to migrate gradle from version 1.0-milestone-1 to 1.0-milestone-7 however i am exeperiencing the following problem using classes in my maven dependencies…
The following script reproduce the problem :
apply plugin: 'java'
apply plugin: 'maven'
// Tache par defaut
// qui sera execute sans le parametre -q <nomTache>
defaultTasks 'main'
repositories {
// mavenCentral()
maven {
url "http://repository.XXXXX.fr:8081/nexus/content/groups/public/"
}
}
dependencies {
compile(group: 'commons-lang', name: 'commons-lang', version: '2.6')
compile(group: 'commons-io', name: 'commons-io', version: '2.0.1')
}
// import org.apache.commons.lang.SystemUtils;
// import org.apache.commons.lang.StringUtils;
task doTestResolve << {
configurations.compile.files.each { println "resolved dependency: $it" }
}
task doTestRetrieve(type: Copy) {
from configurations.compile
into "myDependencies"
eachFile {
println "retrieving dependency: $it.name"
}
}
task main << {
display("================================================================")
display("hello world....")
display("================================================================")
if (org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS == false)
{
display("OS linux...")
}
else
{
display("OS windows...")
}
}
private void display(String message)
{
ant.echo(message: message)
}
When running the script i have the following error :
[root@myServer /]# gradle -b test.gradle
:main
[ant:echo] ================================================================
[ant:echo] hello world....
[ant:echo] ================================================================
FAILURE: Build failed with an exception.
* Where:
Build file '/test.gradle' line: 41
* What went wrong:
Execution failed for task ':main'.
Cause: Could not find property 'org' on task ':main'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.954 secs
When running the script with the « doTestResolve » task, I can see that the maven dependencies are well downloaded :
[root@myServer /]# gradle -b test.gradle -q doTestResolve
resolved dependency: /root/.gradle/caches/artifacts-7/artifacts/4a100ce6d3ddaaebf915c9163900b580/commons-lang/commons-lang/2.6/jar/commons-lang-2.6.jar
resolved dependency: /root/.gradle/caches/artifacts-7/artifacts/4a100ce6d3ddaaebf915c9163900b580/commons-io/commons-io/2.0.1/jar/commons-io-2.0.1.jar
[root@myServer /]#
If I uncomment the line :
import org.apache.commons.lang.SystemUtils;
the following error occurs :
[root@myServer /]# gradle -b test.gradle
FAILURE: Build failed with an exception.
* Where:
Build file '/test.gradle' line: 21
* What went wrong:
Could not compile build file '/test.gradle'.
Cause: startup failed:
build file '/test.gradle': 21: unable to resolve class org.apache.commons.lang.SystemUtils
@ line 21, column 1.
import org.apache.commons.lang.SystemUtils;
^
1 error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.823 secs
Any idea ? Is it a problem with the classloader ? I would like to know how to resolve this problem.
Thanks a lot for you help. F.