spring boot application isn't starting in Jenkins - java

I'm cloning the project from git and doing the mvn clean test package sonar:sonar and deploy
but the project doesn't run , I tried the free-style job too but it's the same
it's spring boot JAR application
pipeline {
agent any
stages{
stage('Git') {
steps {
echo "Cloning"
git branch: '*****', url: 'https://github.com/****.git'
}
}
stage('clean') {
steps{
echo "Cleaning the project"
bat 'mvn clean'
}
}
stage('Test') {
steps {
echo "Doing the tests"
bat 'mvn test'
}
}
stage('SONAR') {
steps{
echo "Cleaning Code";
bat 'mvn sonar:sonar';
}
}
stage('MVN PACKAGE') {
steps{
echo "packing the project";
bat 'mvn package';
}
post{
success {
archiveArtifacts 'target/*.jar';
}
}
}
stage('NEXUS') {
steps{
echo "Deploying the project";
bat 'mvn deploy:deploy-file -DgroupId=**** -DartifactId=**** -Dversion=1.0 -DgeneratePom=true -Dpackaging=jar -DrepositoryId=deploymentRepo -Durl=http://localhost:8081/repository/maven-releases/ -Dfile=target/****-1.0.jar ';
}
}
} ...}}
as the Tomcat does no start running , my Tests aren't running , it's supposed to do 6 tests
[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: 46.816 s
[INFO] Finished at: 2020-11-05T02:52:20+01:00
[INFO] ------------------------------------------------------------------------
even sonar isn't showing the unit tests in the project, Can you please help me?
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>tn.esprit.spring</groupId>
<artifactId>timesheet</artifactId>
<version>1.0</version>
<name>timesheet</name>
<description>timesheet</description>
<properties>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
mvn compile
D:\2-SPRING\jenkins\jenkins\workspace\pipeline timesheet project>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< tn.esprit.spring:timesheet >---------------------
[INFO] Building timesheet 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # timesheet ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # timesheet ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 35 source files to D:\2-SPRING\jenkins\jenkins\workspace\pipeline timesheet project\src\main\webapp\WEB-INF\classes
[INFO] /D:/2-SPRING/jenkins/jenkins/workspace/pipeline timesheet project/src/main/java/tn/esprit/spring/TimesheetApplication.java: D:\2-SPRING\jenkins\jenkins\workspace\pipeline timesheet project\src\main\java\tn\esprit\spring\TimesheetApplication.java uses unchecked or unsafe operations.
[INFO] /D:/2-SPRING/jenkins/jenkins/workspace/pipeline timesheet project/src/main/java/tn/esprit/spring/TimesheetApplication.java: Recompile with -Xlint:unchecked for details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39.156 s
[INFO] Finished at: 2020-11-05T04:07:57+01:00
[INFO] ------------------------------------------------------------------------
mvn sonar:sonar
D:\2-SPRING\jenkins\jenkins\workspace\pipeline timesheet project>mvn sonar:sonar
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< tn.esprit.spring:timesheet >---------------------
[INFO] Building timesheet 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) # timesheet ---
[INFO] User cache: C:\windows\system32\config\systemprofile\.sonar\cache
[INFO] SonarQube version: 6.7.7
[INFO] Default locale: "fr_FR", source code encoding: "UTF-8"
[INFO] Publish mode
[INFO] Load global settings
[INFO] Load global settings (done) | time=1186ms
[INFO] Server id: BF41A1F2-AXWFQCU12uRh5xSTg2DK
[INFO] User cache: C:\windows\system32\config\systemprofile\.sonar\cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=230ms
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=2067ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=1483ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=3900ms
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=380ms
[INFO] Project key: tn.esprit.spring:timesheet
[INFO] ------------- Scan timesheet
[INFO] Load server rules
[INFO] Load server rules (done) | time=160ms
[INFO] Base dir: D:\2-SPRING\jenkins\jenkins\workspace\pipeline timesheet project
[INFO] Working dir: D:\2-SPRING\jenkins\jenkins\workspace\pipeline timesheet project\target\sonar
[INFO] Source paths: pom.xml, src/main/java
[INFO] Test paths: src/test/java
[INFO] Source encoding: UTF-8, default locale: fr_FR
[INFO] Index files
[INFO] 39 files indexed
[INFO] Quality profile for java: Sonar way
[INFO] Quality profile for xml: Sonar way
[INFO] Sensor JavaSquidSensor [java]
[INFO] Configured Java source version (sonar.java.source): 8
[INFO] JavaClasspath initialization
[INFO] JavaClasspath initialization (done) | time=80ms
[INFO] JavaTestClasspath initialization
[INFO] JavaTestClasspath initialization (done) | time=10ms
[INFO] Java Main Files AST scan
[INFO] 35 source files to be analyzed
[INFO] 35/35 source files have been analyzed
[WARNING] Classes not found during the analysis : [javax.annotation.meta.When]
[INFO] Java Main Files AST scan (done) | time=4596ms
[INFO] Java Test Files AST scan
[INFO] 3 source files to be analyzed
[INFO] 3/3 source files have been analyzed
[INFO] Java Test Files AST scan (done) | time=90ms
[INFO] Sensor JavaSquidSensor [java] (done) | time=6680ms
[INFO] Sensor SurefireSensor [java]
[INFO] parsing [D:\2-SPRING\jenkins\jenkins\workspace\pipeline timesheet project\target\surefire-reports]
[INFO] Sensor SurefireSensor [java] (done) | time=0ms
[INFO] Sensor JaCoCoSensor [java]
[INFO] Sensor JaCoCoSensor [java] (done) | time=0ms
[INFO] Sensor SonarJavaXmlFileSensor [java]
[INFO] 1 source files to be analyzed
[INFO] Sensor SonarJavaXmlFileSensor [java] (done) | time=3850ms
[INFO] 1/1 source files have been analyzed
[INFO] Sensor XML Sensor [xml]
[INFO] Sensor XML Sensor [xml] (done) | time=510ms
[INFO] Sensor Analyzer for "php.ini" files [php]
[INFO] Sensor Analyzer for "php.ini" files [php] (done) | time=30ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=170ms
[INFO] Sensor CPD Block Indexer
[INFO] Sensor CPD Block Indexer (done) | time=130ms
[INFO] 11 files had no CPD blocks
[INFO] Calculating CPD for 24 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 679ms, dir size=187 KB
[INFO] Analysis reports compressed in 160ms, zip size=107 KB
[INFO] Analysis report uploaded in 90ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/tn.esprit.spring:timesheet
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://localhost:9000/api/ce/task?id=AXWWYaz_JnFpsXr-KFku
[INFO] Task total time: 57.427 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:22 min
[INFO] Finished at: 2020-11-05T04:09:45+01:00
[INFO] ------------------------------------------------------------------------
deploy
D:\2-SPRING\jenkins\jenkins\workspace\pipeline timesheet project>mvn deploy:deploy-file -DgroupId=tn.esprit -DartifactId=timesheet -Dversion=1.0 -DgeneratePom=true -Dpackaging=jar -DrepositoryId=deploymentRepo -Durl=http://localhost:8081/repository/maven-releases/ -Dfile=target/timesheet-1.0.jar
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< tn.esprit.spring:timesheet>---------------------
[INFO] Building timesheet 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.8.2:deploy-file (default-cli) # timesheet ---
Uploading to deploymentRepo: http://localhost:8081/repository/maven-releases/tn/esprit/timesheet/1.0/timesheet-1.0.jar
Uploaded to deploymentRepo: http://localhost:8081/repository/maven-releases/tn/esprit/timesheet/1.0/timesheet-1.0.jar (54 MB at 6.5 MB/s)
Uploading to deploymentRepo: http://localhost:8081/repository/maven-releases/tn/esprit/timesheet/1.0/timesheet-1.0.pom
Progress (1): 390 B
Uploaded to deploymentRepo: http://localhost:8081/repository/maven-releases/tn/esprit/timesheet/1.0/timesheet-1.0.pom (390 B at 82 B/s)
Downloading from deploymentRepo: http://localhost:8081/repository/maven-releases/tn/esprit/timesheet/maven-metadata.xml
Uploading to deploymentRepo: http://localhost:8081/repository/maven-releases/tn/esprit/timesheet/maven-metadata.xml
Progress (1): 294 B
Uploaded to deploymentRepo: http://localhost:8081/repository/maven-releases/tn/esprit/timesheet/maven-metadata.xml (294 B at 104 B/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.030 s
[INFO] Finished at: 2020-11-05T04:10:36+01:00
[INFO] ------------------------------------------------------------------------
[Pipeline] }

