Hi!
Being a total beginner with gradle i wanted to create a standalone jar for a scala hello world project with gradle.
You can see what i tried here:
Maybe you can indicate what i did wrong and how i should proceed?
Thanks!
Hi!
Being a total beginner with gradle i wanted to create a standalone jar for a scala hello world project with gradle.
You can see what i tried here:
Maybe you can indicate what i did wrong and how i should proceed?
Thanks!
You haven’t declared a Scala library. See the Scala chapter in the Gradle User Guide, and the Scala samples in the full Gradle distribution.
Thanks for the hint!
When i add the scala library as a dependency like this:
apply plugin: 'gradle-one-jar'
apply plugin: 'scala'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.rholder:gradle-one-jar:1.0.3'
compile 'org.scala-lang:scala-library:2.9.1'
}
}
task awesomeFunJar(type: OneJar) {
mainClass = 'example.Hi'
}
I get this error message:
* What went wrong:
A problem occurred evaluating root project 'Hello'.
> No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (java.lang.Str
ing) values: [org.scala-lang:scala-library:2.9.1]
Possible solutions: module(java.lang.Object)
I dont really know what that means
That’s not the correct way to declare the Scala dependency (repo/dependency declaration needs to go outside ‘buildscript’). Have another look at the docs and samples.
that is really confusing for me as i tried to follow the instructions of the one-jar plugin correctly:
There the dependencies are also inside a “buildscript” .
still, when i remove it like this:
apply plugin: 'gradle-one-jar'
apply plugin: 'scala'
repositories {
maven {
mavenCentral()
}
}
dependencies {
compile 'com.github.rholder:gradle-one-jar:1.0.3'
compile 'org.scala-lang:scala-library:2.9.1'
}
task awesomeFunJar(type: OneJar) {
mainClass = 'example.Hi'
}
i get this error:
* What went wrong:
A problem occurred evaluating root project 'Hello'.
> Plugin with id 'gradle-one-jar' not found.
You have to make a difference between the dependencies of the build and the dependencies of your code. The former go inside ‘buildscript’, the latter go outside. Hence:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.rholder:gradle-one-jar:1.0.3'
}
}
apply plugin: 'gradle-one-jar'
apply plugin: 'scala'
repositories {
mavenCentral()
}
dependencies {
compile 'org.scala-lang:scala-library:2.9.1'
}
task awesomeFunJar(type: OneJar) {
mainClass = 'example.Hi'
}
Excellent, that worked! Thanks a lot!