I'm triying to generate a .war with my Eclipse project and Maven. When I'm going to execute the task "mvn test" Maven don't execute/find any of my test:
C:\eclipseJava\workspace\myproject>mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject0.1
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.sun:tools:jar:1.4.2 is missing, no dependency informat
ion available
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocate
d to commons-io:commons-io:jar:1.3.2
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # myproject
---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] Copying 21 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # myproject---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # my
project ---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # myproject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # myproject---
[INFO] Surefire report directory: C:\eclipseJava\workspace\myproject\target\sure
fire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.424s
[INFO] Finished at: Thu Dec 19 11:47:53 CET 2013
[INFO] Final Memory: 6M/10M
[INFO] ------------------------------------------------------------------------
And this is part of 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<groupId>myproject</groupId>
<artifactId>myproject</artifactId>
<version>0.1</version>
<name>myproject</name>
<build>
<!--
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/*Test*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
-->
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<filtering>false</filtering>
<directory>src/es/mycompany/myproject/test</directory>
<includes>
<include>ValoresTest.java</include>
</includes>
</testResource>
</testResources>
<plugins>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>es/mycompany/myproject/test/ValoresTest.java</include>
</includes>
</configuration>
</plugin>
-->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>myproject</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<path>/u</path>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version>
</dependency>
...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.javacsv</groupId>
<artifactId>javacsv</artifactId>
<version>2.0</version>
</dependency>
...
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>project-repo</id>
<url>file://${project.basedir}/local-maven-repo/</url>
</repository>
<repository>
<id>maven-restlet</id>
<url>http://maven.restlet.org</url>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>utf-8</project.reporting.outputEncoding>
</properties>
</project>
If I add the lines commented in maven-surefire-plugin I don't get the message but the tests don't run anyway...
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject 0.1
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.sun:tools:jar:1.4.2 is missing, no dependency informat
ion available
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocate
d to commons-io:commons-io:jar:1.3.2
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # myproject
---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] Copying 21 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # myproject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # my
project ---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # myproje
ct ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) # myproject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.190s
[INFO] Finished at: Thu Dec 19 12:01:22 CET 2013
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------
I'm a newbie in Maven and I don't know where is my fail :( Any help please? I'm working with Java, Eclipse, JUnit4 and Maven.
Thanks!
Related
I am having trouble getting JUnit 5 tests to run on VSCODE. I believe my environment is set up properly. A clone of junit5-samples | junit5-jupiter-starter-maven builds and runs as expected. My project does not.
My project builds under maven but runs no tests. So this is probably a Maven or project configuration issue and not related to VSCODE.
I have tinkered with various ideas for a couple of hours to no avail. Something is different, probably a mistake and maybe additional pairs of eyes can find it. Any help you might provide will be greatly appreciated.
Here is some project information
'mvn clean package' runs without error, but no tests run. CodeLens is also not working.
Run Test|Debug Test is missing. No tests show up in test runner.
Here is my POM file with a few redactions:
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>com.redacted</groupId>
<artifactId>redacted</artifactId>
<packaging>jar</packaging>
<version>0.1.1</version>
<name>redacted</name>
<properties>
<skipTests>false</skipTests>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<junit.jupiter.version>5.6.2</junit.jupiter.version>
</properties>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!-- <skipTests>${skipTests}</skipTests> -->
</configuration>
</plugin>
<!-- <plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin> -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.6</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/WSDL/redacted.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here is the output from the mvn command:
[INFO]
[INFO] ------------------------< com.redacted:redactedClient >-------------------------
[INFO] Building redactedClient 0.1.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # redactedClient ---
[INFO] Deleting D:\repos\redacted\redactedClient\target
[INFO]
[INFO] --- cxf-codegen-plugin:3.3.6:wsdl2java (generate-sources) # redactedClient ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # redactedClient ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\repos\redacted\redactedClient\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # redactedClient ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to D:\repos\redacted\redactedClient\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # redactedClient ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\repos\redacted\redactedClient\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # redactedClient ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\repos\redacted\redactedClient\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # redactedClient ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.444 s
[INFO] Finished at: 2020-04-26T09:55:55-07:00
[INFO] ------------------------------------------------------------------------
A test method should have the return type void whereas your test method GetModList() has Boolean.
In JUnit Jupiter you can remove public from the test class also from all test methods.
With maven, I want to deploy this project locally with all the dependencies to the tomcat server. But I get some errors. I use the operating system archlinux and tomcat installed in the "/opt" directory.
Java version: "11.0.2" 2019-01-15 LTS
Maven version:3.0.6
Tomcat version:9.0.17
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>TomcatServer</id>
<username>onur</username>
<password>onur123</password>
</server>
</servers>
<profiles>
<profile>
<properties>
<tomcathome>/opt/apache-tomcat-9.0.17</tomcathome>
</properties>
<repositories>
<repository>
<id>DefaultRepo</id>
<url>http://localhost:8080/estech</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
</settings>
This is my pom.xml. I use maven deploy plugin for deploy to tomcat server. How can I fix this?
<?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>com.pmyo.group5</groupId>
<artifactId>estech</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<distributionManagement>
<repository>
<id>DefaultRepo</id>
<name>localhost</name>
<url>http://localhost:8080/estech/</url>
</repository>
</distributionManagement>
<name>estech Maven Webapp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<finalName>estech</finalName>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<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-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Error:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.pmyo.group5:estech >-----------------------
[INFO] Building estech Maven Webapp 1.0
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # estech ---
[INFO] Deleting /home/onur/IdeaProjects/Es-tech/estech/target
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # estech ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/onur/IdeaProjects/Es-tech/estech/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # estech ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 21 source files to /home/onur/IdeaProjects/Es-tech/estech/target/classes
[INFO] /home/onur/IdeaProjects/Es-tech/estech/src/main/java/Models/ProductComments.java: Some input files use or override a deprecated API.
[INFO] /home/onur/IdeaProjects/Es-tech/estech/src/main/java/Models/ProductComments.java: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) # estech ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/onur/IdeaProjects/Es-tech/estech/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # estech ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) # estech ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:3.2.2:war (default-war) # estech ---
[INFO] Packaging webapp
[INFO] Assembling webapp [estech] in [/home/onur/IdeaProjects/Es-tech/estech/target/estech]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/onur/IdeaProjects/Es-tech/estech/src/main/webapp]
[INFO] Webapp assembled in [152 msecs]
[INFO] Building war: /home/onur/IdeaProjects/Es-tech/estech/target/estech.war
[INFO]
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-cli) # estech ---
Uploading to DefaultRepo: http://localhost:8080/estech/com/pmyo/group5/estech/1.0/estech-1.0.war
Uploading to DefaultRepo: http://localhost:8080/estech/com/pmyo/group5/estech/1.0/estech-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.847 s
[INFO] Finished at: 2019-05-02T19:48:25+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-cli) on project estech: Failed to deploy artifacts: Could not transfer artifact com.pmyo.group5:estech:war:1.0 from/to DefaultRepo (http://localhost:8080/estech/): Failed to transfer file http://localhost:8080/estech/com/pmyo/group5/estech/1.0/estech-1.0.war with status code 405 -> [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
maven-deploy-plugin is not for deploying your WAR into Tomcat. It is used to transfer build artifacts into repository.
You should take a look at tomcat-maven-plugin or cargo-maven-plugin
I try to run my test as -mvn test, it is showing as build is success but , No Source to Compile.Down I have attached my both pom and Result file.
Output :
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Wepaythemax 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Wepaythemax ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\rck\git\repository3\Wepaythemax\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # Wepaythemax ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Wepaythemax ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # Wepaythemax ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Wepaythemax ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.051 s
[INFO] Finished at: 2018-12-20T18:37:53+05:30
[INFO] Final Memory: 10M/114M
Pom.xml File
<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>Wepaythemax</groupId>
<artifactId>Wepaythemax</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.5</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>selenium-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Help Me out, Where I have done Mistake, I can't find out. I'm Trying to Figure it out.Also I have attached a Screenshot Where the My testng.xml file is placed
no sources to compile, means no java file in src/main/java or src/test/java.
sources are in src/main/java, sources is different from resources, which means .xml,etc.
I'm trying to build shaded jar in spring boot application but having some issues. I don't know what i'm doing wrong here. I also read the following links but no luck
maven-shade-plugin error: Cannot find setter, adder nor field in org.apache.maven.plugins.shade.resource.ManifestResourceTransformer for 'resource'
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>dashboard</groupId>
<artifactId>dashboard</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.2.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>jira.widgets</groupId>
<artifactId>jira-widgets</artifactId>
<version>0.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.5.RELEASE</version>
</parent>
<!-- Additional lines to be added here... -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.text.dashboard.hello.Application</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When i run mvn package then i got following exception on console
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building dashboard 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # dashboard ---
[INFO] Deleting C:\Users\confiz\Documents\workspace-sts-3.7.3.RELEASE\dashboard\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # dashboard ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # dashboard ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\confiz\Documents\workspace-sts-3.7.3.RELEASE\dashboard\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # dashboard ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # dashboard ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.15:test (default-test) # dashboard ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # dashboard ---
[INFO] Building jar: C:\Users\confiz\Documents\workspace-sts-3.7.3.RELEASE\dashboard\target\dashboard-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.1.5.RELEASE:repackage (default) # dashboard ---
[INFO]
[INFO] --- maven-shade-plugin:2.3:shade (default) # dashboard ---
[WARNING] Map in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer declares value type as: class java.util.jar.Attributes but saw: class java.lang.String at runtime
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.609 s
[INFO] Finished at: 2016-04-15T10:55:02+05:00
[INFO] Final Memory: 22M/224M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project dashboard: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.3:shade for parameter resource: Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer -> [Help 1]
[ERROR]
Scenario is : i have two spring boot projects and both have same type which executable jar. I'm adding other project in this project as dependency. That's why i'm building a jar which have all the dependencies
Any suggestions?
I don't know why but it worked for me. Use just
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.text.dashboard.hello.Application</Main-Class>
</manifestEntries>
</transformer>
Instead of
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.text.dashboard.hello.Application</Main-Class>
</manifestEntries>
</transformer>
</transformers>
I am trying to test a maven project but i keep getting this error...any ideas?
My Java version is "1.7.0_80"
All suggestions are welcomed..
/usr/lib/jvm/java-7-oracle/bin/java -Dmaven.home=/usr/share/maven2 -Dclassworlds.conf=/usr/share/maven2/bin/m2.conf -Didea.launcher.port=7541 -Didea.launcher.bin.path=/opt/idea/bin -Dfile.encoding=UTF-8 -classpath /usr/share/maven2/boot/classworlds.jar:/opt/idea/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=13.1.4 --no-plugin-registry test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.rancard.kudi:kudi-client:jar:1.0-SNAPSHOT
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.glassfish.jersey:project
Reason: Invalid JDK version in profile 'jdk1.7+': Unbounded range: [1.7, for project org.glassfish.jersey:project
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Jul 30 12:42:53 GMT 2015
[INFO] Final Memory: 14M/172M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 1
This is the result when I build from the command line...it flags the same error...
rancard#RSL-PROD-INT1 ~/IdeaProjects/kudi/client $ mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.rancard.kudi:kudi-client:jar:1.0-SNAPSHOT
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.glassfish.jersey:project
Reason: Invalid JDK version in profile 'jdk1.7+': Unbounded range: [1.7, for project org.glassfish.jersey:project
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Thu Jul 30 15:35:39 GMT 2015
[INFO] Final Memory: 14M/108M
[INFO] ------------------------------------------------------------------------
This is the content of my pom file
<?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">
<parent>
<artifactId>kudi-platform</artifactId>
<groupId>com.rancard.kudi</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>kudi-client</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.rancard.kudi</groupId>
<artifactId>kudi-domain</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.19</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
</plugins>
</build>
</project>
My guess is that the pom of the glassfish jersey dependency has a profile that is activated when a certain jdk version is used. But the declaration of the JDK version is malformed.
See below : (http://central.maven.org/maven2/org/glassfish/jersey/project/2.19/project-2.19.pom)
<profile>
<id>jdk1.7+</id>
<activation>
<jdk>[1.7,</jdk>
</activation>
...
</profile>
I had the same issue when maven 2.0.6 was installed.
Run mvn -version and check you have the right maven version, it should look like this:
Apache Maven 3.0.4
Maven home: /usr/share/maven