Announcement Announcement Module
Collapse
No announcement yet.
@Configurable(preConstruction = true) stopped working when switching to Gradle build Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Configurable(preConstruction = true) stopped working when switching to Gradle build

    Not sure if this is a Spring (3.1.2) or Gradle (1.0) issue but I've posted to StackOverflow and so far noone has replied so hoping someone on this forum has come across this issue and knows what to do to get things working.

    I'm trying to migrate my build from Maven to Gradle which has worked for everything except classes that rely on the @Configurable annotation to inject dependencies, e.g. @Entity instances that reference a UserDetailsManager to assign updateUserID in @PreUpdate.

    I followed instructions to use the AsjectJ plugin for Gradle (http://github.com/breskeby/gradleplu...aspectJ.gradle), but that targets Gradle 0.9 and destDir has changed, so I modified it to destDir:sourceSets.main.output.classesDir.absolute Path. Everything seems fine but I'm guessing I'm missing a Spring-specific step that incorporates the spring-aspects jar to weave @Configurable annotations at ajc compile time.

    In Maven its configured as an aspectLibrary:

    Code:
    <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>aspectj-maven-plugin</artifactId>
          ...
          <configuration>
              <aspectLibraries>
                  <aspectLibrary>
                      <groupId>org.springframework</groupId>
                      <artifactId>spring-aspects</artifactId>
                  </aspectLibrary>
              </aspectLibraries>
          ...
          </configuration>
    </plugin>
    What do I need to do to configure weaving of @Configurable classes in Gradle?


    build.gradle is:

    Code:
    apply plugin: 'war'
    apply plugin: 'jetty'
    
    sourceCompatibility = 1.6
    targetCompatibility = 1.6
    
    version = 0.1
    
    // apply url:'http://github.com/breskeby/gradleplugins/raw/0.9-upgrade/aspectjPlugin/aspectJ.gradle'
    
    configurations {
        ajc
        aspects
        ajInpath
    }
    
    
    
    task compileJava(dependsOn: JavaPlugin.PROCESS_RESOURCES_TASK_NAME, overwrite: true)  {
        dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileJava")
    
        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",
                    aspectPath:configurations.aspects.asPath, inpath:configurations.ajInpath.asPath, sourceRootCopyFilter:"**/.svn/*,**/*.java",classpath:configurations.compile.asPath){
                sourceroots{
                    sourceSets.main.java.srcDirs.each{
                        pathelement(location:it.absolutePath)
                    }
                }
            }
        }
    }
    
    repositories {
        mavenCentral();
        maven { url "http://maven.springframework.org/release"                                    /* Spring Framework */ }
        maven { url "http://oss.sonatype.org/content/repositories/vaadin-snapshots/"              /* Vaadin */ }
        maven { url "http://maven.vaadin.com/vaadin-addons"                                       /* Vaadin Add-ons */ }
        maven { url "https://repository.jboss.org/nexus/content/repositories/releases/"           /* JBoss */ }
        maven { url "https://repository.jboss.org/nexus/content/repositories/central/"            /* JBoss Proxy */  }
        maven { url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases" /* JBoss 3rd Party */ }
        maven { url "http://oss.sonatype.org/content/groups/jetty"                                /* Jetty */ }
    }
    
    dependencies {
        ajc     group: 'org.aspectj',                     name: 'aspectjweaver',                  version: '1.6.12'
        ajc     group: 'org.aspectj',                     name: 'aspectjtools',                   version: '1.6.12'
        ajc     group: 'org.springframework',             name: 'spring-aspects',                 version: '3.1.2.RELEASE'
    
    
        compile group: 'org.aspectj',                     name: 'aspectjrt',                      version: '1.6.12'
        compile group: 'org.aspectj',                     name: 'aspectjweaver',                  version: '1.6.12'
    
        compile group: 'org.springframework',             name: 'spring-jdbc',                    version: '3.1.2.RELEASE'
        compile group: 'org.springframework',             name: 'spring-orm',                     version: '3.1.2.RELEASE'
        compile group: 'org.springframework',             name: 'spring-aop',                     version: '3.1.2.RELEASE'
        compile group: 'org.springframework',             name: 'spring-aspects',                 version: '3.1.2.RELEASE'
        compile group: 'org.springframework',             name: 'spring-web',                     version: '3.1.2.RELEASE'
        compile group: 'org.springframework',             name: 'spring-webmvc',                  version: '3.1.2.RELEASE'
        compile group: 'org.springframework',             name: 'spring-expression',              version: '3.1.2.RELEASE'
        compile group: 'org.springframework.security',    name: 'spring-security-core',           version: '3.1.1.RELEASE'
        compile group: 'org.springframework.security',    name: 'spring-security-acl',            version: '3.1.1.RELEASE'
        compile group: 'org.springframework.security',    name: 'spring-security-config',         version: '3.1.1.RELEASE'
        compile group: 'org.springframework.security',    name: 'spring-security-web',            version: '3.1.1.RELEASE'
        compile group: 'org.hibernate',                   name: 'hibernate-annotations',          version: '3.5.6-Final'
        compile group: 'org.hibernate',                   name: 'hibernate-entitymanager',        version: '3.5.6-Final'
        compile group: 'com.vaadin',                      name: 'vaadin',                         version: '6.7.5'
        compile group: 'org.vaadin.addons',               name: 'confirmdialog',                  version: '1.1.1'
        compile group: 'com.google.gwt',                  name: 'gwt-user',                       version: '2.3.0'
        compile group: 'javax.servlet',                   name: 'servlet-api',                    version: '2.5'
        compile group: 'org.slf4j',                       name: 'slf4j-api',                      version: '1.6.4'
        compile group: 'org.slf4j',                       name: 'slf4j-ext',                      version: '1.6.4'
        compile group: 'ch.qos.logback',                  name: 'logback-core',                   version: '1.0.2'
        compile group: 'ch.qos.logback',                  name: 'logback-classic',                version: '1.0.2'
        compile group: 'mysql',                           name: 'mysql-connector-java',           version: '5.1.17'
        compile group: 'org.eclipse.persistence',         name: 'javax.persistence',              version: '2.0.0'
        compile group: 'edu.vt.middleware',               name: 'vt-password',                    version: '3.1.1'
        compile group: 'org.projectlombok',               name: 'lombok',                         version: '0.10.1'
        compile group: 'commons-lang',                    name: 'commons-lang',                   version: '2.3'
        compile group: 'commons-codec',                   name: 'commons-codec',                  version: '1.6'
        compile group: 'checkstyle',                      name: 'checkstyle',                     version: '5.0'
        compile group: 'javax.annotation',                name: 'jsr250-api',                     version: '1.0'
        compile group: 'net.sourceforge.jtds',            name: 'jtds',                           version: '1.2.4'
        compile group: 'joda-time',                       name: 'joda-time',                      version: '2.1'
        compile group: 'com.google.guava',                name: 'guava',                          version: '11.0.2'
        compile group: 'org.apache.tomcat',               name: 'tomcat-jdbc',                    version: '7.0.23'
        compile group: 'org.opensymphony.quartz',         name: 'quartz',                         version: '1.6.1'
        compile group: 'org.springframework.batch',       name: 'spring-batch-core',              version: '2.0.3.RELEASE'
    }
Working...
X