Gradle with GPARS
Answered
hi,
Really, really new to gradle. i've the following build.gradle and i want to use gpars. in intellij i'm getting the following error. can you help please.
* What went wrong:
A problem occurred evaluating root project 'example.project'.
> Could not get unknown property 'GParsPool' for root project 'example.project' of type org.gradle.api.Project.
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
//add repositories for optional dependencies
// maven{url 'http://repository.jboss.org/maven2/'}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.codehaus.gpars', name: 'gpars', version: '1.2.1'
}
def sendEmails(numbers) {
GParsPool.withPool {
numbers.eachParallel { number ->
def wait = (long) new Random().nextDouble() * 1000
println "in closure " + number
this.sleep wait
}
}
}
task showDate{
sendEmails([1,2,3])
}
Please sign in to leave a comment.
You are missing a classpath dependency and an import:
Hi Serge.
I added the import and classpath. now i receive the following error.
* What went wrong:
Could not compile build file '/home/neo/IdeaProjects/example.project/build.gradle'.
> startup failed:
build file '/home/neo/IdeaProjects/example.project/build.gradle': 2: unable to resolve class groovyx.gpars.GParsPool
@ line 2, column 1.
import groovyx.gpars.GParsPool
Google for the proper configuration, you may need to add classpath inside buildscript element. The issue has no relation to IntelliJ IDEA, you will have the same problem with the command line Gradle. If you can't find the solution, try asking at http://stackoverflow.com/.
Appears the important part is the is indeed the buildscript portion.