Giter Club home page Giter Club logo

aspectj-maven-plugin's Introduction

Mojohaus AspectJ Maven Plugin

This is the aspectj-maven-plugin.

License: MIT Maven Central GitHub CI

Overview

This plugin weaves AspectJ aspects into your classes using the AspectJ compiler ajc. Typically, aspects are used in one of two ways within your Maven reactors:

  • As part of a Single Project, implying aspects and code are defined within the same Maven project. This is the simplest approach to start out with; feel free to examine the "Examples: Single-project AspectJ use" to better understand single-project use.

  • As part of a Multi-module Maven Reactor where one/some project(s) contains aspects and other projects within the Maven reactor contain code using the aspects ("woven by the aspects"). This is a more complex and powerful approach, best suited when several Maven projects should be woven by a common set of aspects. The "Examples: Multi-module AspectJ use" contains a basic walk-through of this approach.

Contributing

The first step is to create an appropriate issue. Describe the problem/idea you have and create an appropriate pull request.

Test you changes locally using

mvn clean verify -Pdocs,run-its

If you need to contact a committer, please consider getting active on the mailing lists.

Releasing

  • Make sure gpg-agent is running.
  • Make sure all tests pass mvn clean verify -Prun-its
  • Execute mvn -B release:prepare release:perform

For publishing the site do the following:

cd target/checkout
mvn verify site site:stage scm-publish:publish-scm

aspectj-maven-plugin's People

Contributors

andham avatar bentmann avatar bmarwell avatar brianf avatar ccl0326 avatar ctomc avatar dantran avatar davidkarlsen avatar dennisl avatar dependabot[bot] avatar dheid avatar hboutemy avatar kriegaex avatar lennartj avatar megglos avatar mfriedenhagen avatar mojo2012 avatar ndeloof avatar nigelzor avatar olamy avatar paplorinc avatar pcolot01 avatar rfscholte avatar slachiewicz avatar spoutnik-be avatar timwebster9 avatar xkommando avatar zuckel avatar zybreak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aspectj-maven-plugin's Issues

Invalid ticket, please delete

I am stupid and ugly and have created an invalid ticket because there was a problem in my own POM - very embarrassing.

@Around advice compilation fails when using lambdas

When I use lambda expression in method with around annotation it fails, it works for Before, After etc.

exception during build:
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.8:compile (default) on project test-aspectj: AJC compiler errors: [ERROR] abort trouble in: [ERROR] org.tests.TestAspect -- (IllegalStateException) there is no classname for invokedynamic [ERROR] there is no classname for invokedynamic [ERROR] java.lang.IllegalStateException: there is no classname for invokedynamic [ERROR] at org.aspectj.apache.bcel.generic.InvokeDynamic.getClassName(InvokeDynamic.java:126) [ERROR] at org.aspectj.weaver.bcel.BcelAccessForInlineMunger.openAroundAdvice(BcelAccessForInlineMunger.java:141) [ERROR] at org.aspectj.weaver.bcel.BcelAccessForInlineMunger.munge(BcelAccessForInlineMunger.java:80) [ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:440) [ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:100) [ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1689) [ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1633) [ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1398) [ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1155) [ERROR] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514) [ERROR] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterCompiling(AjPipeliningCompilerAdapter.java:375) [ERROR] at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:78) [ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:471) [ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036) [ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272) [ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185) [ERROR] at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112) [ERROR] at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60) [ERROR] at org.aspectj.tools.ajc.Main.run(Main.java:371) [ERROR] at org.aspectj.tools.ajc.Main.runMain(Main.java:248) [ERROR] at org.codehaus.mojo.aspectj.AbstractAjcCompiler.execute(AbstractAjcCompiler.java:537) [ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) [ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) [ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) [ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) [ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) [ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:483) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) [ERROR] at org.codehaus.classworlds.Launcher.main(Launcher.java:47) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:483) [ERROR] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR]

