Enable to setup a simple scala build

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

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.

Same error when I run :

$ gradle init --type scala-library
$ gradle

Please see the stacktrace in the gist

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’?

------------------------------------------------------------
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

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.

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

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

------------------------------------------------------------ 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

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

bug in Gradle

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)

goodbye gradle…

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

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

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

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

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

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