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

Plugin 1.58 is incompatible with Spotbugs #18

Closed
ccrvincent opened this issue Aug 21, 2019 · 9 comments
Closed

Plugin 1.58 is incompatible with Spotbugs #18

ccrvincent opened this issue Aug 21, 2019 · 9 comments

Comments

@ccrvincent
Copy link
Contributor

Our project uses both Spotbugs and the Changelog plugin.

Using Spotbugs 3.1.12 and the Spotbugs Gradle plugin 1.7.1 or 2.0.0 with the Changelog plugin 1.55-1.57 works fine.

Changelog plugin 1.58, 1.59, and 1.64 each appear to cause the Spotbugs worker thread to exit with an error code.

Unfortunately, the Spotbugs Worker does not return any logging or usable errors, so I am unsure what the root cause could be.

@tomasbjerre
Copy link
Owner

Can you repeat that in an open project? And provide a link to that.

@tomasbjerre
Copy link
Owner

no response, closing

@ccrvincent
Copy link
Contributor Author

This was found when trying to get dependencies updated in a project with an urgent release. I just haven't had time yet, please re-open.

@tomasbjerre tomasbjerre reopened this Sep 8, 2019
@ccrvincent
Copy link
Contributor Author

ccrvincent commented Sep 9, 2019

Sorry about the nested folder, I just slapped this together quickly...

Based on the Gradle template, just added Spotbugs and Changelog Plugin. With Changelog Plugin enabled (including 1.57 in this case), Spotbugs fails to launch. With Changelog Plugin commented out, Spotbugs returns an error and fails to launch.

https://github.com/ccrvincent/changelog-spotbugs/tree/master/changelog-spotbugs

* What went wrong:
Execution failed for task ':spotbugsMain'.
> Failed to run Gradle SpotBugs Worker
   > Could not create an instance of type com.github.spotbugs.internal.spotbugs.SpotBugsExecutor.
      > 'com.google.common.collect.ImmutableList$Builder com.google.common.collect.ImmutableList.builderWithExpectedSize(int)'

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':spotbugsMain'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.accept(ExecuteActionsTaskExecuter.java:121)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.accept(ExecuteActionsTaskExecuter.java:117)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:184)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ResolveIncrementalChangesTaskExecuter.execute(ResolveIncrementalChangesTaskExecuter.java:84)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
        at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:63)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:46)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.process.internal.worker.WorkerProcessException: Failed to run Gradle SpotBugs Worker
        at org.gradle.process.internal.worker.WorkerProcessException.runFailed(WorkerProcessException.java:29)
        at org.gradle.process.internal.worker.request.Receiver.infrastructureFailed(Receiver.java:88)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
        ... 3 more
Caused by: org.gradle.api.reflect.ObjectInstantiationException: Could not create an instance of type com.github.spotbugs.internal.spotbugs.SpotBugsExecutor.
        at org.gradle.internal.instantiation.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:53)
        at org.gradle.process.internal.worker.request.WorkerAction.execute(WorkerAction.java:61)
        at org.gradle.process.internal.worker.request.WorkerAction.execute(WorkerAction.java:40)
        at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:93)
        at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:36)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:125)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:68)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:62)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:67)
Caused by: java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableList$Builder com.google.common.collect.ImmutableList.builderWithExpectedSize(int)'
        at org.gradle.internal.instantiation.AbstractClassGenerator$AbstractInjectedPropertyHandler.getInjectedServices(AbstractClassGenerator.java:1080)
        at org.gradle.internal.instantiation.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:197)
        at org.gradle.internal.instantiation.AbstractClassGenerator.generate(AbstractClassGenerator.java:106)
        at org.gradle.internal.instantiation.AsmBackedClassGenerator.generate(AsmBackedClassGenerator.java:105)
        at org.gradle.internal.instantiation.Jsr330ConstructorSelector$1.transform(Jsr330ConstructorSelector.java:59)
        at org.gradle.internal.instantiation.Jsr330ConstructorSelector$1.transform(Jsr330ConstructorSelector.java:54)
        at org.gradle.cache.internal.DefaultCrossBuildInMemoryCacheFactory$DefaultCrossBuildInMemoryCache.get(DefaultCrossBuildInMemoryCacheFactory.java:121)
        at org.gradle.internal.instantiation.Jsr330ConstructorSelector.forType(Jsr330ConstructorSelector.java:54)
        at org.gradle.internal.instantiation.Jsr330ConstructorSelector.forParams(Jsr330ConstructorSelector.java:49)
        at org.gradle.internal.instantiation.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:45)
        ... 8 more