pom.xml
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.8:compile (default) on project test-aspectj: AJC compiler errors: [ERROR] abort trouble in: [ERROR] org.tests.TestAspect -- (IllegalStateException) there is no classname for invokedynamic [ERROR] there is no classname for invokedynamic [ERROR] java.lang.IllegalStateException: there is no classname for invokedynamic [ERROR] at org.aspectj.apache.bcel.generic.InvokeDynamic.getClassName(InvokeDynamic.java:126) [ERROR] at org.aspectj.weaver.bcel.BcelAccessForInlineMunger.openAroundAdvice(BcelAccessForInlineMunger.java:141) [ERROR] at org.aspectj.weaver.bcel.BcelAccessForInlineMunger.munge(BcelAccessForInlineMunger.java:80) [ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:440) [ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:100) [ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1689) [ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1633) [ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1398) [ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1155) [ERROR] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514) [ERROR] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterCompiling(AjPipeliningCompilerAdapter.java:375) [ERROR] at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:78) [ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:471) [ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036) [ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272) [ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185) [ERROR] at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112) [ERROR] at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60) [ERROR] at org.aspectj.tools.ajc.Main.run(Main.java:371) [ERROR] at org.aspectj.tools.ajc.Main.runMain(Main.java:248) [ERROR] at org.codehaus.mojo.aspectj.AbstractAjcCompiler.execute(AbstractAjcCompiler.java:537) [ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) [ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) [ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) [ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) [ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) [ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:483) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) [ERROR] at org.codehaus.classworlds.Launcher.main(Launcher.java:47) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:483) [ERROR] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR]

pom.xml:
`

4.0.0

<groupId>org.tests</groupId>
<artifactId>test-aspectj</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.8</version>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
            <configuration>
                <forceAjcCompile>true</forceAjcCompile>
                <complianceLevel>1.8</complianceLevel>
                <source>1.8</source>
                <target>1.8</target>
                <showWeaveInfo>true</showWeaveInfo>
                <weaveDirectories>
                    <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
                </weaveDirectories>
                <sources/>
            </configuration>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>compile</goal>
                        <!-- use this goal to weave all your main classes -->
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<properties>
    <aspectj.version>1.8.8</aspectj.version>
</properties>

`

Aspect code:
`package org.tests;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@aspect
public class TestAspect {
@around("@annotation(org.tests.TestAnnotation)")
public Object memoize(ProceedingJoinPoint joinPoint) throws Throwable {
final Runnable test = () -> System.out.println("test");
test.run();

    return joinPoint.proceed();
}

}
`

Annotation code:
`package org.tests;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@target(ElementType.METHOD)
@retention(RetentionPolicy.RUNTIME)
public @interface TestAnnotation {}
`

aspectj plugin removes java 8 method parameter names information

The new compiler option -parameters allows to compile in the method parameter names information into the bytecode. After the aspectj processing this information goes removed.

Here ist the configuration of maven compiler plugin

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.3</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <compilerArgument>-parameters</compilerArgument>
      </configuration>
    </plugin>

And configuration of aspectj

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>aspectj-maven-plugin</artifactId>
      <version>1.8</version>
      <executions>
        <execution>
          <goals>
            <goal>compile</goal>
            <goal>test-compile</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <encoding>UTF-8</encoding>
        <source>1.8</source>
        <target>1.8</target>
        <complianceLevel>1.8</complianceLevel>
      </configuration>
    </plugin>

It will be very nice, if you fix it

Fix report generation under JDK 1.7

Currently, under JDK 7 the CreateReport and CreateSite ITs fail with the same message:

> Decorating html files...
> Decorating /home/lj/Development/Projects/Mojohaus/aspectj-maven-plugin/target/it/CreateReport/target/site/aspectj-repo
rt/Azpect.html...
An internal error occured in ajdoc

If this has not already been logged as a bug raised please raise
a new AspectJ bug at https://bugs.eclipse.org/bugs including the
text below. To make the bug a priority, please also include a test
program that can reproduce this problem.

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1904)
        at org.aspectj.tools.ajdoc.HtmlDecorator.decorateHTMLFile(HtmlDecorator.java:272)
        at org.aspectj.tools.ajdoc.HtmlDecorator.decorateHTMLFromIPE(HtmlDecorator.java:122)
        at org.aspectj.tools.ajdoc.HtmlDecorator.decorateHTMLFromIPEs(HtmlDecorator.java:72)
        at org.aspectj.tools.ajdoc.HtmlDecorator.decorateHTMLFromInputFiles(HtmlDecorator.java:62)
        at org.aspectj.tools.ajdoc.Main.decorateHtmlFiles(Main.java:287)
        at org.aspectj.tools.ajdoc.Main.main(Main.java:159)
        at org.codehaus.mojo.aspectj.AjcReportMojo.executeReport(AjcReportMojo.java:280)
        at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:190)
        at org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:99)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)

Dependency Error AspectJ Maven Plugin Installation For com:sun:tools:jar

I would like to run the Maven project that I have on https://github.com/ihsanhaikalz/testMaven in the Eclipse 4.5 (Mars) but it gave me an error in the pom.xml as follow:

1 problem was encountered while building the effective model for
org.codehaus.mojo:aspectj-maven-plugin:1.8 [ERROR]
'dependencies.dependency.systemPath' for com.sun:tools:jar must specify an
absolute path but is ${toolsjarSystemPath} @

