FATAL ERROR while compiling Project using Maven 2 - maven-2

I am new to Maven and starting moving my project to maven. I have created the following POM.
when i issue install command, it gives me FATAL ERROR.
I am using maven 2.2.1 version and JDK 1.5.
My POM is as follows:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<prerequisites>
<maven>2.2.1</maven>
</prerequisites>
<groupId>my.project.group</groupId>
<artifactId>my.artifact</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6.SEC01</version>
</dependency>
</dependencies>
</project>
Thanks for any help.

You are missing a mandatory tag from your project address structure groupId:artifactId:version
Put the following tag after ... with some version info (i.e. 1.x.x) and try.
<version>1.0.0</version>
Reference : http://maven.apache.org/pom.html

Related

How to change the qualifier in the file names of plugins and features

I am trying to rename my artifacts in the repository folder of my eclipse-repository module. At the moment they are auto generated like ...1.0.0.v20130315-1927.jar.
I haven't found any configuration parameter that works. I have tried to use the qualifier setting in the configuration (see tycho-p2-repository-plugin), but it doesn't work.
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>development.statTool</groupId>
<artifactId>Application</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>development.statTool</groupId>
<artifactId>development.statTool.p2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
<properties>
<tycho-version>0.16.0</tycho-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<qualifier>abcd</qualifier>
</configuration>
</plugin>
</plugins>
</build>
</project>
My solution is to use the tycho-packaging-plugin. Only "disadvantage" changing the build qualifier needs to rebuild all modules contained by the repository.
Here the part out of my parent pom.xml:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho.version}</version>
<dependencies>
<dependency>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-buildtimestamp-jgit</artifactId>
<version>${tycho-extras.version}</version>
</dependency>
</dependencies>
<configuration>
<strictBinIncludes>false</strictBinIncludes>
<format>'rev${rev}-'yyyyMMdd-HHmm</format>
</configuration>
</plugin>
try this:
mvn -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=13.3.0.1-SNAPSHOT
or simply search text "1.0.0-SNAPSHOT" and replace it with "13.3.0.1" using Actual Search and Replace tool.

maven-dependency-plugin, copy-dependencies: exclude some artifact ids and their dependencies

I need to copy just one dependency and all its transitive dependencies to a specified folder.
I know i can exclude artifacts with "excludeArtifactIds", but I also need to exclude the transitive dependencies of those artifacts, which, apparently "excludeArtifactIds" does not do.
Is there a way of doing this?
It appears that the Maven dependency plugin is not designed for this as they closed one request for this functionality as "WONTFIX" and another request has been OPEN since 2007.
However, you can use the maven-assembly-plugin to accomplish a similar task.
Below I've attached two sample POM's. The first is the dependent project (the one you wanted to copy) which itself has one dependency (for example). The second is the aggregate project where you are copying the other project and it's dependency to. I've also attached the assembly desriptor file that you'll use to copy the dependency.
Essentially, this will copy the first project and it's one dependency to the target/dest (configurable) directory of the second project.
First POM (dependent project): /sample-dependency/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>sample-dependency</groupId>
<artifactId>sample-dependency</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</project>
Second POM (aggregating project): /sample-dependency-aggregator/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>sample-dependency-aggregator</groupId>
<artifactId>sample-dependency-aggregator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sample-dependency-aggregator</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>aggregate</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>src/main/assembly/default.xml</descriptor>
</configuration>
</execution>
</executions>
<configuration>
<attach>false</attach>
<finalName>dest</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>sample-dependency</groupId>
<artifactId>sample-dependency</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Assembly descriptor : /sample-dependency-aggregator/src/main/assembly/default.xml
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd ">
<id>default</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<includes>
<include>sample-dependency:sample-dependency</include>
</includes>
<useTransitiveDependencies>true</useTransitiveDependencies>
<useTransitiveFiltering>true</useTransitiveFiltering>
</dependencySet>
</dependencySets>
</assembly>
How about setting excludeTransitive to true?

Maven Chronos JMeter plugin

Has any one used Chronos for JMeter + Maven plug-in. I am having tough time trying Maven JMeter plug-in and thought of giving it a try
I have following pom set up for chronos but when I execute "mvn verify " I encounter following exception -
#
Maven cannot calculate your build plan, given the following information:
Tasks:
- verify
Current project:
Group-Id: chronos1
Artifact-Id: chronos1
Version: 0.0.1-SNAPSHOT
From file: C:\SelNG\chronos\pom.xml
Error message: Failed to resolve plugin for mojo binding: org.codehaus.mojo:chronos-maven-plugin:1.0-SNAPSHOT:jmeter
Root error message: Unable to download the artifact from any repository
#
Is it because plug-in is not available in repo?
My pom is -
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>chronos1</groupId>
<artifactId>chronos1</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>chronos1</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<jmeter.home>C:/Program Files/jakarta-jmeter-2.4</jmeter.home>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>chronos-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<input>${basedir}/src/jmeter/EducationSSL.jmx</input>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>chronos-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</plugin>
</plugins>
</reporting>
Thanks
Tarun K
I don't have any particular experience with this plugin but for SNAPSHOT versions of codehaus plugins, you probably need to declare the codehaus snapshot repository:
<project>
...
<pluginRepositories>
<pluginRepository>
<id>snapshots.repository.codehaus.org</id>
<url>http://snapshots.repository.codehaus.org/</url>
</pluginRepository>
...
</pluginRepositories>
...
</project>

Maven: apply plugin only to one of several modules

I'm building my project using the following 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>build.local</groupId>
<artifactId>build-local</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<version>0-SNAPSHOT</version>
<description></description>
<inceptionYear>2009</inceptionYear>
<modules>
<module>module1</module>
<module>module2</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<executable>deploy.bat</executable>
<configuration>
</plugin>
</plugins>
</build>
</project>
The build works fine. The deployment using the plugin works as well. The only problem I have: maven calls deploy.bat twice, once for every module. However, I only need it executed once. How can I do that?
Move the < plugin >...< /plugin > directive in to the module1/pom.xml file.
You can just put the plugin in one of your modules.
Referencing this http://maven.apache.org/ref/2.2.1/maven-model/maven.html
...
...
set inherited value to false (default is true) and childs projects will not inherit the plugin.

compiling project with jdk1.5 using maven2

i managed to create my project structure using maven2.
but when am compiling my project using mvn install
getting error
generics are not supported in -source 1.3
googled to build my project using jdk1.5 and added build tag
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myProject</groupId>
<artifactId>project</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.myProject</groupId>
<artifactId>project</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugins>
</build>
</project>
but this is not working.
Any hints?
Add the maven-compiler-plugin to your build:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
There's an "easier" way to accomplish this, without having to paste the same snippet all over your modules. You can set up a reactor and then you refer to it from all the other modules, like this:
<parent>
<groupId>com.foo.bar</groupId>
<artifactId>reactor</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
In the pom file of your reactor you have to put this:
<packaging>pom</packaging>
To let maven know that it's not a jar/war, etc.
Hope it helps