1

@Configurable を使用して、春の側面からクラスに @Configurable のコンパイル時織りを使用するプロジェクトがあります。Spring Tool Suite 3.7.0 を使用し、gradle タスクを使用してアプリケーションをビルドおよび起動すると、すべてが実行されます。(プラグインのおかげで: 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'
}

「spring-aspects.jarをinpathとして追加する」というステップも実行するようにgradleを構成するにはどうすればよいですか?

.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"/>

(classpathentry org.eclipse.jst.j2ee.internal.web.container は既に存在していましたが、属性が欠落しています)

では、これを切り取ってクラスパスに追加するにはどうすればよいですか? 次のようにクラスパスを変更するを見てきました。

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 を手動で調整する正しい方法ですか?

4

1 に答える 1

1

最後に、他の人にとって役立つかもしれない解決策を見つけました。名前付き .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']);
...
于 2015-07-30T13:11:44.390 に答える