I already installed AJDT for Eclipse 4.5 through http://download.eclipse.org/tools/ajdt/45/dev/update and when I pulled from my github the Eclipse started to download Maven plugin connectors and Maven integration for AJDT but the error is still there. For the complete question please refer to http://stackoverflow.com/questions/37994466/dependency-error-aspectj-maven-plugin-installation-for-comsuntoolsjar

Can't pass --module-path argument to the compiler.

In order to build a java 9/10 module based aspect j project with maven I need to add aspectjrt.jar to the module path. The ajc compiler has the --module-path option e.g.:

ajc --module-path c:/opt/aspectj1.9/lib/aspectjrt.jar ...

but I can't seem to get the aspectj-maven-plugin to pass this through to the compiler.

aspectj-maven compiler version 1.11.
aspectj version 1.9.1

Note that I can get around this with the ASPECTJ_OPTS environment variable, e.g.

$ export ASPECTJ_OPTS="--module-path c:/opt/aspectj1.9/lib/aspectjrt.jar"
$ mvn aspectj:compile

aspectj-maven-plugin the includes tags does not work

I have two aop , just want to use one of them , the excludes is work, but the includes does not work, use excludes can work(It is inconvenient to add new aop always) , use the command( mvn clean package or mvn clean compile)
the following is my configuration:
image

`

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.8.13</version>
    </dependency>

`

not working with java 17

openjdk 17 has reached general availability (GA) level, but AJC doesn't allow version 17

AJC compiler errors:
[ERROR] error source level should be in '1.1'...'1.8','9'...'16' (or '5.0'..'16.0'): 17

Next release should be 1.13

Currently, the POM uses 1.12.0-SNAPSHOT. I would like to suggest switching to 1.13.0-SNAPSHOT in order to recognise and honor the fact that Nick Wong released versions 1.12.1 and 1.12.6 already which are widely used. This project now contains changes both he and I have contributed to the project before someone started merging or replicating them here. I also tried to reflect his prior work by publishing versions like 1.13.M3 in my fork. The world did not stop turning while this project was inactive. We are all happy that now there is some momentum in development, but I think a 1.12.0 release would cause more confusion than necessary.

WDYT, guys?

DEF: ignoring the test scope - during production compile

Actual:
compiles src\main\java\com\mycompany\app\ShoultNotCompile.java

  @org.junit.Test
    public void testMain() throws Exception {

    }

even when jar containing the class the org.junit.Test is defined with **scope **test.

Expeced:
the mvn compile should fail

test project:
my-app.zip

OpenJdk11 Issue

I'm using OpenJDK 64-Bit Server VM Zulu11.45+28-SA.
During compiling product i got compile error like 'Type java.lang.Integer is indirectly referenced from required .class files but cannot be resolved since the declaring package java.lang exported from module java.base conflicts with a package accessible from module unnamed.

Below is the compiler configuration.

     <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.14.0</version>
            <configuration>
                <complianceLevel>11</complianceLevel>
                <source>11</source>
                <target>11</target>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

There are defined extra compiler arguments for maven-compiler to successfully pass compilation for OpenJdk11.

<compilerArgs>
     <arg>--add-exports</arg><arg>java.base/sun.security.x509=ALL-UNNAMED</arg>
</compilerArgs>

I think the same stuff should be added as well in the aspectj compiler plugin configuration,how can i add particular compiler arguments?Is it possible at all or not?

Weaver doesn't consider transitive dependencies

If you include a dependency to be weaved that has a transitive dependency that you also wants to weave, this later is not considered unless explicitly specified.
Is there a workaround for that?

AJC warning incorrect classpath: ... org.springframework.roo.annotations-2.0.0.BUILD-SNAPSHOT.pom

Pom dependencies like

<dependencyManagement>
	<dependencies>

		<!-- Spring Roo annotations -->
		<dependency>
			<groupId>org.springframework.roo</groupId>
			<artifactId>org.springframework.roo.annotations</artifactId>
			<version>${roo.version}</version>
			<type>pom</type>
			<scope>provided</scope>
		</dependency>

are integrated in the classpath delegation as the artefact org.springframework.roo.annotations-2.0.0.BUILD-SNAPSHOT.pom associated to their dependencies. The ajc compiler is not able to able the pom dependency and is generating the warning incorrect classpath.

Pull request proposal : #28

Fix typo in the Usage page

There is a typo in the Usage page.

       <dependencies>
          <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>${aspectj.version}</version>
          </dependency>
        <dependencies> <!-- should be a closing element -->

Copy & Paste rocks!!!

Plugin produces java files in project root