I fixed the problem , I added maven-surefire plugin , took off the junit dependency ( I put it bcz I faced error while deploying to nexus and after changing it the deploying worked) , and to fix the 401 unauthorized error in mvn deploy:deploy , I just changed mvn version from 3.5. to 3.6.3

Related

Custom maven archetype doesn't generate sources defined in archtype.xml

I'm trying to create a custom archetype which defines a substantial pom.xml and includes a couple of source files.
None of the sources I define in my archetype.xml are included when generate a project using this archetype (the pom.xml is generated as expected).
My archetype.xml is located in src/main/resources/META-INF/maven and defines two sources.
<archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>custom-archetype</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<resources>
<resource>src/test/java/BatFile.bat</resource>
</resources>
</archetype>
App.java is located in src/main/resources/archetype-resources/src/main/java.
BatFile.bat is located in src/main/resources/archetype-resources/src/main/resources.
I also have an archetype-metadata.xml located in src/main/resources/META-INF/maven which I use to define dependency version
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="custom">
<requiredProperties>
<requiredProperty key="thorntail-version">
<defaultValue>2.2.1.Final</defaultValue>
</requiredProperty>
</requiredProperties>
</archetype-descriptor>
My root pom.xml is as follows
<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>uk.co.xxxxx</groupId>
<artifactId>custom-archetype</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Custom Archetype</name>
<description>Archetype for Custom projects</description>
</project>
I'm following the maven Documentation on creating custom archetypes and as far as I can see I'm doing everything correctly.
This is the result of running mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreade
d.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Custom Archetype 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # custom-archetype ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # custom-archetype ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # custom-archetype ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) custom-archetype ---
[INFO] No sources to compile
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # custom-archetype
---
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # custom-archetype ---
[INFO] --- maven-install-plugin:2.4:install (default-install) # custom-archetype
---
[INFO] Installing D:\dev\customarchetype\target\custom-archetype-0.0.1-SNAPSHOT.jar to C:\Users\xxxx\.m2\repository\uk\co\xxxxx\custom-archetype\0
.0.1-SNAPSHOT\custom-archetype-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\dev\custom\customarchetype\pom.xml to C:\Users\xxxx\.m2\rep
ository\uk\co\xxxxx\custom-archetype\0.0.2-SNAPSHOT\custom-archetype-0.0.
1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.849 s
[INFO] Finished at: 2019-01-11T09:29:18+00:00
[INFO] Final Memory: 8M/245M
[INFO] ------------------------------------------------------------------------
I'm running the following maven command to generate my project
mvn archetype:generate -DarchetypeGroupId=uk.co.gamma.xxxxx -DarchetypeArtifactId=custom-archetype -DarchetypeVersion=0.0.1-SNAPSHOT -DgroupId=uk.co.xxxxx -Dversion=0.0.1-SNAPSHOT -DartifactId=test12 -Dpackage=uk.co.xxxxx
and this is the 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 Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) # standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) # standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) # standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [uk.co.xxxxx:custom-archetype:0.0.1-SNAPSHOT] found in catalog local
[INFO] Using property: groupId = uk.co.xxxxx
[INFO] Using property: artifactId = test12
[INFO] Using property: version = 0.0.1-SNAPSHOT
[INFO] Using property: package = uk.co.xxxxx
[INFO] Using property: thorntail-version = 2.2.1.Final
Confirm properties configuration:
groupId: uk.co.xxxxx
artifactId: test12
version: 0.0.1-SNAPSHOT
package: uk.co.xxxxx
thorntail-version: 2.2.1.Final
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: custom-archetype:0.0.1-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: uk.co.xxxxx
[INFO] Parameter: artifactId, Value: test12
[INFO] Parameter: version, Value: 0.0.1-SNAPSHOT
[INFO] Parameter: package, Value: uk.co.xxxxx
[INFO] Parameter: packageInPathFormat, Value: uk/co/xxxxx
[INFO] Parameter: package, Value: uk.co.xxxxx
[INFO] Parameter: version, Value: 0.0.1-SNAPSHOT
[INFO] Parameter: thorntail-version, Value: 2.2.1.Final
[INFO] Parameter: groupId, Value: uk.co.xxxxx
[INFO] Parameter: artifactId, Value: test12
[INFO] Project created from Archetype in dir: D:\dev\testarchetype\test12
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.281 s
[INFO] Finished at: 2019-01-11T10:27:45+00:00
[INFO] Final Memory: 13M/183M
[INFO] ------------------------------------------------------------------------
The generated project only contains pom.xml.
What do I need to do to include these files when generating a project from this archetype?
archetype-metadata.xml is an archetype 2.x descriptor whereas archetype.xml is an archetype 1.x descriptor. Using both means anything in archetype.xml is ignored. Including file generation in archetype-metadata.xml and deleting archetype.xml fixes the problem.

