gradle如何在STS(eclipse)中为AspectJ和spring方面设置.classpath
我有一个项目,使用@Configurable将@Configurable从spring方面编译时编织到我的类中。 我使用Spring工具套件3.7.0,如果我使用gradle任务来构建和启动我的应用程序,那么一切都可以运行。(感谢插件:) 现在我还想使用AspectJ Eclipse特性。通过将项目转换为AspectJ并将spring-aspects.jar添加为AspectJ inpath,我手动实现了这一点。 我也想让gradle做这件事。 可以通过以下方式将项目转化为AspectJ nature:gradle如何在STS(eclipse)中为AspectJ和spring方面设置.classpath,gradle,aspectj,sts-springsourcetoolsuite,gradle-eclipse,spring-aspects,Gradle,Aspectj,Sts Springsourcetoolsuite,Gradle Eclipse,Spring Aspects,我有一个项目,使用@Configurable将@Configurable从spring方面编译时编织到我的类中。 我使用Spring工具套件3.7.0,如果我使用gradle任务来构建和启动我的应用程序,那么一切都可以运行。(感谢插件:) 现在我还想使用AspectJ Eclipse特性。通过将项目转换为AspectJ并将spring-aspects.jar添加为AspectJ inpath,我手动实现了这一点。 我也想让gradle做这件事。 可以通过以下方式将项目转化为AspectJ nat
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"/>
…但我总是在这里出错:
找不到参数[build\u 52wic5gr82z6rcs33lo3ix1lk$\u run\u closure7\u closure12]的whenconfigurated()方法_closure13@73914b82]在org.gradle.plugins.ide.eclipse.model.eclipsepasspath上_Decorated@6ca18169.
如何修复此错误?
这是配置AspectJ inpath以手动调整.classpath的正确方法吗?最后我找到了一个解决方案,可能对其他人有帮助。 要创建命名的.classpath代码段,只需在build.gradle中添加以下内容
eclipse {
classpath {
file {
withXml {
def xmlparser = new XmlParser()
def node = it.asNode()
node.findAll{it['@path'] == 'org.eclipse.jst.j2ee.internal.web.container'}.each {
println it;
def attributes = xmlparser.createNode(it, 'attributes', [:])
xmlparser.createNode(attributes, 'attribute', [name: 'org.eclipse.ajdt.inpath.restriction', value: 'spring-aspects-4.1.7.RELEASE.jar']);
xmlparser.createNode(attributes, 'attribute', [name: 'org.eclipse.ajdt.inpath', value: 'org.eclipse.ajdt.inpath']);
...
这是格雷德尔的核心问题。。。试着直接问Gradle的人:谢谢@aboyko。幸好现在解决了。
eclipse {
classpath {
file {
withXml {
def xmlparser = new XmlParser()
def node = it.asNode()
node.findAll{it['@path'] == 'org.eclipse.jst.j2ee.internal.web.container'}.each {
println it;
def attributes = xmlparser.createNode(it, 'attributes', [:])
xmlparser.createNode(attributes, 'attribute', [name: 'org.eclipse.ajdt.inpath.restriction', value: 'spring-aspects-4.1.7.RELEASE.jar']);
xmlparser.createNode(attributes, 'attribute', [name: 'org.eclipse.ajdt.inpath', value: 'org.eclipse.ajdt.inpath']);
...