When using the plugin a copy of generated sources is copied to the project root (after the build I have "com/myproject/..." in the dir where the pom file resides). I've scoured the docs and search the web for answers but can't find a config that changes where these files are output. The plugin does everything else fine. Is there a way to get rid of this directory or move it into target?

Couldn't find the absolute location ${toolsjarSystemPath}.

I got the following error when i was trying to import a new project. I couldn't find the reason why it been referred from jre instead of jdk.

Problem : 1 problem was encountered while building the effective model for org.codehaus.mojo:aspectj-maven-plugin:1.8 [ERROR] 'dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${toolsjarSystemPath}

ref : http://stackoverflow.com/questions/33208876/maven-error-after-importing-latest-code-from-github

Name :java.home Value : C:\Program Files\Java\jre1.8.0_40

Specified profiles in aspectj-maven-plugin.

<profile>
      <id>standardToolsJar-profile</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <file>
          <exists>${java.home}/../lib/tools.jar</exists>
        </file>
      </activation>
      <properties>
        <toolsjarSystemPath>${java.home}/../lib/tools.jar</toolsjarSystemPath>
      </properties>
    </profile>
    <profile>
      <id>appleJdkToolsJar-profile</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <file>
          <exists>${java.home}/../Classes/classes.jar</exists>
        </file>
      </activation>
      <properties>
        <toolsjarSystemPath>${java.home}/../Classes/classes.jar</toolsjarSystemPath>
      </properties>
    </profile>
    <profile>
      <id>java8</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <additionalparam>-Xdoclint:none</additionalparam>
      </properties>
    </profile>

Fork mode & automatic aspectjtools version switch

Hi,

I've made a patch from release 1.10 to add two features to the aspectj-maven-plugin.
patch.zip

1- Option to invoke AJC with an external JVM (fork option)
2- Automaticaly switch of aspectjtools version when the Maven JVM runtime changes

1- Ability to fork AJC

The plugin could be configured with the <executable> and <executableArguments>
to specify the target JVM to run AJC with and its arguments.
Thus we can run Maven with java 8 runtime and weave for a java 7 one.

Unfortunatly, in that mode (fork mode), we must declare the aspectjtools version
in the plugin dependencies:

 <plugin>
 	<groupId>org.codehaus.mojo</groupId>
 	<artifactId>aspectj-maven-plugin</artifactId>
 	<dependencies>
 	    <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjtools</artifactId>
                <version>Depends on the target runtime</version>
           </dependency>
 	</dependencies>
 </plugin>

2- Automaticaly switch of aspectjtools version

With an in core mode, the plugin uses the Maven runtime to compile.
Thus the aspectjtools version depends on the runtime version.

We use the jdk6,7 and 8 profiles to automaticaly swith of aspectjtools version.
The plugin should be released with a java 6 maven runtime to keep a java 6 compatibility.

add Java 9 support

When building a project that makes use of the aspectj-maven-plugin:1.9 with a pre release version of Java 9 the following execption occures:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.9:compile (default) on project foobar: Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.9:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.9 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:9-ea at specified path C:\Program Files\Java\jdk-9/../lib/tools.jar -> [Help 1]

I already upgraded the aspectjtools to version 1.9.0.BETA-5 (which should support Java 9) but that does not fix the issue.

The use of the tools.jar is mentioned in the pom.xml of the aspectj-maven-plugin - thus it is probably the plugin which needs some changes to (also) support Java 9.

Dependency artifacts have higher precedence than reactor artifacts

In a multi-module project, if an artifact is both a project artifact (a sibling module) and also a dependency artifact, the latter one will win and make it to the classpath. An artifact from the repository will then be used instead of the current one from the active build.
This will break the build if there were any changes to one module that need to be visible to another module.

The solution is to reorder dependencies when building the class-path such that reactor artifacts are always considered first.

The scenario can happen e.g. in presence of a BOM such as created by cyclonedx-maven-plugin.

random build error: basedir src / main / java does not exist

Hi,
When I use the following configuration:

