Ant in Ant in Maven: How to add optional tasks? - ant

I'm trying to run junitreport task in Ant in Ant in Maven:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions combine.children="append">
<execution>
<id>reporting</id>
<phase>compile</phase><!--post-integration-test-->
<goals><goal>run</goal></goals>
<configuration>
<target>
<ant antfile="${basedir}/../tools/report/buildReports.xml">
<!--<property name="reports.dest.dir" value=""/>-->
<target name="reports"/>
</ant>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-antunit</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b2</version>
</dependency>
</dependencies>
</plugin>
However, I am getting this:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (reporting) on project jboss-as-testsuite-integration: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /home/ondra/work/AS-7/ozizka-as7/testsuite/tools/report/buildReports.xml:42: Problem: failed to create task or type junitreport
[ERROR] Cause: the class org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator was not found.
[ERROR] This looks like one of Ant's optional components.
[ERROR] Action: Check that the appropriate optional JAR exists in
[ERROR] -ANT_HOME/lib
[ERROR] -the IDE Ant configuration dialogs
What should I add?

Oops. The class really wasn't present - it was in ant-junit. So the needed dependency is:
<dependency>
<groupId>ant</groupId>
<artifactId>ant-junit</artifactId>
<version>1.6.5</version>
</dependency>

Related

