aspectj-maven-plugin

Used in 2 components

Overview

Description

Handles AspectJ usage within Maven. Functionality provided is: weaving of aspects (or existing aspects from libraries) with the test and/or main classes, weaving of pre-existing jars and ajdoc reporting.

Snippets

<dependency>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.15.0</version>
</dependency>

Maven POM File

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>mojo-parent</artifactId>
    <version>77</version>
  </parent>

  <artifactId>aspectj-maven-plugin</artifactId>
  <version>1.15.0</version>
  <packaging>maven-plugin</packaging>

  <name>Mojo's AspectJ Maven Plugin</name>
  <description>
        Handles AspectJ usage within Maven.
        Functionality provided is: weaving of aspects (or existing aspects from libraries) with the
        test and/or main classes, weaving of pre-existing jars and ajdoc reporting.
  </description>
  <inceptionYear>2005</inceptionYear>
  <properties>
    <aspectjVersion>1.9.7</aspectjVersion>
    <doxiaVersion>1.12.0</doxiaVersion>
    <doxiaSitetoolsVersion>1.11.1</doxiaSitetoolsVersion>
    <mojo.java.target>8</mojo.java.target> <!-- aspectJ &gt; 1.8.13 is JDK 1.8 minimum -->
    <project.build.outputTimestamp>2023-12-12T02:46:31Z</project.build.outputTimestamp>
    <!-- work around until it is correctly fixed at top parent -->
    <scmpublish.content>${project.build.directory}/staging/aspectj-maven-plugin</scmpublish.content>
  </properties>

  <prerequisites>
    <maven>${mavenVersion}</maven>
  </prerequisites>

  <issueManagement>
    <system>GitHub</system>
    <url>https://github.com/mojohaus/aspectj-maven-plugin/issues/</url>
  </issueManagement>

  <scm>
    <connection>scm:git:https://github.com/mojohaus/aspectj-maven-plugin.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/mojohaus/aspectj-maven-plugin.git</developerConnection>
    <url>https://github.com/mojohaus/aspectj-maven-plugin</url>
    <tag>aspectj-maven-plugin-1.15.0</tag>
  </scm>

  <developers>
    <developer>
      <id>kaare</id>
      <name>Kaare Nilsen</name>
      <email>kaare.nilsen@gmail.com</email>
      <organization>Arktekk</organization>
      <organizationUrl>http://arktekk.no</organizationUrl>
      <roles>
        <role>Java Developer</role>
      </roles>
      <timezone>+1</timezone>
    </developer>
    <developer>
      <name>Lennart Jörelid</name>
      <email>lj@jguru.se</email>
      <organization>jGuru Europe AB</organization>
      <roles>
        <role>Java Developer</role>
      </roles>
      <timezone>+1</timezone>
    </developer>
  </developers>
  <contributors>
    <contributor>
      <name>Thor Age Eldby</name>
      <email>tel@objectnet.no</email>
      <roles>
        <role>Java Developer</role>
      </roles>
      <timezone>+1</timezone>
    </contributor>
    <contributor>
      <name>David J. M. Karlsen</name>
      <email>david@davidkarlsen.com</email>
      <organization>davidkarlsen.com</organization>
      <organizationUrl>http://www.davidkarlsen.com</organizationUrl>
      <roles>
        <role>Java Developer</role>
      </roles>
      <timezone>+1</timezone>
    </contributor>
    <contributor>
      <name>Marvin Froeder</name>
      <email>velo.br@gmail.com</email>
      <timezone>-3</timezone>
    </contributor>
    <contributor>
      <name>Krzysztof Debski</name>
      <email>kdebski85@gmail.com</email>
      <timezone>+1</timezone>
    </contributor>
  </contributors>

  <dependencies>
    <!-- Maven core -->
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-core</artifactId>
      <version>${mavenVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-model</artifactId>
      <version>${mavenVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-artifact</artifactId>
      <version>${mavenVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>${mavenVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <scope>provided</scope><!-- annotations are needed only to build the plugin -->
    </dependency>
    <!-- Other -->
    <!-- see: https://cwiki.apache.org/confluence/display/MAVEN/Plugin+migration+to+Maven3+dependencies -->
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-compat</artifactId>
      <version>${mavenVersion}</version>
      <scope>provided</scope>
    </dependency>

    <!-- Reporting -->
    <dependency>
      <groupId>org.apache.maven.reporting</groupId>
      <artifactId>maven-reporting-api</artifactId>
      <version>3.1.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.doxia</groupId>
      <artifactId>doxia-sink-api</artifactId>
      <version>${doxiaVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.doxia</groupId>
      <artifactId>doxia-site-renderer</artifactId>
      <version>${doxiaSitetoolsVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.reporting</groupId>
      <artifactId>maven-reporting-impl</artifactId>
      <version>3.0.0</version>
    </dependency>

    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjtools</artifactId>
      <version>${aspectjVersion}</version>
    </dependency>
    <!--
        This is required to make the ajdoc tool work properly.
        When generating the AspectJ site documentation, the following debug statement is emitted onto the log:

        [DEBUG] Running : ajdoc  -classpath [... a long classpath follows ...]
        ajdoc requires a JDK 1.4 or later tools jar - exiting
    -->

    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>4.0.0</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-xml</artifactId>
      <!-- To keep compatibility with Maven 3.x use 3.x -->
      <version>3.0.0</version>
    </dependency>

    <!-- Test -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugin-testing</groupId>
      <artifactId>maven-plugin-testing-harness</artifactId>
      <version>3.3.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-plugin-plugin</artifactId>
          <configuration>
            <!-- see: https://github.com/apache/maven-plugin-tools/pull/11 -->
            <mojoDependencies>org.codehaus.mojo:aspectj-maven-plugin</mojoDependencies>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <detectLinks>false</detectLinks>
            <detectJavaApiLink>false</detectJavaApiLink>
            <detectOfflineLinks>false</detectOfflineLinks>
            <failOnWarnings>false</failOnWarnings>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.4.1</version>
        <executions>
          <execution>
            <id>enforce-bytecode-version</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <enforceBytecodeVersion>
                  <maxJdkVersion>${mojo.java.target}</maxJdkVersion>
                  <excludes>
                    <exclude>com.sun:tools</exclude>
                  </excludes>
                </enforceBytecodeVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.7.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>false</skip>
          <excludes>
            <exclude>**/test-project/**/*.java</exclude>
            <exclude>**/parent-child-test-project/**/*.java</exclude>
            <exclude>**/AbstractAjcMojoTest.java</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>l10n-maven-plugin</artifactId>
        <version>1.0.0</version>
        <configuration>
          <locales>
            <locale>nl</locale>
            <locale>sv</locale>
          </locales>
        </configuration>
      </plugin>
    </plugins>
  </reporting>

  <profiles>
    <!--
      AspectJ compilation requires that tools.jar (or its equivalent for some JDKs) is found on the classpath.
      The profiles named [something]toolsJar-profile define the systemPath for the tools.jar dependency
      by overriding the dummy systemPath from the dependencyManagement section.

      CAVEAT: Setting the systemPath it via a profile-dependent property like in earlier plugin versions
      does *not* work when the compiled plugin is used from Eclipse because properties are incorrectly merged
      by Eclipse, leading to problems ever since the 'java8' profile was introduced here because it also
      defines a property.
    -->

    <profile>
      <id>tools-jar</id>
      <activation>
        <jdk>1.8</jdk> <!-- activate only on JDK8, as 8 is minimum version to run aspectj on-->
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>1.8</version>
          <scope>system</scope>
          <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>docs</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>default-jar-no-fork</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
              <failOnError>true</failOnError>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>run-its</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>install</goal>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <projectsDirectory>src/it</projectsDirectory>
              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
              <postBuildHookScript>verify</postBuildHookScript>
              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
              <goals>
                <goal>clean</goal>
                <goal>test</goal>
              </goals>
              <settingsFile>src/it/settings.xml</settingsFile>
              <debug>true</debug>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>