<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>aspectj-maven-plugin</artifactId>
	<version>1.11</version>
	<configuration>
		<Xlint>ignore</Xlint>
		<complianceLevel>1.8</complianceLevel>
		<verbose>true</verbose>
		<sources>
			<source>
				<basedir>src/main/java</basedir>
				<includes>
					<include>**/*Aspect.java</include>
				</includes>
			</source>
		</sources>
		<weaveDependencies>
			<weaveDependency>
				<groupId>com.mycompany</groupId>
				<artifactId>my-model</artifactId>
			</weaveDependency>
		</weaveDependencies>
	</configuration>
	<executions>
		<execution>
			<goals>
				<!-- weaving of the main classes -->
				<goal>compile</goal>
				<!-- weaving of the UT -->
				<goal>test-compile</goal>
			</goals>
		</execution>
	</executions>
</plugin>

I get randomly the following build error:

06-Feb-2018 15:49:25	[INFO] ------------------------------------------------------------------------
06-Feb-2018 15:49:25	[INFO] BUILD FAILURE
06-Feb-2018 15:49:25	[INFO] ------------------------------------------------------------------------
06-Feb-2018 15:49:25	[INFO] Total time: 16.631 s
06-Feb-2018 15:49:25	[INFO] Finished at: 2018-02-06T14:49:25+00:00
06-Feb-2018 15:49:26	[INFO] Final Memory: 73M/671M
06-Feb-2018 15:49:26	[INFO] ------------------------------------------------------------------------
06-Feb-2018 15:49:26	[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile (default) on project commons: Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile failed: basedir src/main/java does not exist -> [Help 1]
06-Feb-2018 15:49:26	[ERROR] 
06-Feb-2018 15:49:26	[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
06-Feb-2018 15:49:26	[ERROR] Re-run Maven using the -X switch to enable full debug logging.
06-Feb-2018 15:49:26	[ERROR] 

Can you help me a bit and tell me what's happening?
Regards.

getting an aspectj compiler error that I don't understand

Hello,

I am doing a custom build of the Cinnamon webdriver sub-project in github. I am always seeing the same error which has to do with a problem with the aspectj compiler, but I am not sure how to fix it. I do see that a version field is not defined in the Module class but can't sort out why this might be relevant.

The environment is Java 1.8_121, aspect jars 1.8.10, aspectj-maven-plugin 1.9, maven 3.3.9

On the off chance that someone will recognize what the issue might be I'm including the maven output resulting from turning the -e flag on.

If there is any additional information that would be useful to help trouble shoot this problem please let me know and I will deliver it.

Any help that anyone might offer will be appreciated.

Andrews-MBP:webdriver andy$ mvn -e clean compile
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building cinnamon-webdriver 0.0.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ cinnamon-webdriver ---
[INFO]
[INFO] --- aspectj-maven-plugin:1.9:compile (default) @ cinnamon-webdriver ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.109 s
[INFO] Finished at: 2017-03-05T13:22:43-05:00
[INFO] Final Memory: 14M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.9:compile (default) on project cinnamon-webdriver: Unable to parse configuration of mojo org.codehaus.mojo:aspectj-maven-plugin:1.9:compile for parameter version: Cannot find 'version' in class org.codehaus.mojo.aspectj.Module -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.9:compile (default) on project cinnamon-webdriver: Unable to parse configuration of mojo org.codehaus.mojo:aspectj-maven-plugin:1.9:compile for parameter version: Cannot find 'version' in class org.codehaus.mojo.aspectj.Module
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginConfigurationException: Unable to parse configuration of mojo org.codehaus.mojo:aspectj-maven-plugin:1.9:compile for parameter version: Cannot find 'version' in class org.codehaus.mojo.aspectj.Module
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:662)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:594)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: org.codehaus.plexus.component.configurator.ComponentConfigurationException: Cannot find 'version' in class org.codehaus.mojo.aspectj.Module
at org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHelper.java:252)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:101)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration(ObjectWithFieldsConverter.java:57)
at org.codehaus.plexus.component.configurator.converters.composite.AbstractCollectionConverter.fromChildren(AbstractCollectionConverter.java:54)
at org.codehaus.plexus.component.configurator.converters.composite.ArrayConverter.fromConfiguration(ArrayConverter.java:52)
at org.eclipse.sisu.plexus.CompositeBeanHelper.convertProperty(CompositeBeanHelper.java:273)
at org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHelper.java:210)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:101)
at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:34)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:632)
... 23 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException

Plugin doesn't detect recompiled files

The Maven compiler plugin currently always recompiles sources, even if there have been any changes at all (see these tickets for details). That recompilation however is not recognized by the AspectJ Maven plugin and it just skips AspectJ compilation on subsequent runs.

To reproduce:

$ git clone https://github.com/spring-projects/spring-data-jpa
$ cd spring-data-jpa
$ mvn clean package -DskipTests
…
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ spring-data-jpa ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 101 source files to /Users/olivergierke/Documents/workspace/spring-data-jpa/target/classes
… 
[INFO] --- aspectj-maven-plugin:1.8:compile (default) @ spring-data-jpa ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
    <unknown source file>:<no line information>
[INFO]
$ mvn package -DskipTests
…
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ spring-data-jpa ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 101 source files to /Users/olivergierke/Documents/workspace/spring-data-jpa/target/classes
…
[INFO] --- aspectj-maven-plugin:1.8:compile (default) @ spring-data-jpa ---
[INFO] No modifications found skipping aspectJ compile
…

See the last line. The plugin skips the compilation step although the compiler plugin has recompiled the code and we end up with classes that haven't got any aspects applied.

Documentation improvement: Optional parameters sources and targetSources sample code

The optional parameters 'sources' and 'testSources' documentation for the compile and test-compile goals (respectively) might be incomplete, the text implies that includes and excludes might be specified, yet there are no hints on how that can be accomplished. One alternative I found to work is (covers my use case).:

<testSources>
    <source>
        <basedir>src/test/java/</basedir>
    </source>
</testSources>

It took me sometime to figure it out, perhaps an example can be provided where the syntax is shown. I must say I first assumed a structure like <testSources><includes><include>some/**/expression</... by analogy from other parameters example code.

