Maven bundle packaging problem, known as MNG-4338 - apache

I'm having trouble with the maven-bundle-plugin:
I want to deploy my project as a osgi bundle, wherefore I use the packaging as bundle.
But it seems that the pom does not know a packaging as a bundle. Here you can see my pom.xml:
<project ...>...
<packaging>bundle</packaging>
<version>1.0.0</version>
<name>Simple CXF project using spring configuration</name>
<properties>
<cxf-version>2.4.2</cxf-version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.5</version>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>demo.hw.server</Export-Package>
<Bundle-Activator>demo.hw.server.Activator</Bundle-Activator>
<Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
</instructions>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
</project>
They say, this bug has already been fixed (http://jira.codehaus.org/browse/MNG-4338), but to me it seems it hasn't. Has anyone encountered this problem before and found a solution?
The Error message is like this:
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.talend.liugang.cxf:java_first_jaxws:1.0.0 (C:\Users\Andreas\workspace\java_first_jaxws\pom.xml) has 1 error
[ERROR] Unknown packaging: bundle # line 7, column 13
[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/ProjectBuildingException
Best regards,
saen

Given your pom example above, you should just move the maven-bundle-plugin outside of the <pluginManagement> node. <pluginManagement> is normally used for inheritance purposes in parent poms. The bundle packaging type is provided by the maven-bundle-plugin (which is why you need <extensions>true</extensions>), so this plugin is required to be outside <pluginManagement> in this case.
<project ...>...
<packaging>bundle</packaging>
<version>1.0.0</version>
<name>Simple CXF project using spring configuration</name>
<properties>
<cxf-version>2.4.2</cxf-version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.5</version>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>demo.hw.server</Export-Package>
<Bundle-Activator>demo.hw.server.Activator</Bundle-Activator>
<Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
</project>

Yeap, the issue is that <groupId>org.apache.felix</groupId> needs to be outside of the <pluginManagement>.

I see a similar issue. It occurs to me that it happens when the group id ends like the artifact id starts. I try to bundle something like that:
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api.plugin</artifactId>
The slf4j from the artifact id is deleted at it ends up like: org.slf4j.api.plugin in the Manifest as symbolic name.

Related

When running via maven, my tests are not found in the junit project

screenshot 1
As in the screenshot 1 I'm trying to run my set of autotests, the build works successfully, but not a single test is defined.
screenshot 2
Screenshot 2 shows the result after running through maven
If you run tests separately, through "run test", but everything starts and runs according to the script
my POM file:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>src/test/java/</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>`
I want that tests were defined in all classes.
I tried to play with the pom file, apparently there are problems in it, but nothing happens.
link to project
i fix problem
my pom:
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
<groupId>org.example</groupId>
<artifactId>Test_Framework</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<selenium.version>4.6.0</selenium.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>

Error while converting java project to maven project

I just installed eclipse for Learning selenium automation i have added java environment variable but after converting java to maven project its giving me some error as follows:
The <maven-compiler-plugin> looks error-prone. You can update it as:
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Additionally you need to indent the <dependency> properly as follows:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>

Selenium (Eclipse) - feature file - step is not highlighted if step definition is undefined

I am very new to Selenium and Cucumber.
I am asking for your kind advice.
My problem is: Feature file - step is not highlighted, not showing warning messages if step definition is undefined.
My Feature file:
[![enter image description here][1]][1]
My runner:
[![enter image description here][2]][2]
Maven dependencies:
[![enter image description here][3]][3]
My pom.xml:
<?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>
<groupId>linkedlearning</groupId>
<artifactId>Mycucumbercourse</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Mycucumbercourse</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.version>4.11</junit.version>
<cucumber.version>4.2.5</cucumber.version>
<maven.compiler.version>3.3</maven.compiler.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<!-- hamcrest dependency required in order to be able to run test using maven (command: mvn test) -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I tried to investigate myself and find that import io.cucumber.junit.CucumberOptions; in combination with stepNotifications = true may help. However when I try to add it I am getting: "The import io.cucumber.junit cannot be resolved". Looking forward for your kind advice.
[1]: https://i.stack.imgur.com/KcrQN.png
[2]: https://i.stack.imgur.com/t2h9a.png
[3]: https://i.stack.imgur.com/n2gFr.png
I found an answer here:
Step Definition detection only works when project is configured as cucumber project.- Virtual Machine
Generally speaking:
If the step definition is not happened and the feature file does not highlight undefined steps with amber color that means that the project is not converted as a cucumber project.
Do the following:
In order to convert the project as a cucumber project do the following: Right-click on your project from the Project Explorer > Configure > Convert as Cucumber Project.
Ensure option Enable Step Definitions Glue Detection is checked in Window > Preferences > Cucumber

Intellij + Ajc + Lombok/Mapstruct

I want to enable AspectJ compiler in my IntelliJ Idea as I have several aspects that I'd like to be woven during compile time.
At the same time, I am using Lombok and Mapstruct in my codebase.
Those 2 require additional annotations processing, that must happen before ajc kicks in.
I have both plugins installed for Lombok and Mapstruct. Independently they work fine, source code is being generated. But when I enable ajc and tick Enable annotation processing options, and then build a project, I get:
Error:(9, 0) ajc: Internal error in the mapping processor: java.lang.NullPointerException at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding.sourceField(FieldBinding.java:425) at org.aspectj.org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl$SourceLocationComparator.determineSourceStart(TypeElementImpl.java:108) at org.aspectj.org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl$SourceLocationComparator.getSourceStart(TypeElementImpl.java:72) at org.aspectj.org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl$SourceLocationComparator.compare(TypeElementImpl.java:65) at org.aspectj.org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl$SourceLocationComparator.compare(TypeElementImpl.java:1) at java.util.TimSort.countRunAndMakeAscending(TimSort.java:360) at java.util.TimSort.sort(TimSort.java:234) at java.util.Arrays.sort(Arrays.java:1512) at java.util.ArrayList.sort(ArrayList.java:1462) at java.util.Collections.sort(Collections.java:175) at org.aspectj.org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl.getEnclosedElements(TypeElementImpl.java:166) at org.mapstruct.ap.internal.util.workarounds.SpecificCompilerWorkarounds.replaceTypeElementIfNecessary(SpecificCompilerWorkarounds.java:99) at org.mapstruct.ap.internal.util.Executables.getAllEnclosedExecutableElements(Executables.java:99) at org.mapstruct.ap.internal.model.common.Type.getAllMethods(Type.java:633) at org.mapstruct.ap.internal.model.common.Type.getPropertyReadAccessors(Type.java:496) at org.mapstruct.ap.internal.model.BeanMappingMethod$Builder.build(BeanMappingMethod.java:168) at org.mapstruct.ap.internal.processor.MapperCreationProcessor.getMappingMethods(MapperCreationProcessor.java:376) at org.mapstruct.ap.internal.processor.MapperCreationProcessor.getMapper(MapperCreationProcessor.java:151) at org.mapstruct.ap.internal.processor.MapperCreationProcessor.process(MapperCreationProcessor.java:122) at org.mapstruct.ap.internal.processor.MapperCreationProcessor.process(MapperCreationProcessor.java:76) at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:283) at org.mapstruct.ap.MappingProcessor.processMapperTypeElement(MappingProcessor.java:263) at org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:221) at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:156) at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139) at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:121) at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:931) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:437) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:417) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185) at com.intellij.lang.aspectj.build.AjJpsCompiler.doBuild(AjJpsCompiler.java:249) at com.intellij.lang.aspectj.build.AjJpsCompiler.build(AjJpsCompiler.java:119) at com.intellij.lang.aspectj.build.AjTranslatingBuilder.doBuild(AjTranslatingBuilder.java:114) at com.intellij.lang.aspectj.build.AjBuilderBase.build(AjBuilderBase.java:74) at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1328) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1008) at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1075) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:969) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:798) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:380) at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178) at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:139) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302) at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135) at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:228) at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
Also, I see a bunch of other ajc compilation errors as it is not able to locate methods that should've been generated by the Lombok.
How do I solve these issues?
Hi I had similar issue.
The fix was to let aspectj-maven-plugin to only start weaving after classes are compiled.
It describes in more detail here https://www.mojohaus.org/aspectj-maven-plugin/examples/weaveDirectories.html
I needed to:
(1) Specify folder where already compiled classes will be via <weaveDirectories >
(2) Change the phase of maven-compiler-plugin lifecycle to be run "process-classes" or later.
This is how my pom looked like.
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>-Amapstruct.defaultComponentModel="spring"</compilerArg>
<compilerArg>-Amapstruct.unmappedTargetPolicy=ERROR</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>
<configuration>
<showWeaveInfo>${showWeaveInfo}</showWeaveInfo>
<showWeaveInfo>true</showWeaveInfo>
<Xlint>ignore</Xlint>
<complianceLevel>${java.compiler.version}</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>false</verbose>
<verbose>true</verbose>
<forceAjcCompile>true</forceAjcCompile>
<sources/>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories>
<aspectLibraries>
<aspectLibrary>
<groupId>com.lib.test</groupId>
<artifactId>test1</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>com.lib.test2</groupId>
<artifactId>test2</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<phase>process-classes</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>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Enabling Post-compile weave mode in IntelliJ solved it for me (https://www.jetbrains.com/help/idea/using-the-aspectj-ajc-compiler.html).
if you have aspect sources with the same project then you should add a few line codes to the #jun-huh answers and delete <aspectLibraries>. The below pom.xml is for if you use your aspects with the same project.
<?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>
<groupId>az.sanco</groupId>
<artifactId>aspect</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.14.0</version>
<configuration>
<forceAjcCompile>true</forceAjcCompile>
<weaveDirectories>
<weaveDirectory>${project.build.outputDirectory}</weaveDirectory>
</weaveDirectories>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<proc>none</proc><!-- annotation process already finished, so we don't need to run again-->
</configuration>
<executions>
<execution>
<id>copy-only-aspect-files</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<!--when `javac` compile works it does not copy *.aj files to the
output directory. We need to run `ajc` compile during `compile` phase and
copy only *.aj files to weave our classes-->
<includes>
<include>**/*.aj</include><!--IMPORTANT-->
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

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