Maven won't run tests from parent or child projects

I got a multi-module project. Each project has its own unittest same for the parent project. When I use mvn test no tests are run and the target folder does not contain any test classes. Parent project doesn't even create a target folder
Structure looks like this:
|-module1-> pom.xml
|-module2-> pom.xml
|-module3-> pom.xml
|-src/main
|-src/test/java/MyTest.java
|-pom.xml
See poms below ( I omited standard pom boilerplate)
parent pom.xml
<groupId>com.tests</groupId>
<artifactId>unit-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>RELEASE</version>
</dependency>
<dependencies>
Child pom has:
<parent>
<groupId>com.tests</groupId>
<artifactId>unit-tests</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
Whenever i run mvn clean test no tests are run and in the console i get something like:
[INFO] ------------------------------------------------------------------------
[INFO] Building unit-tests 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
Btw, parent project does not have any source code, just tests
You're using packaging pom. With that kind of packaging you're only allowed to run a small number of goals bound to phases (like install and deploy). In order to run the tests in the parent you must be explicit about your intentions, like this:
$mvn clean compiler:testCompile surefire:test
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.tests.unit_tests.TestModules
Test1!
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 s <<< FAILURE! - in com.tests.unit_tests.TestModules
[ERROR] test1(com.tests.unit_tests.TestModules) Time elapsed: 0.003 s <<< FAILURE!
java.lang.AssertionError
at com.tests.unit_tests.TestModules.test1(TestModules.java:11)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] TestModules.test1:11
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] unit-tests ......................................... FAILURE [ 1.262 s]
[INFO] module1 ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.473 s
[INFO] Finished at: 2017-12-02T11:04:50-02:00
[INFO] Final Memory: 16M/207M
[INFO] ------------------------------------------------------------------------
That way you are telling maven that you want to compile (generate your target) and run your tests in the aggregator (which has the parent pom). Otherwise maven will only run the tests in the modules.
$mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] unit-tests
[INFO] module1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building unit-tests 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building module1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # module1 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # module1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # module1 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # module1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # module1 ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] unit-tests ......................................... SUCCESS [ 0.002 s]
[INFO] module1 ............................................ SUCCESS [ 0.424 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.504 s
[INFO] Finished at: 2017-12-02T11:06:24-02:00
[INFO] Final Memory: 9M/241M
[INFO] ------------------------------------------------------------------------
I know that it is a hard reading, but you should check it out:
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Packaging
For example, a project that is purely metadata (packaging value is
pom) only binds goals to the install and deploy phases (for a complete
list of goal-to-build-phase bindings of some of the packaging types,
refer to the Lifecycle Reference).
EDIT
As eis pointed out. Even though it's possible to do it, maven made it hard to do it because you SHOULDN't do it by default. Your unit tests should be in the module they are testing. It's not a good practice to scatter them.
The answer is: you can do it, yes. But you shouldn't! There are somethings in life that you can do, but shouldn't...
If we were talking about integration tests that would be a different story.. That's a different discussion.
Cheers!
The maven surefire plugin runs all JUnit Test where the name of the testclass ends with Test - with a capital 'T'. According to your info your test class is named Mytest. Refactor that class to be named MyTest will make it work.
multimodule parent has the packaging pom, and as such, can by definition only contain the pom, not any source code (not even test source code!). This is the reason your tests won't run and you don't get a target folder: there cannot be anything to run or compile on a project of type pom. A multimodule parent is only meant to group the modules together.

SonarQube: uploading Cobertura results using Maven

I am using Maven with the Cobertura and SonarQube plug-ins. I want the results in cobertura.ser to be uploaded to SonarQube. This 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>delta.coverage.mvp</groupId>
<artifactId>delta.coverage.mvp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.host.url>http://192.168.1.10:9000</sonar.host.url>
<sonar.jdbc.driverClassName>org.h2.Driver</sonar.jdbc.driverClassName>
<sonar.language>java</sonar.language>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.login>admin</sonar.login>
<sonar.password>adminpwd</sonar.password>
<sonar.projectKey>delta.coverage.mvp</sonar.projectKey>
<sonar.projectName>delta.coverage.mvp</sonar.projectName>
<sonar.projectVersion>test</sonar.projectVersion>
<sonar.sources>src/main/java</sonar.sources>
<sonar.java.coveragePlugin>cobertura</sonar.java.coveragePlugin>
<sonar.junit.reportsPath>${project.basedir}/target/surefire-reports</sonar.junit.reportsPath>
<sonar.surefire.reportsPath>${project.basedir}/target/surefire-reports</sonar.surefire.reportsPath>
<sonar.cobertura.reportPath>${project.basedir}/target/cobertura/cobertura.ser</sonar.cobertura.reportPath>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<instrumentation>
<includes>
<include>**/*.class</include>
</includes>
</instrumentation>
</configuration>
<executions>
<execution>
<id>clean</id>
<phase>pre-site</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>instrument</id>
<phase>site</phase>
<goals>
<goal>instrument</goal>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- SonarQube Plugin -->
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.2</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<!-- use mvn cobertura:cobertura to generate cobertura reports -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
</reporting>
</project>
I am running mvn clean cobertura:cobertura sonar:sonar in order to build, unit-test (with coverage) and analyze the code+upload the unit test results. The analysis (SonarQube scan) is uploaded successfully. However, the Cobertura results are not uploaded to SonarQube. Instead, the log shows that Maven actually looked for JaCoCo files:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building delta.coverage.mvp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # delta.coverage.mvp ---
[INFO] Deleting /home/phil/git/delta-coverage-mvp/target
[INFO]
[INFO] >>> cobertura-maven-plugin:2.7:cobertura (default-cli) > [cobertura]test # delta.coverage.mvp >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # delta.coverage.mvp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # delta.coverage.mvp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/phil/git/delta-coverage-mvp/target/classes
[INFO]
[INFO] --- cobertura-maven-plugin:2.7:instrument (default-cli) # delta.coverage.mvp ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Saved information on 1 classes.
[INFO] Cobertura: Saved information on 1 classes.
[INFO] Instrumentation was successful.
[INFO] NOT adding cobertura ser file to attached artifacts list.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # delta.coverage.mvp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # delta.coverage.mvp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/phil/git/delta-coverage-mvp/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # delta.coverage.mvp ---
[INFO] Surefire report directory: /home/phil/git/delta-coverage-mvp/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running delta.coverage.mvp.package1.Test1
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.202 sec
[INFO] Cobertura: Loaded information on 1 classes.
[INFO] Cobertura: Saved information on 1 classes.
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) < [cobertura]test # delta.coverage.mvp <<<
[INFO]
[INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) # delta.coverage.mvp ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 1 classes.
Report time: 108ms
[INFO] Cobertura Report generation was successful.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building delta.coverage.mvp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.0.2:sonar (default-cli) # delta.coverage.mvp ---
[INFO] User cache: /home/phil/.sonar/cache
[INFO] Load global repositories
[INFO] Load global repositories (done) | time=517ms
[INFO] User cache: /home/phil/.sonar/cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=116ms
[INFO] SonarQube version: 5.6.1
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=193ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=143ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=1824ms
[WARNING] 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[INFO] Publish mode
[INFO] ------------- Scan delta.coverage.mvp
[INFO] Language is forced to java
[INFO] Load server rules
[INFO] Load server rules (done) | time=966ms
[INFO] Base dir: /home/phil/git/delta-coverage-mvp
[INFO] Working dir: /home/phil/git/delta-coverage-mvp/target/sonar
[INFO] Source paths: src/main/java
[INFO] Test paths: src/test/java
[INFO] Binary dirs: target/classes
[INFO] Source encoding: UTF-8, default locale: en_US
[INFO] Index files
[INFO] 2 files indexed
[INFO] Quality profile for java: Cloud Managed Services - 201503
[INFO] JaCoCoSensor: JaCoCo report not found : /home/phil/git/delta-coverage-mvp/target/jacoco.exec
[INFO] JaCoCoItSensor: JaCoCo IT report not found: /home/phil/git/delta-coverage-mvp/target/jacoco-it.exec
[INFO] Sensor JavaSquidSensor
[INFO] Configured Java source version (sonar.java.source): none
[INFO] JavaClasspath initialization...
[INFO] JavaClasspath initialization done: 12 ms
[INFO] JavaTestClasspath initialization...
[INFO] JavaTestClasspath initialization done: 4 ms
[INFO] Java Main Files AST scan...
[INFO] 1 source files to be analyzed
[INFO] Java Main Files AST scan done: 193 ms
[INFO] 1/1 source files have been analyzed
[INFO] Java bytecode scan...
[INFO] Java bytecode scan done: 18 ms
[INFO] Java Test Files AST scan...
[INFO] 1 source files to be analyzed
[INFO] Java Test Files AST scan done: 56 ms
[INFO] 1/1 source files have been analyzed
[INFO] Package design analysis...
[INFO] Package design analysis done: 4 ms
[INFO] Sensor JavaSquidSensor (done) | time=560ms
[INFO] Sensor Lines Sensor
[INFO] Sensor Lines Sensor (done) | time=1ms
[INFO] Sensor SurefireSensor
[INFO] parsing /home/phil/git/delta-coverage-mvp/target/surefire-reports
[INFO] Sensor SurefireSensor (done) | time=54ms
[INFO] Sensor SCM Sensor
[INFO] SCM provider for this project is: git
[INFO] 2 files to be analyzed
[INFO] 0/2 files analyzed
[WARNING] Missing blame information for the following files:
[WARNING] * /home/phil/git/delta-coverage-mvp/src/main/java/delta/coverage/mvp/package1/Class1.java
[WARNING] * /home/phil/git/delta-coverage-mvp/src/test/java/delta/coverage/mvp/package1/Test1.java
[WARNING] This may lead to missing/broken features in SonarQube
[INFO] Sensor SCM Sensor (done) | time=112ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=5ms
[INFO] Sensor Code Colorizer Sensor
[INFO] Sensor Code Colorizer Sensor (done) | time=1ms
[INFO] Sensor CPD Block Indexer
[INFO] JavaCpdBlockIndexer is used for java
[INFO] Sensor CPD Block Indexer (done) | time=159ms
[INFO] Calculating CPD for 1 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 57ms, dir size=13 KB
[INFO] Analysis reports compressed in 14ms, zip size=8 KB
[INFO] Analysis report uploaded in 218ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://192.168.1.10:9000/dashboard/index/delta.coverage.mvp
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://192.168.1.10:9000/api/ce/task?id=AVbYSBOBTyY3I5vbl2iO
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.175 s
[INFO] Finished at: 2016-08-29T16:50:17-05:00
[INFO] Final Memory: 31M/666M
[INFO] ------------------------------------------------------------------------
The problem was that the the Cobertura plug-in on the SQ server was not installed. I installed it and everything worked fine.
Unfortunately nothing in the mvn log showed that Cobertura was invoked, and I assumed that the SQ server would support Cobertura by default since it's one of the main coverage tools for Java. Very counter-intuitive, but at least there is a simple solution.

Java app deployment to heroku using Maven failed

I am trying to setup the Continuous deployment process for a Tomcat based java app using Github for source code hosting, TravisCI for building the WAR file, running the unit tests and then Heroku to deploy the packaged WAR file.
I tried following the tutorial from
https://devcenter.heroku.com/articles/deploying-war-files-to-heroku-from-travis-ci#creating-a-java-web-application
I am getting an error while running the below step from the above tutorial:
mvn clean heroku:deploy-war
Command outpt:
$ mvn -e clean heroku:deploy-war
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.example:travis-heroku-java-example:war:0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 31, column 10
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple Web Application 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.3:clean (default-clean) # travis-heroku-java-example ---
[INFO] Deleting file set: /home/ciuser/travis-heroku-java-example/target (included: [**], excluded: [])
[INFO]
[INFO] >>> heroku-maven-plugin:0.3.6:deploy-war (default-cli) # travis-heroku-java-example >>>
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) # travis-heroku-java-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ciuser/travis-heroku-java-example/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) # travis-heroku-java-example ---
[INFO] Compiling 1 source file to /home/ciuser/travis-heroku-java-example/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) # travis-heroku-java-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ciuser/travis-heroku-java-example/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) # travis-heroku-java-example ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # travis-heroku-java-example ---
[INFO] No tests to run.
[INFO] Surefire report directory: /home/ciuser/travis-heroku-java-example/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) # travis-heroku-java-example ---
[INFO] Packaging webapp
[INFO] Assembling webapp [travis-heroku-java-example] in [/home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ciuser/travis-heroku-java-example/src/main/webapp]
[INFO] Webapp assembled in [86 msecs]
[INFO] Building war: /home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] <<< heroku-maven-plugin:0.3.6:deploy-war (default-cli) # travis-heroku-java-example <<<
[INFO]
[INFO] --- heroku-maven-plugin:0.3.6:deploy-war (default-cli) # travis-heroku-java-example ---
[INFO] Configured Artifact: com.github.jsimone:webapp-runner:7.0.57.2:jar
[INFO] Copying webapp-runner-7.0.57.2.jar to /home/ciuser/travis-heroku-java-example/target/dependency/webapp-runner.jar
[INFO] ---> Packaging application...
[INFO] - app: possessed-cemetery-7933
[INFO] - including: target/dependency/webapp-runner.jar
[INFO] - including: target/travis-heroku-java-example.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.636s
[INFO] Finished at: Fri Apr 24 03:33:35 UTC 2015
[INFO] Final Memory: 19M/46M
[INFO] ------------------------------------------------------------------------
[**ERROR] Failed to execute goal com.heroku.sdk:heroku-maven-plugin:0.3.6:deploy-war (default-cli) on project travis-heroku-java-example: Failed to deploy application: Forbidden -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.heroku.sdk:heroku-maven-plugin:0.3.6:deploy-war (default-cli) on project travis-heroku-java-example: Failed to deploy application**
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to deploy application
at com.heroku.sdk.maven.DeployWarMojo.execute(DeployWarMojo.java:24)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.apache.http.client.HttpResponseException: Forbidden
at com.heroku.sdk.deploy.RestClient.handleResponse(RestClient.java:87)
at com.heroku.sdk.deploy.RestClient.get(RestClient.java:26)
at com.heroku.sdk.deploy.ConfigVars.getConfigVars(ConfigVars.java:39)
at com.heroku.sdk.deploy.ConfigVars.merge(ConfigVars.java:22)
at com.heroku.sdk.deploy.App.mergeConfigVars(App.java:152)
at com.heroku.sdk.deploy.App.deploy(App.java:81)
at com.heroku.sdk.deploy.App.deploy(App.java:87)
at com.heroku.sdk.deploy.WarApp.deploy(WarApp.java:29)
at com.heroku.sdk.maven.DeployWarMojo.execute(DeployWarMojo.java:20)
... 21 more
[ERROR]
[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
$
Error Message in the above output:
[**ERROR] Failed to execute goal com.heroku.sdk:heroku-maven-plugin:0.3.6:deploy-war (default-cli) on project travis-heroku-java-example: Failed to deploy application: Forbidden -> [Help 1]
Here is the Maven System configuration:
$ mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-79-generic", arch: "amd64", family: "unix"
Java Version is:
$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>travis-heroku-java-example</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Simple Web Application</name>
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.4_spec</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>rubygems-releases</id>
<url>http://rubygems-proxy.torquebox.org/releases</url>
</pluginRepository>
</pluginRepositories>
<build>
<finalName>travis-heroku-java-example</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>0.3.6</version>
<configuration>
<appName>possessed-cemetery-7933</appName>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>0.3.6</version>
<configuration>
<appName>boiling-beach-1111</appName>
</configuration>
</plugin>
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-maven-plugin</artifactId>
<version>1.0.5</version>
<configuration>
<execArgLines>
<execArgLine>${project.build.directory}/rubygems/bin/travis</execArgLine>
<execArgLine>encrypt</execArgLine>
<execArgLine>HEROKU_API_KEY=${herokuApiKey}</execArgLine>
</execArgLines>
</configuration>
<dependencies>
<dependency>
<groupId>rubygems</groupId>
<artifactId>travis</artifactId>
<version>1.7.1</version>
<type>gem</type>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>pry</artifactId>
<version>0.9.12.6</version>
<type>gem</type>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I found what the issue was!!!
Heroku deploy-war maven plugin requires Maven 3.2.X version while I was using 3.0.X version.
Installed Maven 3.2.1 version on my ubuntu machine and the war file was successfully deployed to Heroku.
I got to know this from Github Heroku Maven plugin repository Readme file:
Requirements
Maven 3.2.x
Java 1.7 or higher
Thank you #Steve for your time.
Output:
$ maven -version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T17:37:52+00:00)
Maven home: /usr/share/maven3
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-79-generic", arch: "amd64", family: "unix"
$
$
$
$ maven -e clean heroku:deploy-war
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.example:travis-heroku-java-example:war:0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 31, column 11
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple Web Application 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # travis-heroku-java-example ---
[INFO] Deleting /home/ciuser/travis-heroku-java-example/target
[INFO]
[INFO] >>> heroku-maven-plugin:0.3.6:deploy-war (default-cli) # travis-heroku-java-example >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # travis-heroku-java-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ciuser/travis-heroku-java-example/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # travis-heroku-java-example ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /home/ciuser/travis-heroku-java-example/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # travis-heroku-java-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ciuser/travis-heroku-java-example/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # travis-heroku-java-example ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # travis-heroku-java-example ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # travis-heroku-java-example ---
[INFO] Packaging webapp
[INFO] Assembling webapp [travis-heroku-java-example] in [/home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ciuser/travis-heroku-java-example/src/main/webapp]
[INFO] Webapp assembled in [38 msecs]
[INFO] Building war: /home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] <<< heroku-maven-plugin:0.3.6:deploy-war (default-cli) # travis-heroku-java-example <<<
[INFO]
[INFO] --- heroku-maven-plugin:0.3.6:deploy-war (default-cli) # travis-heroku-java-example ---
[INFO] Configured Artifact: com.github.jsimone:webapp-runner:7.0.57.2:jar
[INFO] Copying webapp-runner-7.0.57.2.jar to /home/ciuser/travis-heroku-java-example/target/dependency/webapp-runner.jar
[INFO] ---> Packaging application...
[INFO] - app: boiling-beach-1111
[INFO] - including: target/dependency/webapp-runner.jar
[INFO] - including: target/travis-heroku-java-example.war
[INFO] - installing: OpenJDK 1.8
[INFO] ---> Creating slug...
[INFO] - file: target/heroku/slug.tgz
[INFO] - size: 56MB
[INFO] ---> Uploading slug...
[INFO] - stack: cedar-14
[INFO] - process types: [web]
[INFO] ---> Releasing...
[INFO] - version: 6
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.265 s
[INFO] Finished at: 2015-04-24T20:05:46+00:00
[INFO] Final Memory: 19M/48M
[INFO] ------------------------------------------------------------------------

Maven cannot find tomcat7 goal while using tomcat7-maven-plugin

I'm facing a problem while trying to setup my webapp deployment to tomcat 7 using maven tomcat plugin.
settings.xml:
<server>
<id>server</id>
<username>admin</username>
<password>password</password>
</server>
pom.xml:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>server</server>
<url>http://localhost:8080/manager/text</url>
<path>/myapp</path>
</configuration>
</plugin>
When I'm starting to type mvn tom<tab> autocomplete suggests me only mvn tomcat:.
The output for mvn tomcat:list is:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'tomcat'.
[INFO] ------------------------------------------------------------------------
[INFO] Building myapp
[INFO] task-segment: [tomcat:list]
[INFO] ------------------------------------------------------------------------
[INFO] [tomcat:list {execution: default-cli}]
[INFO] Listing applications at http://localhost:8080/manager
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot invoke Tomcat manager
Embedded error: http://localhost:8080/manager/list
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Sun Dec 22 21:37:08 MSK 2013
[INFO] Final Memory: 13M/211M
[INFO] ------------------------------------------------------------------------
It looks like that the tomcat6-maven-plugin is actually in use.
The output for mvn tomcat7:list is:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Required goal not found: tomcat7:list in org.apache.tomcat.maven:tomcat7-maven-plugin:2.2
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sun Dec 22 21:43:41 MSK 2013
[INFO] Final Memory: 7M/116M
[INFO] ------------------------------------------------------------------------
I'm using Ubuntu 13.10, all software is installed via repository.
As far as I know , some goals are yet not available with the tomcat7 mojo and mvn tomcat7:list is one of them. mvn tomcat6:list is available for the tomcat6 mojo.

Categories