I'm guessing the includes and excludes can be leveraged directly inside <source>... using something along the lines of <dirsExcluded>, <dirsIncluded>, etc. as per the structure of DirectoryScanner, but I'm not really familiar with the mechanisms by which configuration parameters are converted inside maven plugins.

Perhaps the documentation can be complemented by someone fully familiar with the possibilities.

Links to the related documentation:
@ http://www.mojohaus.org/aspectj-maven-plugin/test-compile-mojo.html#testSources

Set the java test source folders to use, specifying the includes and excludes.

and
@ http://www.mojohaus.org/aspectj-maven-plugin/compile-mojo.html#sources

Set the java source folders to use, specifying the includes and excludes.

Unable to weave dependencies from project with POM packaging type

Hello,

I am looking for solution on how to correctly use this plugin to weave dependencies of a project with POM packaging type.

ArtifactHandler artifactHandler = project.getArtifact().getArtifactHandler();
if (!"java".equalsIgnoreCase(artifactHandler.getLanguage())) {
getLog().warn("Not executing aspectJ compiler as the project is not a Java classpath-capable package");
return;
}

The above code from the 'AbstractAjcCompiler' class is preventing me to weave dependencies as it explicitly prohibits the AJC compiler to be executed on POM project.

http://maven.apache.org/ref/3.1.1/maven-core/artifact-handlers.html

I was wondering if you think it is safe to skip this test in case 'forceAjcCompile' is set.

java 11 compiler support

I am getting the following error (even when using -Daspectj.skip=true):

[INFO] --- aspectj-maven-plugin:1.11:compile (aspectj-compile) @asdfasdf ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.497 s
[INFO] Finished at: 2018-09-01T16:56:01+02:00
[INFO] Final Memory: 53M/187M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile (aspectj-compile) on project asdfasdf: Execution aspectj-compile of goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.11 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:11 at specified path /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/../lib/tools.jar -> [Help 1]
[ERROR]

Duplicate field name "ajc$tjp_0"

I am using aspectj-maven-plugin to weave my sources and tests.
I have a spring-boot app, in which I want to use compile-time weaving of my code to manage JDBC transactions. Here is my portion of the maven file:

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>1.18.8</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>1.3.1.Final</version>
                        </path>
                    </annotationProcessorPaths>
                    <compilerArgs>
                        <compilerArg>-Amapstruct.defaultComponentModel="spring"</compilerArg>
                        <compilerArg>-Amapstruct.unmappedTargetPolicy=WARN</compilerArg>
                        <compilerArg>-Amapstruct.suppressGeneratorTimestamp=true</compilerArg>
                        <compilerArg>-Amapstruct.suppressGeneratorVersionInfoComment=true</compilerArg>
                    </compilerArgs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.11</version>
                <configuration>
                    <proc>none</proc>
                    <Xlint>ignore</Xlint>
                    <forceAjcCompile>true</forceAjcCompile>
                    <complianceLevel>${java.version}</complianceLevel>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <showWeaveInfo>true</showWeaveInfo>
                    <sources/>
                    <testSources/>
                    <weaveDirectories>
                        <weaveDirectory>${project.build.outputDirectory}</weaveDirectory>
                    </weaveDirectories>
                    <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>1.8.13</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>1.8.13</version>
                    </dependency>
                </dependencies>
            </plugin>

