Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find org.scoverage.ScoverageReport #13

Closed
fsarradin opened this issue Aug 27, 2014 · 12 comments
Closed

Unable to find org.scoverage.ScoverageReport #13

fsarradin opened this issue Aug 27, 2014 · 12 comments

Comments

@fsarradin
Copy link

Hi,

With the configuration displayed in the README.md file at the root of the project, gradle says that it is unable to find or load the main class org.scoverage.ScoverageReport. By launching gradle with --debug option, it says:

Starting process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/java''.
Working directory: /Users/fsarradin/ks-framework/kff-coresetup
Command: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -cp /Users/fsarradin/.gradle/caches/modules-2/files-2.1/org.scoverage/scalac-scoverage-plugin_2.11/0.99.5/ee02c604b73c8b6cca7c345a2fd419531da47d08/scalac-scoverage-plugin_2.11-0.99.5.jar:/Users/fsarradin/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.11.0/aa8f7553253318c468f90ce58a85f94bd1a224eb/scala-library-2.11.0.jar:/Users/fsarradin/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.4/b1b6ea3b7e4aa4f492509a4952029cd8e48019ad/commons-io-2.4.jar:/Users/fsarradin/.gradle/caches/modules-2/files-2.1/org.scala-lang.modules/scala-xml_2.11/1.0.1/21dbac0088b91b8ffb7ac385301f4340f8ebe71f/scala-xml_2.11-1.0.1.jar org.scoverage.ScoverageReport /Users/fsarradin/ks-framework/kff-coresetup/src/main/scala /Users/fsarradin/ks-framework/kff-coresetup/build/scoverage /Users/fsarradin/ks-framework/kff-coresetup/build/reports/scoverage

So gradle-scoverage does not appear in the classpath. But I don't how to do it? Any idea?

I'm using gradle 2.0.

regards

@fsarradin
Copy link
Author

