How to set .classpath in STS (eclipse) by gradle for AspectJ and spring-aspects -
i have project using compile time weaving @configurable spring-aspects classes using @configurable. use spring tool suite 3.7.0 , got running if use gradle tasks build , start application. (thanks plugin: https://github.com/eveoh/gradle-aspectj).
now want use aspectj eclipse nature. manually got running turning project aspectj , adding spring-aspects.jar aspectj inpath. want gradle well. turn project aspectj nature possible by:
eclipse { project { buildcommand('org.eclipse.ajdt.core.ajbuilder') natures += 'org.eclipse.ajdt.ui.ajnature' }
how to configure gradle step "add spring-aspects.jar inpath"?
when compare .classpath file difference one:
<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"/>
(the classpathentry org.eclipse.jst.j2ee.internal.web.container there attributes missing)
so how can add snipped classpath? have seen examples modifying classpath this:
eclipseclasspath { withxml { xmlprovider -> def classpath = xmlprovider.asnode() def parser = new xmlparser()
...but error here: could not find method whenconfigured() arguments [build_52wic5gr82z6rcs33lo3ix1lk$_run_closure7_closure12_closure13@73914b82] on org.gradle.plugins.ide.eclipse.model.eclipseclasspath_decorated@6ca18169.
how fix error? right way configure aspectj inpath adapt .classpath manually?
finally found solution, maybe helpful others. create named .classpath snippet add following in 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']); ...
Comments
Post a Comment