Jenkins build error with message Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project in Jenkins build with error message
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # projectname---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 21 source files to C:\Program Files (x86)\Jenkins\workspace\projectname\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.958 s
[INFO] Finished at: 2020-07-30T14:53:55+05:45
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Projectname: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\projectname\pom.xml to projectnamegroup/projectname/0.0.1-SNAPSHOT/projectname-0.0.1-SNAPSHOT.pom
[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/MojoFailureException
channel stopped
Finished: FAILURE
POM Details
<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>projectnameworkgroup</groupId>
<artifactId>projectnameframework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>projecnameautomation</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>MYtestNG.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.sikuli/sikuli-api -->
<dependency>
<groupId>org.sikuli</groupId>
<artifactId>sikuli-api</artifactId>
<version>1.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.assertthat/selenium-shutterbug -->
<dependency>
<groupId>com.assertthat</groupId>
<artifactId>selenium-shutterbug</artifactId>
<version>0.9.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.opencsv/opencsv -->
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/ -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mvntestngrepo.read</id>
<url>https://github.com/abc/projectname</url>
</repository>
</repositories>
</project>
Looking for solution. Please give your valuable solution.Thank you
Used version Details
Looks like maven-compiler-plugin has default 5 source and target options.
You must set explicit values to that options.
Something like this:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

Compile error when packaging maven project

I'm using datanucleus/mongodb. I recently converted my dynamic web project to maven in Eclipse because I wanted to use the maven buildnumber plugin. However I am just trying to get it to work now in maven. I do not have issues getting my simple projects to compile and run with Eclipse.
My projects are divided into 3 - main, LibA, LibAA.
Main relies/uses stuff in LibA (or directly from LibAA as well) and LibA relies/uses stuff from LibAA. LibAA doesn't know of other projects.
Example:
LibAA - DObject data class file
LibA - DRemote inherits from DObject
Main - DStaff inherits from DObject
That's how I set the dependencies in Pom xml.
So the issue here is that whenever I tried mvn clean package/install in Main project, I always get symbol not found for the data classes files that inherits from LibAA.
Datanucleus query says DStaff has been renamed to QDStaff, then later further down the process, it says DObject could not be found. Is it because DObject has been internally renamed to QDObject as well, hence it is too late to find them?
2 questions.
1: why is my data files being renamed. I.e a Q character is prependded
2: why am I still getting the symbol not found error despite calling datanucleus enhancer and correctly setting the dependencies? I have no problems with standalone data class files but only those that inherits DObject is the LibAA project.
I seems to have been missing something..
Any insights is appreciated.
edit: added a example partial compile log (with most of the similar errors/log removed)
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # MyMainProject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 591 source files to /Users/rhs/gitnew/MyMainProject/MyMainProject/target/classes
DataNucleus : JDO Query - com.rhs.kms.data.DServerSettingRecord -> com.rhs.kms.data.QDServerSettingRecord
DataNucleus : JDO Query - com.rhs.kms.data.account.DStaffAccount -> com.rhs.kms.data.account.QDStaffAccount
DataNucleus : JDO Query - com.rhs.kms.data.DMenu -> com.rhs.kms.data.QDMenu
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/rhs/gitnew/MyMainProject/MyMainProject/target/generated-sources/annotations/com/rhs/data/account/QDStaffAccount.java:[6,55] cannot find symbol
symbol: class QAuthAccount
location: package com.rhslib.account
[ERROR] /Users/rhs/gitnew/MyMainProject/MyMainProject/target/generated-sources/annotations/com/rhs/data/QDTableOrderingSettings.java:[6,65] cannot find symbol
symbol: class QDObject
location: package com.rhslib.database
[INFO] 10 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.056 s
[INFO] Finished at: 2015-09-14T16:25:40+08:00
[INFO] Final Memory: 25M/300M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project MyMainProject: Compilation failure: Compilation failure:
[ERROR] /Users/rhs/gitnew/MyMainProject/MyMainProject/target/generated-sources/annotations/com/rhs/data/account/QDStaffAccount.java:[6,55] cannot find symbol
[ERROR] symbol: class QAuthAccount
[ERROR] location: package com.rhslib.account
[ERROR] /Users/rhs/gitnew/MyMainProject/MyMainProject/target/generated-sources/annotations/com/rhs/kms/data/QMenu.java:[6,47] cannot find symbol
[ERROR] symbol: class QDObject
[ERROR] location: package com.rhslib.database
edit2: This is an example of a file where it broke (taken from target/generated-sources/annotations/*)
package com.rhs.data.ARM;
import javax.jdo.query.*;
import org.datanucleus.api.jdo.query.*;
public class QDAccountApp extends com.rhslib.database.QDObject //error starts from QDObject
To iterate, DAccountApp exists in the main project. Main project depends on a lib named KMSLib, and KMSLib depends on a project named RHSLib. I have tried making Main project depend directly with both projects but to no avail.
edit3: attached my pom.xml from my Main project
<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>MainProject</groupId>
<artifactId>MainProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>MainProject</name>
<properties>
<maven.build.timestamp.format>yyyy/MM/dd hh:mm:ss a</maven.build.timestamp.format>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<encoding>UTF-8</encoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>4.0.1</version>
<configuration>
<api>JDO</api>
<props>${basedir}/datanucleus.properties</props>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifest>
<addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>KMSLib</groupId>
<artifactId>KMSLib</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-manifests</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.0-b01</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>oss.sonatype.org</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
<repository>
<id>DN_M2_Repo</id>
<name>DataNucleus Repository</name>
<url>http://www.datanucleus.org/downloads/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>DataNucleus_2</id>
<url>http://www.datanucleus.org/downloads/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
edit4: attached my .classpath file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 8.x Runtime">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

possible bug in Maven + plexus + eclipse compiler on case sensitive packages?

I encounter a very strange problem with Maven and Eclipse compiler.
While in Eclipse+m2eclipse, I have no problem compiling a small project (archetype quick start) with the following single class.
package test.test;
import com.Ostermiller.util.CSVParser;
public class TestCaseSensitive {
CSVParser csvParser;
}
Ostermiller utils is added to pom.xml. Eclipse Kepler compiles the project.
Next, mvn compile works out-of-the-box.
Now the issue, I switch to compiler 3.1 and asks for Eclipse compiler (to be able to handle same compilation issues in console mode as well as IDE mode). This is the POM :
<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>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</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.ostermiller</groupId>
<artifactId>utils</artifactId>
<version>1.07.00</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerId>eclipse</compilerId>
<source>1.7</source>
<target>1.7</target>
<optimize>true</optimize>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<fork>false</fork>
<compilerArgument>-err:nullAnnot,null</compilerArgument>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
And now here is the result :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test: Compilation failure: Compilation failure:
[ERROR] /home/me/workspaces/4/3/ws/test/src/main/java/test/test/TestCaseSensitive.java:[3] The import com.Ostermiller cannot be resolved
[ERROR] /home/me/workspaces/4/3/ws/test/src/main/java/test/test/TestCaseSensitive.java:[7] CSVParser cannot be resolved to a type
The package com.Ostermiller exists (it compiles in maven default compiler as well in Eclipse IDE), but not after switching to eclipse compiler.
Please note that the reported error path is also wrong :
[ERROR] /home/me/workspaces/4/3/ws/test/src/main/java/...
should be
[ERROR] /home/me/workspaces/4.3/ws/test/src/main/java/...
Has someone an idea? Where shall the potential bug be reported?
Have you tried using the jdt compiler provided by tycho?
See http://wiki.eclipse.org/Tycho/FAQ#Can_I_use_the_Tycho_compiler_support_in_non-OSGi_projects.2C_too.3F
That'd give you :
<plugin>
<!-- Use compiler plugin with tycho as the adapter to the JDT compiler. -->
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>jdt</compilerId>
<source>1.7</source>
<target>1.7</target>
<optimize>true</optimize>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<fork>false</fork>
<compilerArgument>-err:nullAnnot,null</compilerArgument>
</configuration>
<dependencies>
<!-- This dependency provides the implementation of compiler "jdt": -->
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-jdt</artifactId>
<version>${tycho-version}</version>
</dependency>
</dependencies>
</plugin>
Currently tycho-version=0.18.0

Maven Open JPA Plugin Enhance: Seems to be working but It did not enhance my entity

When I compiled my Maven Project it says that my entity is enhanced. However when I start a database connection through EntityManagerFactory, Error happend on the code here: em = factory.createEntityManager(); I believe that I had followed all the steps in the net.. however I encountered this error. Please help.. Any advice regarding this? Thank you very much.
Error part of the code that causes the error.
factory = Persistence.createEntityManagerFactory("LotMovementPU");
em = factory.createEntityManager();
Tihs is the logs when compilied.
nothing to compile - all classes are up to date
[openjpa:enhance]
52 LotMovementPU INFO [main] openjpa.Tool - Enhancer running on type "class lotmovement.business.entity.UserProfile".
[resources:testResources]
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\Users\god-gavedmework\Documents\NetBeansProjects\lotmovementMaven\src\test\resources
[compiler:testCompile]
No sources to compile
[surefire:test]
No tests to run.
Surefire report directory: C:\Users\god-gavedmework\Documents\NetBeansProjects\lotmovementMaven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[war:war]
Packaging webapp
Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 8.386s
Finished at: Thu Nov 29 14:21:58 NZDT 2012
Final Memory: 22M/437M
------------------------------------------------------------------------
NetBeans: Deploying on Apache Tomcat 7.0.27.0
profile mode: false
debug mode: true
force redeploy: true
Error when step to em.factory.createEntityManager();
<openjpa-2.2.0-r422266:1244990 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
lotmovement.business.entity.UserProfile".
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>com.mycompany</groupId>
<artifactId>LotMovement</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>LotMovement</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
</properties>
<repositories>
<repository>
<id>JBoss Repo</id>
<url>http://repository.jboss.com/maven2</url>
<name>JBoss Repo</name>
</repository>
<repository>
<id>ibiblio mirror</id>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</repository>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<url>http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo</url>
<id>eclipselink</id>
<layout>default</layout>
<name>Repository for library Library[eclipselink]</name>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.3.4</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<!-- set the version to be the same as the level in your runtime -->
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<!-- set the version to be the same as the level in your runtime -->
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
<!-- Struts 2 + Spring plugins -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.3.7</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.9.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.9.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbynet</artifactId>
<version>10.9.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>10.9.1.0</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory> src/main/java </directory>
<includes>
<include> **/*.xml </include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<includes>lotmovement/business/entity/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<!-- Pass additional properties to the Plugin here -->
<toolProperties>
<property>
<name>directory</name>
<value>otherdirectoryvalue</value>
</property>
</toolProperties>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="LotMovementPU" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>openjpa</jta-data-source>
<class>lotmovement.business.entity.UserProfile</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/sample"/>
<property name="javax.persistence.jdbc.password" value="app"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.user" value="app"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
</persistence>
On the ANT style of building this, This is what is found in the BUILD.XML Maybe my enhancer did not post compile enhance it? if yes, how can you do a post compile enhance in maven?
build.xml to enhance entity in ant.
<target name="-post-compile">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
<echo message="begin openJPAC"/>
<path id="openjpa.path.id">
<pathelement location="${build.classes.dir}"/>
<!-- Adding the OpenJPA jars into the classpath -->
<fileset dir="D:\openjpa\apache-openjpa-2.2.0\" includes="*.jar"/>
<!-- or if you create a OpenJPA Library you can use that instead -->
<!--<pathelement path="${libs.OpenJPA.classpath}"/>-->
</path>
<taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask">
<classpath refid="openjpa.path.id"/>
</taskdef>
<openjpac>
<classpath refid="openjpa.path.id"/>
</openjpac>
<echo message="end openJPAC"/>
I found the solution. I removed the plugin "openjpa-maven-plugin" and replace it with this (please see plugin below.) in the POM.XML -- Plugin element. When you compile it, you will see this message below. Please see the compile message. By the way, I am using Netbeans 7.2.1, Maven and struts2-spring plugin.
Compile message.
[antrun:run]
Executing tasks
[java] 63 LotMovementPU INFO [main] openjpa.Tool - Enhancer running on type "lotmovement.business.entity.UserProfile".
Executed tasks
POM.xml
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<configuration>
<tasks>
<java classname="org.apache.openjpa.enhance.PCEnhancer"
classpathref="maven.runtime.classpath"
dir="target/classes" fork="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

Maven antrun with sequential ant-contrib fails to run

We have a special routine to explode files in a subfolder into extensions, which will be copied and jared into single extension files. For this special approach I wanted to use the maven-antrun-plugin, for the sequential iteration and jar packaging through the dirset, we need the library ant-contrib.
The upcoming plugin configuration fails with an error. What did I misconfigured? Thank you.
Plugin configuration
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<for param="extension">
<path>
<dirset dir="${basedir}/src/main/webapp/WEB-INF/resources/extensions/">
<include name="*" />
</dirset>
</path>
<sequential>
<basename property="extension.name" file="${extension}" />
<echo message="Creating JAR for extension '${extension.name}'." />
<jar destfile="${basedir}/target/extension-${extension.name}-1.0.0.jar">
<zipfileset dir="${extension}" prefix="WEB-INF/resources/extensions/${extension.name}/">
<include name="**/*" />
</zipfileset>
</jar>
</sequential>
</for>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
Error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project extension-platform: An Ant BuildException has occured: Problem: failed to create task or type for
[ERROR] Cause: The name is undefined.
[ERROR] Action: Check the spelling.
[ERROR] Action: Check that any custom tasks/types have been declared.
[ERROR] Action: Check that any <presetdef>/<macrodef> declarations have taken place.
[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]
[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/MojoExecutionException
Therefore I wasted at least one hour to find the error a little hint below ...
I use maven3 and the rest as described above, BUT I have to use maven.dependency.classpath
instead of maven.plugin.classpath! Otherwise maven won't find the contrib tasks. Hope this helps anybody.
It looks like you're missing the taskdef that's needed to declare the ant-contrib tasks, so that Ant knows about them, hence this part of the error message:
Problem: failed to create task or type for
(It would perhaps be a little clearer if the failed task - 'for' - were quoted.)
One way to add the taskdef is to insert it immediately prior to the for loop:
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpathref="maven.plugin.classpath" />
<for param="extension">
...
After wasting 2 hours and reading too many answers, this is what I need to check
http://www.thinkplexx.com/learn/howto/maven2/plugins/could-not-load-definitions-from-resource-antlib-xml-understanding-the-problem-and-fix-worklow
I printed all the maven classpaths using this
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
and checked which classpath contains antrib jar file. So I changed classpathhref to maven.runtime.classpath from maven.plugin.classpath
. So my taskdef is
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.runtime.classpath" />
and the dependencies
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
I too wasted several hours on this one, because antcontrib for task could not be found.
Finally, I found out that for task in not defined in antcontrib.properties, but in antlib.xml!
antcontrib.properties is a pre ant 1.6 way of doing things – the modern way is to use antlib.xml.
So, this is a maven 3.5, ant 1.8, working example:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<execution>
<id>deploy_to_distrib_folder</id>
<phase>package</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<macrodef name="deploy_extra_dir">
<attribute name="dir" />
<sequential>
<basename property="basename" file="#{dir}" />
<sync todir="${outputDir}/${basename}">
<fileset dir="#{dir}" />
</sync>
<var name="basename" unset="true" />
</sequential>
</macrodef>
<for param="dir">
<path>
<dirset dir="${project.build.directory}/maven-shared-archive-resources" includes="*" />
</path>
<sequential>
<deploy_extra_dir dir="#{dir}" />
</sequential>
</for>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</plugin>
Hope this helps!

Resources