From my own investigation, the gradle plugin is looking for org.scoverage.ScoverageReport (https://github.com/scoverage/gradle-scoverage/blob/master/src/main/groovy/org/scoverage/ScoverageExtension.groovy#L107). But scalac-scoverage-plugin only has scoverage.ScoverageReport.

@mohnishkodnani
Copy link

I see the same issue with gradle 1.12 as well.
12:57:00.655 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
12:57:00.657 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command '/usr/lib/jvm/java-7-oracle/bin/java'.
12:57:00.663 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
12:57:00.663 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
12:57:00.663 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command '/usr/lib/jvm/java-7-oracle/bin/java''
12:57:00.736 [ERROR] [system.err] Error: Could not find or load main class org.scoverage.ScoverageReport
12:57:00.740 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
12:57:00.741 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with exit value 1 (state: FAILED)
12:57:00.742 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':web-service:reportScoverage'
12:57:00.742 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :web-service:reportScoverage FAILED

@avdv
Copy link

avdv commented Dec 23, 2014

org.scoverage.ScoverageReport is contained in the gradle-scoverage plugin itself, not in the scalac-scoverage-plugin.

Seems maiflai addressed this issue in commit 6686446 yesterday.

For the time being, until a new version is released, adding the following to your gradle build file solves this problem too:

reportScoverage {
  dependencies {
    scoverage 'org.scoverage:gradle-scoverage:0.6-SNAPSHOT'
  }
}

@maiflai
Copy link
Contributor

maiflai commented Dec 23, 2014

Release 1.0 has now been published to maven central - please note that this requires you to update to scoverage 1.0.1.

Please could you let me know if this issue can be closed?

Thanks,
Stu

@avdv
Copy link

avdv commented Jan 7, 2015

I just tested with gradle-scoverage 1.0.6 and scoverage 1.0.1 and 1.0.2. But the error is still there. I guess I misinterpreted what 6686446 was meant to do.

Note, that I also tried Release 1.0 as you suggested, but it seems that was build with java 8 and I only have jdk 7.

Looking at

classpath = project.buildscript.configurations.classpath + configuration
it seems that it should work, but printing the value of project.buildscript.configurations.classpath shows up empty. And consequently, the gradle-scoverage jar is missing from reportScoverage.classpath.

The discussion here (http://forums.gradle.org/gradle/topics/share_classpath_between_buildscript_and_project_configuration) seems to suggest that accessing the classpath configuration of the buildscript is not possible.

@maiflai
Copy link
Contributor

maiflai commented Jan 7, 2015

Hi - thanks for reporting back - we've since released 1.0.6 which supports jdk 7, but I agree that I can reproduce an error here.

It appears to work correctly with a simple project, but please could I check that you have a multi-module project? It would also be helpful if you could share your build configuration.

I agree with your workaround (as listed above) in the meantime. An alternative is to 'accidentally' configure the buildscript in your subprojects - perhaps you have a code-free parent project?

Thanks again,
Stu.

@avdv
Copy link

avdv commented Jan 8, 2015

Yes, I do have a multi-module project, but my parent project does have code. And btw, I'm using Gradle 2.2.1.

In my rootProject I'm using

apply from: "gradle/scoverage.gradle"

where the scoverage.gradle file contains the code from the "Gettting started" section of README.md.

When I include the code directly in my build.gradle file, it works fine. Is this a limitation of Gradle's apply mechanism, or a feature?

@maiflai
Copy link
Contributor

maiflai commented Jan 8, 2015

That's interesting - are you applying this to allprojects, subprojects, or configuring individual projects?

@avdv
Copy link

avdv commented Jan 9, 2015

I'm only configuring scoverage for the root project, the single subproject is not configured for scoverage yet.

When I try to do it for all projects:

// root project

allprojects {
  buildscript {
    repositories {
      mavenCentral()
      maven { url "https://oss.sonatype.org/content/groups/public" }
    }
    dependencies {
      classpath 'org.scoverage:gradle-scoverage:1.0.6'
    }
  }
  apply plugin: org.scoverage.ScoveragePlugin
}

I get this error:

A problem occurred evaluating root project 'root'.
> Cannot change configuration ':classpath' after it has been resolved.

Which is OK, since the buildscripts have already been processed when the allprojects call is seen in the second phase of Gradle's build evaluation.

Then, I tried:

// root project
buildscript {
  repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/groups/public" }
  }
  dependencies {
    classpath 'org.scoverage:gradle-scoverage:1.0.6'
  }
}

allprojects {
  apply plugin: org.scoverage.ScoveragePlugin

  dependencies {
    scoverage 'org.scoverage:scalac-scoverage-plugin_2.11:1.0.2', 'org.scoverage:scalac-scoverage-runtime_2.11:1.0.2'
  }
}

Which yields this error in the subproject again:

Error: Could not find or load main class org.scoverage.ScoverageReport

@avdv
Copy link

avdv commented Jan 9, 2015

Just looked through the gradle forums and I found this discussion: http://forums.gradle.org/gradle/topics/understanding_the_additivity_of_the_buildscript_dependencies

The buildscript block has to be in the "main" build script, not the applied one. It's a known limitation.

So, the second script I posted above is the way to go, too bad it doesn't work for the subprojects.

\edit: Here's another piece of the puzzle: http://forums.gradle.org/gradle/topics/how_to_refer_to_classes_on_the_buildscript_classpath_in_an_applied_script

Officially, each build script needs to declare its build script dependencies on its own. In the current implementation, a child build script can also see the parent script's dependencies, but this isn't the case for applied build scripts.

@maiflai
Copy link
Contributor

maiflai commented Feb 8, 2015

I've published version 1.0.8, which I hope addresses this issue.

Please could you upgrade and remove the workaround (if you used one) to test it?

@avdv
Copy link

avdv commented Feb 11, 2015

Yes, works for me without having any workaround code in my build. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants