Enable to setup a simple scala build


(Philippe Jean) #1

Hi,

I’m using sala 1.10 and I’m unable to setup a scala build thanks to the scala plugin. The line

apply plugin: 'scala'

generates an exception : Could not create task of type ‘ScalaDoc’

I’m a newbie with gradle. Can someone help me ?

Thanks


(Peter Niederwieser) #2

Can you provide a reproducible example? Meanwhile, you can study the Scala chapter in the Gradle User Guide, check out the Scala sample builds in the full Gradle distribution, or use ‘gradle init --type scala-library’ to create a working skeleton for a Scala build.


(Philippe Jean) #3

Same error when I run :

$ gradle init --type scala-library
$ gradle

Please see the stacktrace in the gist


(Peter Niederwieser) #4

I can’t reproduce this, and I wonder if it’s at all related to Gradle’s Scala support. (Can you verify this?) My best guess is that your JDK installation isn’t clean (e.g. you have some libs in ‘jre/lib’) or your Gradle installation is corrupted. Can you show the output of ‘gradle -v’?


(Philippe Jean) #5
------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------
  Build time:
 2013-12-17 09:28:15 UTC
Build number: none
Revision:
   36ced393628875ff15575fa03d16c1349ffe8bb6
  Groovy:
     1.8.6
Ant:
        Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:
        2.2.0
JVM:
        1.8.0-ea (Oracle Corporation 25.0-b60)
OS:
         Mac OS X 10.9.1 x86_64

(Peter Niederwieser) #6

Perhaps your Scala version isn’t compatible with Java 1.8 (I’m not sure if any released Scala version is). Can you try if running Gradle with JDK 1.7 solves the problem?

If this also happens when using, say, the Java plugin, rather than the Scala plugin, then it might be a problem with Gradle and Java 8, and a reproducible example would be appreciated.


(Philippe Jean) #7

I set up my JAVA_HOME to use 1.7 and it works fine.

Thanks for your help

UPDATE : Gradle and Java plugin works fine with Java 8


(Flaviu Tamas) #8

This may be a bug in Java 8. getPropertyType() allows for returning null and it is called in the parameter list of isAssignableFrom(), which does not allow for nulls. Relevent code:

if (isAssignable(gpd.getPropertyType() /* Can return null */, pd.getPropertyType() /* Can return null */)) {
 ...
private static boolean isAssignable(Class<?> current, Class<?> candidate) {
    return current == null ? candidate == null : current.isAssignableFrom(/* Can't be null */candidate);
}

Relevent breaking patch to the JDK: http://hg.openjdk.java.net/hsx/hotspot-rt/jdk/rev/29f979efbabf


(vvpvvp20) #9

------------------------------------------------------------ Gradle 1.10 ------------------------------------------------------------

Build time:

2013-12-17 09:28:15 UTC Build number: none Revision:

36ced393628875ff15575fa03d16c1349ffe8bb6

Groovy:

1.8.6 Ant:

Apache Ant™ version 1.9.2 compiled on July 8 2013 Ivy:

2.2.0 JVM:

1.7.0_45 (Oracle Corporation 24.45-b08) OS:

Mac OS X 10.9.1 x86_64


(vvpvvp20) #10

generates an exception : Could not create task of type ‘ScalaDoc’


(vvpvvp20) #11

bug in Gradle


(Mikael Ståldal) #12

I get the same error with Gradle 1.10 and the latest Java 8 RC. I don’t get the error with Java 7. And I don’t have any issues with running Scala itself on Java 8 RC.

So it seems like Gradle 1.10 (or the Scala plugin of Gradle 1.10) is incompatible with the latest Java 8 RC.

java version “1.8.0” Java™ SE Runtime Environment (build 1.8.0-b129) Java HotSpot™ Server VM (build 25.0-b69, mixed mode)

------------------------------------------------------------ Gradle 1.10 ------------------------------------------------------------

Build time:

2013-12-17 09:28:15 UTC Build number: none Revision:

36ced393628875ff15575fa03d16c1349ffe8bb6

Groovy:

1.8.6 Ant:

Apache Ant™ version 1.9.2 compiled on July 8 2013 Ivy:

2.2.0 JVM:

1.8.0 (Oracle Corporation 25.0-b69) OS:

Linux 3.2.0-58-generic-pae i386

java.lang.NullPointerException

at org.gradle.api.DefaultTask.(DefaultTask.java:33)

at org.gradle.api.internal.ConventionTask.(ConventionTask.java:28)

at org.gradle.api.tasks.SourceTask.(SourceTask.java:36)

at org.gradle.api.tasks.scala.ScalaDoc.(ScalaDoc.java:28)

at org.gradle.api.tasks.scala.ScalaDoc_Decorated.(Unknown Source)

at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:62)

at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)

at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:124)


(vvpvvp20) #13

goodbye gradle…


(Jong Wook Kim) #14

Well I had to downgrade to Java 7. Basically my fault to use a beta software but I hope gradle to fix this shortly.


(david koch) #15

I have the same issue with java version “1.8.0_05”, scala-2.10.3 and gradle-1.11


(Stevo Slavić) #16

Issue is still there, gradle-1.12, scala 2.10.4, jdk 1.8.0_05


(Peter Niederwieser) #17

Try with 2.0 nightly. 2.0 will be the first Gradle version that officially supports to be run with Java 8.


(Stevo Slavić) #18

Just tried both 2.0 and 2.1 snapshots (gradle-2.0-20140515233139+0000 and gradle-2.1-20140526220021+0000) - neither worked.


(Peter Niederwieser) #19

Thanks. We’ll try to fix it for 2.0.