2014-04-22 5 views
1

Eclipse (STS)로 가져온 AOP (Spring 3.x.x)를 활용하는 Gradle 프로젝트가 있습니다. Gradle의 컨텍스트 메뉴를 사용하여 종속성을 새로 고침/소스를 다시 빌드 할 때 필자는 내 테스트를 올바르게 실행할 수있는 AspectJ 프로젝트로 변환해야합니다. AspectJ 런타임 라이브러리는 다음과 같은 팩토리 메소드를 구현하는 빌드 경로에 없습니다. bean 정의). spring-aspects.jar가 어디에도 없으며 문제없이 Tomcat에 배포됩니다 (libs/폴더에서 aspectJ가 없음). 그것은 나를 두 번 언제 내가 종속성을 새로 고침 및 통합 테스트를 실행해야 다시 만들면서AspectJ 구성으로 Eclipse Gradle 가져 오기

<bean id="fooBarAspect" class="foo.Bar" factory-method="aspectOf" > 

이 과정 작동은하지만 고통스러운 것입니다.

dependencies { 

ajc 'org.aspectj:aspectjtools:1.7.3' 
aspects 'org.springframework:spring-aspects:3.2.4.RELEASE' 

compile (
     'org.aspectj:aspectjrt:1.7.3' 
     ) 

}

생각?

답변

0

"정상적인"컴파일러 대신 ajc 컴파일러를 사용하려면 이클립스의 프로젝트를 aspectj 프로젝트로 표시해야합니다. build.gradle 파일에서 aspectj 컴파일을 어떻게 선언 했습니까? aspectj-rt를 컴파일 클래스 패스에 추가하는 것만으로는 충분하지 않습니다.

gravel을 사용하여 xml 레벨에서 eclipse 프로젝트 구성을 조작 할 수 있습니다. 나는 오래 전에 withXml 훅을 사용하여이 작업을 수행했다. AspectJ의 이클립스 플러그인 작품이 오래된 수 있습니다

https://github.com/breskeby/gradleplugins/blob/0.9-upgrade/aspectjPlugin/aspectJ.gradle#L29

방법에 build.gradle 파일에서 모양과 당신은 아마 당신의 요구에 맞게 업데이트,하지만 당신은 아이디어를 얻을 것이다. AspectJ를 들어

1

:

eclipseClasspath { 
     withXml { xmlProvider -> 
      def classpath = xmlProvider.asNode() 
      def parser = new XmlParser() 

      classpath.classpathentry.findAll{ entry -> 
       [email protected] == 'var' && configurations.runtime.find {[email protected](it.name) && [email protected]('servlet-api') 
       }.each { entry -> 
       def attrs = entry.attributes ?: parser.createNode(entry, 'attributes', [:]) 
       parser.createNode(attrs, 'attribute', [name: 'org.eclipse.jst.component.dependency', value: '../']) 
      } 
     } 
} 
: 이클립스를 들어

apply plugin: 'java' 
apply plugin: 'war' 
apply plugin: 'eclipse' 
apply plugin: 'eclipse-wtp' 

ext.aspectjVersion = '1.7.4' 

configurations { 

    ajc 
    aspects 
    aspectCompile 
    ajInpath 

    compile { 
     extendsFrom aspects 
    } 

} 

compileJava { 
    sourceCompatibility="1.7" 
    targetCompatibility="1.7" 

    doLast{ 
     ant.taskdef(resource:"org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: configurations.ajc.asPath) 
     ant.iajc(
      source:sourceCompatibility, 
      target:targetCompatibility, 
      destDir:sourceSets.main.output.classesDir.absolutePath, 
      maxmem: "512m", 
      fork:  "true", 
      inpath: configurations.ajInpath.asPath, 
      aspectPath:configurations.aspects.asPath, 
      sourceRootCopyFilter:"**/.svn/*,**/*.java", 
      classpath:"${configurations.compile.asPath};${configurations.aspectCompile.asPath}"){ 
      sourceroots{ 
       sourceSets.main.java.srcDirs.each{ 
        pathelement(location:it.absolutePath) 
       } 
      } 
     } 
    } 
} 


dependencies { 
     ajc    "org.aspectj:aspectjtools:1.7.3" 
     compile   "org.aspectj:aspectjrt:1.7.3" 
     aspects  group: 'org.springframework', name: 'spring-aspects', version: springVersion 
     aspectCompile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.0-api', version: '1.0.0.Final' 
     aspectCompile group: 'org.springframework', name: 'spring-tx', version: springVersion 
     aspectCompile group: 'org.springframework', name: 'spring-orm', version: springVersion 
} 

우리는 비트를 수동으로 코드를해야 할

관련 문제