@tomasbjerre
Copy link
Owner

You added it twice:
https://github.com/ccrvincent/changelog-spotbugs/blob/master/changelog-spotbugs/build.gradle#L15
and:
https://github.com/ccrvincent/changelog-spotbugs/blob/master/changelog-spotbugs/build.gradle#L24

And you should probably use the plugin DSL way of doing things:

plugins {
  id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "1.64"
}

That way, the plugins don't share classpath and you dont get this kind of error.

@ccrvincent
Copy link
Contributor Author

ccrvincent commented Sep 9, 2019

Ah, so I did. I started from scratch rather than use the project from work to be sure it wasn't something odd in the project setup and made something odd instead.

Removed the old style dependency statement on L15, bug persists.

Based on the stacktrace, I was expecting gradlew dependencies to show a difference in the Guava version used by Spotbugs, but with the changelog plugin enabled or commented out the dependencies output is identical.

@tomasbjerre
Copy link
Owner

I can see it also now.

Perhaps it is SLF4J: spotbugs/spotbugs-gradle-plugin#11

Would be nice to shaddow the dependencies and package a fat jar of git-changelog-lib but I have been experiencing strange behavior of JGit when doing that.

@ccrvincent
Copy link
Contributor Author

Could be, though that was supposed to be fixed in Spotbugs Plugin 1.6.5, and this is reproducible using both 1.7.1 and 2.0.0.

@tomasbjerre
Copy link
Owner

This works for me:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath("com.google.guava:guava:27.0.1-jre")
    classpath("gradle.plugin.se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.64") {
      exclude group:"org.slf4j"
      exclude group:"com.google.guava"
    }
  }
}

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java'
    id 'com.github.spotbugs' version '1.7.1'
}

apply plugin: "se.bjurr.gitchangelog.git-changelog-gradle-plugin"

repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

spotbugs {
  toolVersion = '3.1.12'
}

dependencies {
    implementation 'org.apache.commons:commons-math3:3.6.1'
    implementation 'com.google.guava:guava:27.0.1-jre'

    testImplementation 'junit:junit:4.12'
}

task gitChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
 file = new File("CHANGELOG.md");
 templateContent = """
Changelog of Bug18Sample.

{{#tags}}
## {{name}}
 {{#issues}}
  {{#hasIssue}}
   {{#hasLink}}
### {{name}} [{{issue}}]({{link}}) {{title}} {{#hasIssueType}} *{{issueType}}* {{/hasIssueType}} {{#hasLabels}} {{#labels}} *{{.}}* {{/labels}} {{/hasLabels}}
   {{/hasLink}}
   {{^hasLink}}
### {{name}} {{issue}} {{title}} {{#hasIssueType}} *{{issueType}}* {{/hasIssueType}} {{#hasLabels}} {{#labels}} *{{.}}* {{/labels}} {{/hasLabels}}
   {{/hasLink}}
  {{/hasIssue}}
  {{^hasIssue}}
### {{name}}
  {{/hasIssue}}

  {{#commits}}
**{{{messageTitle}}}**

{{#messageBodyItems}}
 * {{.}}
{{/messageBodyItems}}

[{{hash}}](https://github.com/{{ownerName}}/{{repoName}}/commit/{{hash}}) {{authorName}} *{{commitTime}}*

  {{/commits}}

 {{/issues}}
{{/tags}}
 """;
}

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

2 participants