I changed <packaging>war</packaging> to <packaging>pom<packaging>, but I am getting an error - maven

I have changed war to pom, but I am getting the following error:
Project configuration is not up-to-date with pom.xml.
Run Maven->Update Project or use Quick Fix.
How can I solve this error?

Assuming you are using Eclipse, you right click the pom, choose Maven --> Update Project.

http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
br.com.projetoweb03
universo2
0.0.1-SNAPSHOT
war
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>

Related

Pitest report-aggregate goal complains about transitive dependencies

I integrated Pitest according to https://pitest.org/aggregating_tests_across_modules/ in a Maven module project (Maven version 3.5.4).
When running mvn clean package the log shows the Pitest execution for the target modules (i.e. the modules for which Pitest should be executed) and I confirmed that result files are actually produced.
However, I get the following error message for the report module:
[ERROR] Failed to execute goal org.pitest:pitest-maven:1.5.1:report-aggregate (put-it-together) on project mutationtesting:
An error has occurred in PIT Test Report report generation.:
.../.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.10.0/jackson-databind-2.10.0.jar is not a directory
jackson-databind is a dependency of the target modules and therefore a transitive dependency of the reporting module. It seems to me that the report-aggregate goal also tries to analyse the transitive dependencies of the modules for which Pitest is enabled.
Is there some error in the project configuration? Is this a known bug? What can I do?
I tried to change the scope of the target modules in the reporting module to provided, and I also set the packing of the reporting module to pom, but to no avail.
Configuration
I configured Pitest in the parent POM as follows:
<properties>
...
<pitest.version>1.5.1</pitest.version>
<pitest.junit5.version>0.12</pitest.junit5.version>
<properties>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>${pitest.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
</executions>
<configuration>
<exportLineCoverage>true</exportLineCoverage>
<outputFormats>
<value>XML</value>
</outputFormats>
<timestampedReports>false</timestampedReports>
</configuration>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>${pitest.junit5.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
The target module POM's each contain this section:
<build>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
</plugin>
</plugins>
</build>
And finally the reporting module POM looks like this
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
...
</parent>
<artifactId>mutationtesting</artifactId>
<dependencies>
<dependency>
target module 1
</dependency>
<dependency>
target module 2
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<executions>
<execution>
<id>put-it-together</id>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Jaxb2 Maven Plugin failed to generate java from xsd file

I don't understand the official document. Even I follow the example, I still get an error. When I execute the command "mvn clean compile", the following error is shown:
Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.3.1:xjc
(xjc) on project zTestJaxb: : MojoExecutionException:
NoSchemasException -> [Help 1]
environment:
mac, jdk8, eclipse Mars
project directory
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</groupId>
<artifactId>zTestJaxb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<!-- If we e.g. execute on JDK 1.7, we should compile for Java 7 to get
the same (or higher) JAXB API version as used during the xjc execution. -->
<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>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>xjc1</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The package of your generated sources -->
<packageName>com</packageName>
</configuration>
</plugin>
</plugins>
</build>
Check your project workspace configured to JDK or JRE as your pom goal is set to XJC and XJC will be present in your java/Jdk/bin. if you are using eclipse goto preferences --> java --> Installed JREs here Add path to JDK.

how to create deployable war in spring using maven

Creating war in spring what are the dependency needed ?
1) maven compiler and maven war plugins are required ?
2) How to add class path reference to war package ?
Create a Maven Spring project and in pom.xml change the packaging to war:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>Maven Spring Project</artifactId>
<packaging>war</packaging>
And just build the project using Maven by executing goal : "clean install". It will automatically create war file in target folder of Maven project.
You can try this in your pom.xml
<build>
<finalName>projectname</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin-version}</version>
<configuration>
<source>${jdk-version}</source>
<target>${jdk-version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin-version}</version>
<configuration>
<warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<argLine>-XX:-UseSplitVerifier</argLine>
</configuration>
</plugin>
</plugins>
</build>
and to make war run this package tomcat7:run goal from eclipse

Jenkins package project out of his workspace

I tried to build maven war projects with Jenkins.
Jenkins pulls the code and builds the project. However, the build is not in the workspace, but rather in a folder with the project source. I think Jenkins takes the target folder from maven pom file and builds it.
How can I tune Jenkins to make a build and deploy pipeline?
In the deploy phase Jenkins cannot find war file.
OS is windows, IDE - eclipse.
<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>my.test.webapp</groupId>
<artifactId>webApp</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>webApp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>8.0.5</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<directory>${basedir}\target</directory> <!-- tried with this line and without -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
The way I coped with a problem:
In pom.xml:
<properties>
<baseFolder>${basedir}</baseFolder>
</properties>
<build>
<directory>${baseFolder}/target</directory>
</directory>
In Jenkins run build maven build with properties
baseFolder=$WORKSPACE

Tycho Compiler not picking up generated source code

I am fairly new to the world of maven and tycho, so hopefully this is just something obvious that I am missing. I am trying to build a plugin using tycho but I am unable to get the tycho-compiler-plugin to recognise source code that is generated as a part of the build process.
Here is a copy of a test pom that I've put together to demonstrate:
<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>rt</groupId>
<artifactId>rt.webservice</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tycho-version>0.16.0</tycho-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<verbose>true</verbose>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>generate-ws-code</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>${basedir}/wsdl</wsdlDirectory>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have a java class in the src folder that references some of the generated source code, which then fails to compile.
If I remove tycho and use the standard maven-compiler-plugin, it automatically picks up the code generated during the build and the java class mentioned above compiles as expected.
Can someone tell me what I am doing wrong?
tycho compiler plugin uses source dirs configured in build.properties
you have to make sure the generated source dir is referenced in build.properties
http://jax-ws-commons.java.net/jaxws-maven-plugin/wsimport-mojo.html#sourceDestDir
You have to add additional source folders for generated sources, in your case the wsdl dir.
See this question for help on that.
Tycho will then pick up those additional directories during compile.

Resources