【发布时间】:2015-07-27 12:30:09
【问题描述】:
我有一个项目使用编译时将 @Configurable 从 spring-aspects 编织到使用 @Configurable 的类中。 如果我使用 gradle 任务来构建和启动我的应用程序,我使用 Spring Tool Suite 3.7.0 并运行所有东西。 (感谢插件:https://github.com/eveoh/gradle-aspectj)。
现在我还想使用 AspectJ Eclipse 特性。通过将项目转换为 AspectJ 并添加 spring-aspects.jar 作为 AspectJ inpath,我手动运行了它。 我也想通过 gradle 来做到这一点。 将项目转变为 AspectJ 自然是可能的:
eclipse {
project {
buildCommand('org.eclipse.ajdt.core.ajbuilder')
natures += 'org.eclipse.ajdt.ui.ajnature'
}
如何配置 gradle 它也执行“添加 spring-aspects.jar 作为我的 inpath”步骤?
当我比较 .classpath 文件时,区别是这个:
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container">
<attributes>
<attribute name="org.eclipse.ajdt.inpath.restriction" value="spring-aspects-4.1.7.RELEASE.jar"/>
<attribute name="org.eclipse.ajdt.inpath" value="org.eclipse.ajdt.inpath"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
(类路径入口 org.eclipse.jst.j2ee.internal.web.container 已经存在,但缺少属性)
那么我怎样才能将这个片段添加到类路径中呢?我看到examples 正在像这样修改类路径:
eclipseClasspath {
withXml { xmlProvider ->
def classpath = xmlProvider.asNode()
def parser = new XmlParser()
...但我总是在这里得到一个错误:
could not find method whenConfigured() for arguments [build_52wic5gr82z6rcs33lo3ix1lk$_run_closure7_closure12_closure13@73914b82] on org.gradle.plugins.ide.eclipse.model.EclipseClasspath_Decorated@6ca18169.
如何修复此错误?
这是配置 AspectJ inpath 以手动调整 .classpath 的正确方法吗?
【问题讨论】:
-
这是 Gradle 的核心问题...尝试直接询问 Gradle 人:discuss.gradle.org
-
谢谢@aboyko。幸好现在解决了。
标签: gradle aspectj sts-springsourcetoolsuite gradle-eclipse spring-aspects