hierynomus / license-gradle-plugin

Manage your license(s)
http://www.javadude.nl
Other
409 stars 114 forks source link

Spring Boot projects fail to build when Gradle License Plugin is applied #161

Open drewwills opened 6 years ago

drewwills commented 6 years ago

I have encountered this issue in a couple of Spring Boot projects.

Here is how I'm applying the plugin...

+++ b/build.gradle
@@ -1,16 +1,26 @@
+plugins {
+    id "com.github.hierynomus.license" version "0.14.0"
+}
+
 description = "Form Builder Microservice (FBMS) for the uPortal ecosystem, by Apereo"

 subprojects {

-    // Adds the 'install' task
-    apply plugin: 'maven'
+    apply plugin: 'license' // Use licenseFormatMain and licenseFormatTest tasks
+    apply plugin: 'maven'   // Adds the 'install' task

     repositories {
         mavenCentral()
         mavenLocal()
     }

+    license {
+        header = rootProject.file('docs/short-license-header.txt')
+        strictCheck = true
+        mapping {
+            java = 'SLASHSTAR_STYLE'
+        }
+        exclude "**/*.json"
+    }
+
 }

And here is the error I receive...

FAILURE: Build failed with an exception.

* What went wrong:
org.springframework.asm.Type.getMethodType(Lorg/springframework/asm/Type;[Lorg/springframework/asm/Type;)Lorg/springframework/asm/Type;

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

* Exception is:
java.lang.NoSuchMethodError: org.springframework.asm.Type.getMethodType(Lorg/springframework/asm/Type;[Lorg/springframework/asm/Type;)Lorg/springframework/asm/Type;
        at org.springframework.boot.loader.tools.MainClassFinder.<clinit>(MainClassFinder.java:60)
        at org.springframework.boot.gradle.plugin.MainClassConvention.findMainClass(MainClassConvention.java:76)
        at org.springframework.boot.gradle.plugin.MainClassConvention.resolveMainClass(MainClassConvention.java:69)
        at org.springframework.boot.gradle.plugin.MainClassConvention.call(MainClassConvention.java:64)
        at org.gradle.util.GUtil.uncheckedCall(GUtil.java:458)
        at org.gradle.api.internal.ConventionAwareHelper$2.doGetValue(ConventionAwareHelper.java:82)
        at org.gradle.api.internal.ConventionAwareHelper$MappedPropertyImpl.getValue(ConventionAwareHelper.java:126)
        at org.gradle.api.internal.ConventionAwareHelper.getConventionValue(ConventionAwareHelper.java:109)
        at org.springframework.boot.gradle.tasks.bundling.BootWar_Decorated.getMainClassName(Unknown Source)
        at org.gradle.api.internal.tasks.properties.bean.AbstractNestedRuntimeBeanNode$DefaultPropertyValue$1$1.create(AbstractNestedRuntimeBeanNode.java:83)
        at org.gradle.util.SingleMessageLogger.whileDisabled(SingleMessageLogger.java:200)
        at org.gradle.api.internal.tasks.properties.bean.AbstractNestedRuntimeBeanNode$DefaultPropertyValue$1.get(AbstractNestedRuntimeBeanNode.java:80)
        at com.google.common.base.Suppliers$MemoizingSupplier.get(Suppliers.java:125)
        at org.gradle.api.internal.tasks.properties.bean.AbstractNestedRuntimeBeanNode$DefaultPropertyValue.getValue(AbstractNestedRuntimeBeanNode.java:138)
        at org.gradle.api.internal.tasks.properties.bean.AbstractNestedRuntimeBeanNode$DefaultPropertyValue.validate(AbstractNestedRuntimeBeanNode.java:149)
        at org.gradle.api.internal.tasks.DefaultTaskInputPropertySpec.validate(DefaultTaskInputPropertySpec.java:61)
        at org.gradle.api.internal.tasks.execution.DefaultTaskProperties.validate(DefaultTaskProperties.java:193)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:47)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
        at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:97)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$ExecuteTaskAction.execute(DefaultTaskExecutionGraph.java:262)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$ExecuteTaskAction.execute(DefaultTaskExecutionGraph.java:246)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:136)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.execute(DefaultTaskPlanExecutor.java:201)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.executeWithTask(DefaultTaskPlanExecutor.java:192)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
        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)

I'm not a Gradle expert, but (to me) the stack trace reads like the License plugin is bringing one or more incompatible Spring jars into the classpath Gradle uses to run the build.

rolfhub commented 5 years ago

We had the same problem. As a workaround we excluded the license-gradle-plugin dependency to spring-core:

buildscript {
    dependencies {
        classpath ('gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0'){
             exclude group: 'org.springframework', module: 'spring-core'
    }
    }
}

Now both spring-boot-gradle-plugin and license-gradle-plugin work again in our setup.

twoversionsofme commented 4 years ago

We had the same problem. As a workaround we excluded the license-gradle-plugin dependency to spring-core:

buildscript {
    dependencies {
        classpath ('gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0'){
           exclude group: 'org.springframework', module: 'spring-core'
  }
    }
}

Now both spring-boot-gradle-plugin and license-gradle-plugin work again in our setup.

@rolfhub I'm fairly green with Gradle and I haven't found a way to exclude a library using the current plugin DSL rather than the legacy buildscript syntax. Are you aware of any?