After the compilation phase, the integration test starts running, but it fails immediately with:

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [my_package.microservice.MyManager] for bean with name 'myManager' defined in file [/my_project/service/target/test-classes/my_package/MyManager.class]: problem with class file or dependent class; nested exception is java.lang.ClassFormatError: Duplicate field name "ajc$tjp_0" with signature "Lorg.aspectj.lang.JoinPoint$StaticPart;" in class file my_package/MyManager
	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1383)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:668)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:635)
	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1489)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:420)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:390)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:511)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:503)
	at org.springframework.boot.context.TypeExcludeFilter.match(TypeExcludeFilter.java:65)
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(ClassPathScanningCandidateComponentProvider.java:492)
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:431)
	... 51 common frames omitted

How do I solve this issue?

ArrayIndexOutOfBoundsException

Hi, an ArrayIndexOutOfBoundsException will appear when I use an aspect from a jar and an Aspect from current maven module to weave another java class. It may sound not clear, so I make a demo.

[email protected]:chuanghou/spoon.git

please git clone it and then mvn clean compile , you will find

java.lang.ArrayIndexOutOfBoundsException: 1
[ERROR] at org.aspectj.weaver.bcel.BcelShadow.prepareForMungers(BcelShadow.java:379)
[ERROR] at org.aspectj.weaver.Shadow.implement(Shadow.java:546)
[ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.implement(BcelClassWeaver.java:3361)
[ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:499)
[ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:103)
[ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1707)
[ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1651)
[ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1418)
[ERROR] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1192)
[ERROR] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:510)
[ERROR] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueForWeaving(AjPipeliningCompilerAdapter.java:446)
[ERROR] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:431)
[ERROR] at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:104)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:943)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:576)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:476)
[ERROR] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:427)
[ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1096)
[ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:275)
[ERROR] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:188)
[ERROR] at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:103)
[ERROR] at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:47)

aspectj maven plugin does not weave classes if only -inpath option is used

