将 grails 2 插件导出到 grails 3 时出错

Posted

技术标签:

【中文标题】将 grails 2 插件导出到 grails 3 时出错【英文标题】:error while exporting grails 2 plugin to grails 3 【发布时间】:2016-02-26 09:56:20 【问题描述】:

我一直在尝试将 grails spring-security-ui 插件升级到 grails 3。如文档中所述,我已将所有依赖项复制到 build.gradle。

文件看起来像这样。

buildscript 
    ext 
        grailsVersion = project.grailsVersion
    
    repositories 
        mavenLocal()
        maven  url 'https://repo.grails.org/grails/core' 
    
    dependencies 
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
    


plugins 
    id "io.spring.dependency-management" version "0.5.2.RELEASE"
    id "com.jfrog.bintray" version "1.2"


version "0.1-SNAPSHOT"
group "org.grails.plugins"

apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "spring-boot"
apply plugin: "org.grails.grails-plugin"
apply plugin: "org.grails.grails-gsp"
// Used for publishing to central repository, remove if not needed
apply from:'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/grailsCentralPublishing.gradle'
apply from:'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle'

ext 
    grailsVersion = project.grailsVersion
    gradleWrapperVersion = project.gradleWrapperVersion


sourceCompatibility = 1.7
targetCompatibility = 1.7

repositories 
    mavenLocal()
    mavenCentral()
    maven  url "https://repo.grails.org/grails/core" 


dependencyManagement 
    imports 
    mavenBom "org.grails:grails-bom:$grailsVersion"
    
    applyMavenExclusions false


dependencies 
    provided 'org.springframework.boot:spring-boot-starter-logging'
    provided "org.springframework.boot:spring-boot-starter-actuator"
    provided "org.springframework.boot:spring-boot-autoconfigure"
    provided "org.springframework.boot:spring-boot-starter-tomcat"

    provided "org.grails:grails-web-boot"
    provided "org.grails:grails-dependencies"
    provided 'javax.servlet:javax.servlet-api:3.1.0'

    compile ':spring-security-core:2.0-RC3'
    compile ':mail:1.0.5'
    compile ':jquery:1.11.1'
    compile ':jquery-ui:1.10.3'
    compile ':famfamfam:1.0.1'

    compile ':spring-security-acl:2.0-RC1', 
        export = false
    

    compile ":hibernate:3.6.10.14", 
        export = false
    

    build ':release:3.0.1', ':rest-client-builder:2.0.1', 
        export = false
    

    testCompile "org.grails:grails-plugin-testing"

    console "org.grails:grails-console"


task wrapper(type: Wrapper) 
    gradleVersion = gradleWrapperVersion

当我尝试安装插件时,出现这样的错误

| Error Error initializing classpath: No such property: export for class: org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency_Decorated (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
groovy.lang.MissingPropertyException: No such property: export for class: org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency_Decorated
    at org.gradle.api.internal.plugins.ExtraPropertiesDynamicObjectAdapter.setProperty(ExtraPropertiesDynamicObjectAdapter.java:46)
    at org.gradle.api.internal.CompositeDynamicObject.setProperty(CompositeDynamicObject.java:119)
    at org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency_Decorated.setProperty(Unknown Source)
    at build_3l359y3diorgc61r1z5bdizfw$_run_closure4_closure8.doCall(/mnt/data/Work/Tutorials/Practice/grails/grails-spring-security-ui-master/build.gradle:70)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
    at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.create(DefaultDependencyHandler.java:70)
    at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.doAdd(DefaultDependencyHandler.java:83)
    at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.methodMissing(DefaultDependencyHandler.java:117)
    at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:225)
    at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:129)
    at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:163)
    at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated.invokeMethod(Unknown Source)
    at build_3l359y3diorgc61r1z5bdizfw$_run_closure4.doCall(/mnt/data/Work/Tutorials/Practice/grails/grails-spring-security-ui-master/build.gradle:69)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
    at org.gradle.api.internal.project.AbstractProject.dependencies(AbstractProject.java:831)
    at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:225)
    at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:129)
    at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
    at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
    at build_3l359y3diorgc61r1z5bdizfw.run(/mnt/data/Work/Tutorials/Practice/grails/grails-spring-security-ui-master/build.gradle:53)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:154)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
    at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:59)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:492)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:86)
    at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
    at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:97)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.configure(InProcessBuildActionExecuter.java:84)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:43)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:31)
    at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:119)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:48)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
| Error Error initializing classpath: No such property: export for class: org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency_Decorated

我已经阅读了编写插件的文档。 export 是一个非常有效的条目。为什么会出现这样的错误。

【问题讨论】:

【参考方案1】:

解决方案 1: 使用provided 而不是compile 'something', export = false 作为:

configurations 
    provided

sourceSets 
    main  
          compileClasspath += configurations.provided 
    

dependencies 
    provided ':spring-security-acl:2.0-RC1'

注意:我没有对此进行测试,但它应该可以工作。

解决方案 2:

相关问题已在 grails 3.0.4 中解决/修复。尝试将其导出到 3.0.4 版本。

例子:

    No such property: developmentModeActive for class issue when run schema-export https://github.com/grails/grails-core/issues/9099

【讨论】:

以上是关于将 grails 2 插件导出到 grails 3 时出错的主要内容,如果未能解决你的问题,请参考以下文章

Grails 插件 compass-sass 不适用于 grails 版本 2.3.5

grails spring安全休息插件

[grails 3]:替换插件描述符上的 doWithWebDescriptor?

添加 Spring Security 插件 3.1.1 后,Grails 3.2.4 应用程序不会加载

Grails 从 2.2.1 升级到 2.3.4 @Secured Annotation

将 grails 2.0.3 应用程序部署到 cloudfoundry 而不使用 cloudfoundry grails-plugin?