javaspringaspectjspring-tool-suiteajdt

Setting up Spring Tool Suite 4 with AspectJ/Spring Boot (m2e connector missing)


I am using the latest version of STS which at the moment is 4.11. I'm building a new project and trying to get AspectJ CTW working with Spring Boot. I have some unit tests to check the aspects with @Async method calls. The funny thing is that the unit tests pass with a maven clean install, but not when building through STS.

I believe the reason is the AJDT plugin or AJDT configurator plugins are not working because I see this error:

Plugin execution not covered by lifecycle configuration:
  dev.aspectj:aspectj-maven-plugin:1.13.M3:compile
  (execution: default, phase: compile)  

I am using the latest aspectj maven plugin with these settings.

<plugin>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.M3</version>
<configuration>
  <source>${maven.compiler.source}</source>
  <target>${maven.compiler.target}</target>
  <complianceLevel>${maven.compiler.target}</complianceLevel>
  <encoding>${project.build.sourceEncoding}</encoding>
  <XnoInline>true</XnoInline>
  <aspectLibraries>
    <aspectLibrary>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
    </aspectLibrary>
  </aspectLibraries>
</configuration>
<executions>
  <execution>
    <goals>
      <goal>compile</goal>
      <goal>test-compile</goal>
    </goals>
  </execution>
</executions>
<dependencies>
  <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjtools</artifactId>
    <version>${aspectj.version}</version>
  </dependency>
</dependencies>
</plugin>

And I tried to install these two software installations:

Getting this set up always seems to be a pain. Has anyone managed to do it with Java 11?


Solution

  • AspectJ Development Tools (AJDT)

    I do not use STS, but mostly IntelliJ IDEA and if Eclipse, then plain Eclipse for Java developers. A while ago, I prepared a new AJDT version for Eclipse 2021-03, which still seems to be working in 2021-06, while developing AspectJ 1.9.7.

    Try downloading the latest snapshot from aspectj.dev: https://aspectj.dev/maven/org/eclipse/ajdt/org.eclipse.ajdt.releng/2.2.4-SNAPSHOT/

    At the time of writing this, the latest snapshot is: https://aspectj.dev/maven/org/eclipse/ajdt/org.eclipse.ajdt.releng/2.2.4-SNAPSHOT/org.eclipse.ajdt.releng-2.2.4-20210509.044425-2.zip

    Sorry that I cannot provide you with a regular Eclipse update site, but while contributing to AspectJ, I have no access to the Eclipse infrastructure. The lead developer is busy, so my own web server is the easiest way to provide you with AJDT. The ZIP archive is about 15 MB in size. You can import it into Eclipse as a virtual update site as described here (scroll to "Install AJDT (AspectJ Development tools) for Eclipse IDE").

    AspectJ Maven Plugin by aspectj.dev

    Some small news: Yesterday I released version 1.13 of AspectJ Maven. It has a few more improvements compared to 1.13.M3, most notably 1.13

    More information can be found on the plugin's GitHub site.


    Update: I found an m2e connector for AJDT which is maintained by Miika Vesti for his private use. At first it was not working for the dev.aspectj groupID, because he had forgotten to push an update to the Eclipse update site, but I got in touch with him and now it works. Please see the project's read-me for more information. You can use the existing update site for Eclipse 2020-12 in order to install a connector which also works on Eclipse 2021-06.

    The connector needs some more work in order to import all AspectJ Maven settings correctly, e.g. it does not work in some of my projects where I deactivated Maven Compiler Plugin, because it currently relies on it being active and things like source/target compiler levels being configured there. Only then it will also correctly import source and target directories as well as dependencies - most prominently the Aspectj runtime library - correctly and result in a usable Eclipse project. I am trying to work with Miika in order to make the connector more self-sufficient in the future.