When the plugin is configured to weave only the classes (as described in http://www.mojohaus.org/aspectj-maven-plugin/examples/weaveDirectories.html) and skipping the source compilation (by configuring empty <sources/>), aspectj maven plugin ignores weaving the classes and instead a WARNING is issued that there are no sources to compile. If ajc supports -inpath without specifying the source files, then why doesn't aspectj maven plugin support this? Shouldn't the warning be raised only if -inpath and <sources> are not specified?

[WARNING] invalid Class-Path header in manifest of jar file

I'm using aspectj-maven-plugin, version 1.10, to do "compile-time" weaving of my aspect data. I get the following warning messages:

[WARNING] invalid Class-Path header in manifest of jar file:
   ...\org\restlet\jee\org.restlet\2.3.0\org.restlet-2.3.0.jar
invalid Class-Path header in manifest of jar file:
    ...\org\restlet\jee\org.restlet.ext.servlet\2.3.0\org.restlet.ext.servlet-2.3.0.jar

This is a legitimate warning since those the JAR files do, in fact, contain manifests with an empty Class-Path header.

However, as far as I can tell, there is no way to disable that warning message (it's not controlled by the <Xlint> value). And I couldn't figure out how to exclude those (or other JAR files) from the process.

It's not a huge deal, but in general our build/deploy system can't have errors, and shouldn't have warnings. I need a way to get rid of that warning.

BTW -- a later version of the "org.restlet" jar has a corrected manifest file, but the associated "org.restlet.ext.server" jar does not, so the warning will persist.

java.lang.module.ResolutionException: Modules org.aspectj.weaver and org.aspectj.runtime export package org.aspectj.runtime.internal to module commons.net

Hi all,
as title I get this error when trying to run my app...

 <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${aspectj.version}</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectj.version}</version>
        </dependency>
----
<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.11</version>
                <configuration>
                    <complianceLevel>${java.version}</complianceLevel>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

my module-info.java contains this:
requires org.aspectj.runtime;

how can I solve it?

thanks

Java 17 support

hi guys do you have any plans to add support for java 17 (LTS)? thanks!

Randomly appearing RuntimeException key not found in wovenClassFile

Hi! I have a problem when sometimes my build fails with the following message:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.14.0:test-compile (default) on project core: AJC compiler errors:
[ERROR] abort ABORT -- (RuntimeException) key not found in wovenClassFile
[ERROR] key not found in wovenClassFile
[ERROR] java.lang.RuntimeException: key not found in wovenClassFile

On the next run the problem disappears but happens again randomly. The build is a part of an automatic pipeline so this problem is really annoying, googling does not give any clue, and I cannot reproduce it ad hoc. What can you advise, maybe to check or set some parameters in the plugin config?

Mvn clean compile fails with $missing$ method, mvn compile works fine

My compile fails when I run mvn clean compile, but not when I run mvn compile after.

Error message:

[ERROR] The method inRangePrivate(String, BiFunction<String,T,DynamicQuery>, T, BiFunction<String,T,DynamicQuery>, T) in the type DynamicQuery is not applicable for the arguments (String, this::$missing$, Comparable, BiFunction<String,T,DynamicQuery>, Comparable)
/opt/jenkins_home/workspace/Build/NOS3/Compile/app/src/main/java/no/tripletex/common/util/DynamicQuery.java:1031
return inRangePrivate(property,this::after, min, this::upIncludingTo, max);

Failing code:

public<T extends Comparable<T>> DynamicQuery inRangeInclusive(String property, T min, T max) {
		return inRangePrivate(property,this::after, min, this::upIncludingTo, max);
	}

public DynamicQuery after(String property, Comparable<?> comparable) {
		return comparable != null ? condition(property,GREATER_THAN_OR_EQUAL,comparable) : suceedCondition();
	}

public DynamicQuery upIncludingTo(String property, Comparable<?> comparable) {
		return comparable != null ? condition(property,LESS_THAN_OR_EQUAL,comparable) : suceedCondition();
	}

What I found interesting is that while the after method is $missing$, the very identical upIncludingTo, which is used in the same manner, is not.

I have tried aspectj versions 1.8.7-1.10.

To avoid the problem and make mvn clean compile successfull, I replace this::after with (x,y) -> after(x,y).

Is this project being maintained?

Hi, I would like to know if this project is being maintained, as I use this plugin in my projects. I see that the last commit in master is from May 31, 2018, and the last release is from January. After that, Java 10 and Java 11 where release. Even, aspjectj 1.9.2 was released, which has support for Java 11.

Absolute paths in builddef.lst make the builds non reproducible

aspectj-maven-plugin generates a builddef.lst file with the detailed options passed to AspectJ and this file is embedded in the final jar. The various paths appearing in this file are all absolute, which means someone else rebuilding a project using the plugin will be unable to reproduce a byte identical artifact (see https://reproducible-builds.org for why it matters).

I suggest using relative paths instead (or removing the file if it isn't important).

Please add me as a contributor to this project

Dear contributors/project owner.

What are the conditions for someone becoming a contributor to this project? This would include build, testing, pull request merging and plugin maintenance.

Regards,
Aleksander

Support for Java 14 & 16

Seems that java tools jar has been changed in latest versions of jvm. This plugin or one of it's dependencies tries to use it directly (by the path).
Getting the next error:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile (default) on project javatar: Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.11 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:14.0.2 at specified path /home/stanislav/.jabba/jdk/[email protected]/../lib/tools.jar -> [Help 1]

Re-introduce PlantUML

Background

In the AspectJ.dev fork, a while ago I managed to PlantUML incl. Graphviz running on all Java versions 8-16 and all operating systems (Windows, Linux, MacOS) used for CI builds. In a first step I had used two different plugins, one for older and one for more recent OS. Then I forked one of those not so well-maintained Maven plugins, fixing some things and publishing it on Maven Central with under group ID dev.aspectj. So one plugin works in all situations. The resulting UML file is embedded in the Maven site section about multi-module builds, while image gneration was removed from this repository on purpose, supposedly not providing any value. I disagree. The diagram is helpful.

Suggestion 1: use status quo from AspectJ.dev fork

I can prepare a PR, porting the build and CI workflow settings to this repository.

Advantages:

  • Immediate availability
  • The most recent Windows versions of PlantUML have a basic Graphviz version embedded, i.e. on Windows Graphviz does not need to be installed. If we would use Windows for Maven site generation, the loss of time due to Graphviz installation in the CI workflow would be zero.

Disadvantages:

  • On Linux and MacOS, Graphviz still needs to be installed. But we can skip the UML generation step in the CI workflows on those platforms.

Suggestion 2: switch to Java-based graph generation

The latest versions of PlantUML contain a new Java-based "jdot" engine called Sematana. I tested it with the UML diagram used by AspectJ Maven, the result looks very similar to the one generated by GraphViz. Only the layout is more dense with regard to spacing and resulting length of arrows. For me it looks acceptable, even though I like the GraphViz version a bit more.

Advantages:

  • We could generate diagrams on all OS platforms without GraphViz installation, speeding up the build
  • No need to add any time-consuming GraphViz installation steps to CI builds, not only on Windows but also on MacOS and Linux.

Disadvantages:

  • I would have to upgrade the PlantUML Maven plugin or at least override the PlantUML dependency in our POM. Both would work and be easy.
  • We would have to add a line !pragma layout smetana to the diagram source file. Also easy.

UML diagrams

If you want to compare, here are the two diagrams.

Graphviz

image

Smetana (Java-based)

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.