I need to install a custom plugin (mojo) first and then execute the goal. I would want this to happen in one go but as of now using below code i am getting build errors. Not sure if i'm going right in below code so that i can install plugin first and then code inside mojo would get executed.
ParentProject:
<groupId>com.io</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Parent</name>
<description>ThisisParent</description>
<packaging>pom</packaging>
<modules>
<module>Child1Plugin</module>
<module>ChildFramework</module>
</modules>
Child1Plugin-pom.xml
<parent>
<groupId>com.io</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Child1Plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Child</name>
<description>ThisisChild</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
</plugin>
<plugin>
<groupId>com.parent.module</groupId>
<artifactId>ChildFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>mydata</goal>
</goals>
</execution>
</executions>
<configuration>
<scope>test</scope>
</configuration>
</plugin>
</plugins>
</build>
</project>
ChildFramework-pom.xml
<parent>
<groupId>com.io</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>ChildFramework</artifactId>
<packaging>maven-plugin</packaging>
<name>Childtwo</name>
<description>Thisischildtwo</description>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
</plugin>
<plugin>
<groupId>com.io</groupId>
<artifactId>ChildFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>mydata</goal>
</goals>
</execution>
</executions>
<configuration>
<scope>test</scope>
</configuration>
</plugin>
</plugins>
</build>
The below mojo is inside src/main/java folder of ChildFramework module.
#Mojo(name = "mydata", defaultPhase = LifecyclePhase.COMPILE)
public class Feat extends AbstractMojo {
#Override
public void execute() throws MojoExecutionException, MojoFailureException {
System.out.println("%%%%%%%%%%%%%%%%%%%%%% MyMOJO");
}
ChildFramework can't use itself as a plugin (because that's a circular dependency). I think the changes you need are these:
Child1Plugin: remove the ChildFramework plugin element
ChildFramework: change <packaging> to jar and change the <artifactId> of the plugin to Child1Plugin
move the mojo code from the ChildFramework module to the Child1Plugin module
Related
I have my Storm application (maven) project structured as follow:
parent-project/
├── pom.xml
├── storm-application/
└── pom.xml
├── utils/
└── pom.xml
I structured my pom.xml files as follow:
parent-project:pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>my.project</groupId>
<artifactId>parent-project</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>utils</module>
<module>storm-application</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
storm-application:pom.xml
<parent>
<groupId>my.project</groupId>
<artifactId>parent-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>my.project.parent-project</groupId>
<artifactId>storm-application</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>my.project.parent-project</groupId>
<artifactId>utils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> ...storm dependency... </dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
utils:pom.xml
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my.project</groupId>
<artifactId>parent-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>my.project.parent-project</groupId>
<artifactId>utils</artifactId>
<packaging>jar</packaging>
<dependencies>
... some project related dependencies ...
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
</build>
My objective would be to include the sibling module utilsin storm-application.
I need to include the module utils directly in the jar package of the storm-applicationmodule.
In fact, if I run the main function directly from IntelliJ it works, because it recognize the project structure, but if I try to deploy the application with Storm I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: my/project/parent-project/utils/MyClass
at my.project.parent-project.storm-application.MainClass.main(MainClass.java:116)
Caused by: java.lang.ClassNotFoundException: my.project.parent-project.utils.MyClass
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
I even tried to use the maven-assembly-plugin to include all the dependency in the package but I still get the same error.
Update
So what I was missing was that the assembly creates a second jar on the form name-version-jar-with-dependencies.
Plus, the storm dependency should be of <scope>provided</scope> otherwise it complains.
Still, I'm wondering if there would be an easier way to achieve this inter-module dependency.
I found a cleaner way to do so. Instead of using the assembly plugin, I use the shade plugin, so that the fat jar keeps the standard name.
Finally, this is the storm-application/pom.xml that, for me, works:
<parent>
<groupId>my.project</groupId>
<artifactId>parent-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>my.project.parent-project</groupId>
<artifactId>storm-application</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>my.project.parent-project</groupId>
<artifactId>utils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> ...storm dependency... </dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Actually i want to create a small "Hello WOrld"-like Example of a JavaSE-Application with Weld-SE, but it seems that there is a runtime error.
Here is my class:
package de.mycompany.weldapp;
import java.util.List;
import javax.enterprise.event.Observes;
import javax.inject.Singleton;
import org.jboss.weld.environment.se.bindings.Parameters;
import org.jboss.weld.environment.se.events.ContainerInitialized;
#Singleton
public class App
{
public void printHello(#Observes ContainerInitialized event, #Parameters List<String> parameters) {
System.out.println("Hello " + parameters.get(0));
}
}
An here is my pom.xml:
<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>
<groupId>de.mycompany</groupId>
<artifactId>weldapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>weldapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-shaded</artifactId>
<version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>de.mycompany.weldapp.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have installed Java JDK 1.8.0_151 and Maven 3.5.2.
The compile-process was successful, but when i execute the created jar-file in the target-directory, i will get the following error all the time:
A JNI error has occurred, plase check your installation and try again.
Exception in thread "main" java.lang.noClassDefFoundError: org/jboss/environment/se/events/ContainerInitialized
at java.lang.Class.getDeclaredMethods0(native Method)
...
Caused by : java.lang.ClassNotFoundException: org.jboss.weld.environment.se.events.ContainerInitialized
at java.net.URLCLassLoader.findClass(Unknown Source)
...
Is there anything that i did not mention or that i am doing wrong? Is there any dependency, that was not included?
I have installed Java, Maven and Eclipse again, but nothing helped.
Thanks a lot
Daniel
Since you're running in SE mode, you do not want to make any dependencies provided. So remove <scope>provided</scope> from your cdi-api dependency.
Edit: I reran your test, and realized what's happening for you. You're using the maven-jar-plugin to create your jAR. I'm assuming though you want to use the shade plugin to create an uber JAR. Here's an updated pom.xml you can use that seems to work (note that I also changed your main class to be the Weld start up class):
<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>
<groupId>de.mycompany</groupId>
<artifactId>weldapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>weldapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.jboss.weld.environment.se.StartMain</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The simplified setup of my project is as follows:
root
|--parent
|--service-1
|--service-2
|--service-aggregator
I need to assemble the 'service-1' & 'service-2' modules in 'service-aggregator'. I am using maven-assembly-plugin for the same and it works fine, however I foresee a maintenance issue wherein whenever the version of either of service-1 or service-2 will change, I will need to update the service-aggregator pom.xml also.
Hence, I am looking for a way to prevent writing the version of the service-1 / -2 in the service-aggregator pom.xml i.e. I just need service-aggregator to simply pick the latest version of service-1 / -2.
I have gone through the examples provided in maven-assembly-plugin documentation but those contain the version being mentioned in the assembly module (service-aggregator in my example).
Please let me know if any detail is missing & I will add it.
Here is the key contents of service-aggregator pom.xml:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.company.project</groupId>
<artifactId>parent</artifactId>
<version>0.0.1</version>
</parent>
<groupId>com.company.project.parent</groupId>
<artifactId>service-aggregator</artifactId>
<name>service-aggregator</name>
<dependencies>
<dependency>
<groupId>com.company.project.parent</groupId>
<artifactId>service-1</artifactId>
<version>0.0.1</version> <!-- this is the line troubling me -->
</dependency>
<dependency>
<groupId>com.company.project.parent</groupId>
<artifactId>service-2</artifactId>
<version>0.0.1</version> <!-- this is the line troubling me -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<skipAssembly>${skip.assembly}</skipAssembly>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<skip.assembly>false</skip.assembly>
</properties>
The best thing is to use properties like this:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.company.project</groupId>
<artifactId>parent</artifactId>
<version>0.0.1</version>
</parent>
<groupId>com.company.project.parent</groupId>
<artifactId>service-aggregator</artifactId>
<name>service-aggregator</name>
<dependencies>
<dependency>
<groupId>com.company.project.parent</groupId>
<artifactId>service-1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.company.project.parent</groupId>
<artifactId>service-2</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<skipAssembly>${skip.assembly}</skipAssembly>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I am working on a Spring Boot project using IntelliJ IDEA and everything works fine. I have no problem running and testing the application inside IntelliJ IDEA. It runs perfectly whether I configure it as an "Application" or "Spring Boot" (from the Run/Edit Configuration menu)
However, problems occur after I created an artifact and try to run it using "java -jar AppName.jar". It spews out errors like:
Could not find key 'spring.profiles.active' in any property source
and
Caused by: java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
I extracted the jar file and the spring.factories, etc. files are indeed inside the folder "META-INF".
I suspect the cause of the problem is the class path. When I run it from within IntelliJ IDEA, I noticed that it is set to module in "Use Classpath of Module". However, in the artifact, I could not get the settings right.
What do you think is the cause of the problem? I think it is the class path. If not, what else can it be? Please help!
I'm providing my pom.xml file here:
<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.kurento.tutorial</groupId>
<artifactId>kurento-tutorial</artifactId>
<version>6.6.1-SNAPSHOT</version>
</parent>
<artifactId>WebRTCLiveApp</artifactId>
<packaging>jar</packaging>
<name>WebRTCLiveApp</name>
<description>Company Live App</description>
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<organization>
<name>Kurento</name>
<url>http://www.kurento.org</url>
</organization>
<developers>
<developer>
<id>kurento.org</id>
<name>-kurento.org Community</name>
<organization>Kurento.org</organization>
<organizationUrl>http://www.kurento.org</organizationUrl>
</developer>
</developers>
<properties>
<!-- Main class -->
<start-class>com.company.live.webrtc.WebRTCLiveApp</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
</dependency>
<!-- Kurento -->
<dependency>
<groupId>org.kurento</groupId>
<artifactId>kurento-client</artifactId>
</dependency>
<dependency>
<groupId>org.kurento</groupId>
<artifactId>kurento-utils-js</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>draggabilly</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>demo-console</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>adapter.js</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>jquery</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>ekko-lightbox</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
<classifier>exec</classifier>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>banner.txt</include>
</includes>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>src/assembly/bin.xml</descriptor>
<finalName>${project.artifactId}-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>no-assembly</id>
</profile>
</profiles>
I have search and tried other examples/solutions and none worked.
Please help! Thanks!
Problem is resolved.
In the IntelliJ Artifacts Create JAR from Modules dialog box, I have to
choose "Copy to output directory and link via manifest" option
make sure the META-INF/MANIFEST.INF file is set to "src/main/resources"
Everything is working now (after spending the entire afternoon).
If it is an maven project, it is recommended to add pom.xml
<packaging>war</packaging>
I am trying get the AspectJ weaving working in a simple Maven project, and not sure where it is going wrong :
when I run the code using "mvn exec:java", I dont see expected output.
I am sure the code is working, because I tried the same in STS, where it works fine. I just wanted to get the AspectJ working in a Maven project.
Any hints to how to debug this kind of issues will be much appreciated.
<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>
<groupId>com.aop</groupId>
<artifactId>aop1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>aop1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version> <!-- specify your version -->
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</execution>
</executions>
<configuration>
<outxml>true</outxml>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<mainClass>com.aop.aop1.App</mainClass>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Aspect file in same folder as code :
package com.aop.aop1;
public aspect aspect {
pointcut secureAccess()
: execution(* *.foo(..));
before() : secureAccess() {
System.out.println("BEHOLD the power of AOP !!!");
}
}
Java file :
package com.aop.aop1;
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
foo();
}
public static void foo() {
System.out.println(" IN FOO.");
}
}
There are several problems with your configuration:
The aspect should be named Aspect with a capital "A" instead of aspect which is a reserved keyword.
The POM is missing a closing </project> tag.
The POM has a <pluginManagement> section, but no separate <plugins> section, i.e. you provide defaults for your plugins, but do not actually declare that you want to use them. So either you use a stand-alone <plugins> section without <pluginManagement> or you redeclare the plugins in an additional <plugins> section.
The aspectj-maven-plugin needs a <version>. You forgot to specify one.
The aspectj-maven-plugin also needs a <complianceLevel> configuration.
You use compile-time weaving, so you do not need the <outxml> setting. It is only needed for load-time weaving.
The aspectjrt dependency needs at least version 1.7.4 in order to be compatible with the version used in aspectj-maven-plugin 1.6 by default in order to compile your sources.
In addition to that, I recommend to use newer versions of Maven plugins and dependencies such as JUnit and exec-maven-plugin if you do not have any compelling reasons to use older ones. I also recommend to use the latest AspectJ version 1.8.2 and also specify to use that one internally in aspectj-maven-plugin.
Working pom.xml with minimal changes:
<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>
<groupId>com.aop</groupId>
<artifactId>aop1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>aop1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<complianceLevel>1.7</complianceLevel>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<mainClass>com.aop.aop1.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
Working pom.xml with recommended changes:
<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>
<groupId>com.aop</groupId>
<artifactId>aop1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AOP Sample</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<aspectj.version>1.8.2</aspectj.version>
<java.source-target.version>1.7</java.source-target.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.source-target.version}</source>
<target>${java.source-target.version}</target>
<!-- IMPORTANT -->
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>${java.source-target.version}</source>
<target>${java.source-target.version}</target>
<Xlint>ignore</Xlint>
<complianceLevel>${java.source-target.version}</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<!-- IMPORTANT -->
<phase>process-sources</phase>
<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>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<mainClass>com.aop.aop1.App</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.dstovall</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<onejarVersion>0.96</onejarVersion>
<mainClass>com.aop.aop1.App</mainClass>
<attachToBuild>true</attachToBuild>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>OneJAR googlecode.com</id>
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
<!--<scope>runtime</scope>-->
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
BTW, the onejar-maven-plugin is just a goodie which I like to use in order to build a stand-alone uber JAR (a.k.a. fat JAR) containing everything you need to run the software, i.e. your classes/aspects plus the AspectJ runtime. You can just run the program with
java -jar aop1-0.0.1-SNAPSHOT.one-jar.jar
The output should be similar to mvn exec:java just without the Maven stuff:
Hello World!
BEHOLD the power of AOP !!!
IN FOO.