Code Coverage reports are not getting reflected on sonarqube dashboard - maven

I am having the scoverage.xml report generated using command:
mvn verify sonar:sonar
getting output as:
Run completed in 2 minutes, 39 seconds.
Total number of tests run: 10
Suites: completed 5, aborted 0
Tests: succeeded 10, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
[INFO]
[INFO] <<< scoverage-maven-plugin:1.4.1:report (default) < [scoverage]test # ccr-reporting <<<
[INFO]
[INFO] --- scoverage-maven-plugin:1.4.1:report (default) # ccr-reporting ---
[INFO] Reading scoverage instrumentation [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/scoverage-data/scoverage.coverage]...
[INFO] Reading scoverage measurements [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/scoverage-data/scoverage.measurements.*]...
[INFO] Generating coverage reports...
[INFO] Written Cobertura XML report [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/cobertura.xml]
[INFO] Written XML coverage report [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/scoverage.xml]
[INFO] Written HTML coverage report [/mrit_cm2/rawasum/ds-rfds-falconnet/falcon-agents/dispatcher-tasks/ccr-reporting/target/site/scoverage/index.html]
[INFO] Statement coverage.: 36.07%
[INFO] Branch coverage....: 6.25%
[INFO] Coverage reports completed.
And analysis is also successfull:
[INFO] 5 files to be analyzed
[INFO] 5/5 files analyzed
[INFO] Calculating CPD for 13 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 151ms, dir size=384 KB
[INFO] Analysis report compressed in 100ms, zip size=127 KB
[INFO] Analysis report uploaded in 244ms
[INFO] ANALYSIS SUCCESSFUL, you can browse to ---
But the dashboard is showing 0.0% code coverage
here is my pom.xml having these important data. I have mentioned the jacoco, surefire plugin. My scoverage.xml report is getting generated having the branch coverage and statement coverage.
<properties>
<junit.version>4.12</junit.version>
<scalatest.version>3.0.8</scalatest.version>
<scala.version>2.11.8</scala.version>
<scala.major.version>2.11</scala.major.version>
<maven-scala-plugin.version>2.15.2</maven-scala-plugin.version>
<scalatest-maven-plugin.version>1.0</scalatest-maven-plugin.version>
<sonar.scala.scoverage.reportPath>target/scoverage.xml</sonar.scala.scoverage.reportPath>
<sonar.coverage.jacoco.xmlReportPaths>target/scoverage.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>target/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>target/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
What is missing? How can I resolve?

Related

Maven Invoker Plugin not detecting failed test

As part of a root parent pom project, several integration tests have been added to test it on sample projects.
The structure of the project folder is as following:
-root-maven-parent-project
|- src
| |-it
| |-sample-project-test1
| |-sample-project-test2
| |-sample-project-test3
| |-settings.xml
|- pom.xml
The main issue is: although the build of sample-project-test2 is wrongly failing (it should not), the build is SUCCESSFUL for the Invoker plugin and the overall build does not fail.
Here is the concerned maven-invoker-plugin configuration:
<profile>
<id>it-tests</id>
<build>
<plugins>
<!-- Integration tests configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<streamLogs>true</streamLogs>
<goals>
<goal>clean</goal>
<goal>generate-sources</goal>
</goals>
<settingsFile>src/it/settings.xml</settingsFile>
<failIfNoProjects>true</failIfNoProjects>
</configuration>
<executions>
<execution>
<id>integration-test-release</id>
<goals>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<cloneProjectsTo>${project.build.directory}/its/sample-project-test1</cloneProjectsTo>
<pom>src/it/sample-project-test1/pom.xml</pom>
<properties>
<scmBranch>release-something</scmBranch>
</properties>
</configuration>
</execution>
<execution>
<id>integration-test-hotfix</id>
<goals>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<cloneProjectsTo>${project.build.directory}/its/sample-project-test2</cloneProjectsTo>
<pom>src/it/sample-project-test2/pom.xml</pom>
<properties>
<scmBranch>hotfix-something</scmBranch>
</properties>
</configuration>
</execution>
<execution>
<id>integration-test-master</id>
<goals>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<cloneProjectsTo>${project.build.directory}/its/sample-project-test3</cloneProjectsTo>
<pom>src/it/sample-project-test3/pom.xml</pom>
<properties>
<scmBranch>master</scmBranch>
</properties>
</configuration>
</execution>
</plugin>
</plugins>
</build>
</profile>
As you can see, multiple executions are configured because each execution would need its own properties. Each execution is also pointing at its own integration test project and pom.
The build is clearly failing for a specific execution:
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 2.337 s
[INFO] [INFO] Finished at: 2017-07-04T17:35:49+02:00
[INFO] [INFO] Final Memory: 12M/220M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-snapshot-management) on project cmp-sample-project-test2: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[INFO] [ERROR]
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR]
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] pom.xml .......................................... FAILED (4.1 s)
[INFO] The build exited with code 1. See C:\data\git-repositories\root-maven-parent\target\its\sample-project-test2\build.log for details.
However, at the bottom of the build we see that the verify goal of the maven-invoker-plugin aggregated the results, flagged the concerned test as Passed and made the build SUCCESS:
[INFO]
[INFO] --- maven-invoker-plugin:3.0.0:verify (integration-test-release) # root-maven-parent ---
[INFO] -------------------------------------------------
[INFO] Build Summary:
[INFO] Passed: 1, Failed: 0, Errors: 0, Skipped: 0
[INFO] -------------------------------------------------
[INFO]
[INFO] --- maven-invoker-plugin:3.0.0:verify (integration-test-hotfix) # root-maven-parent ---
[INFO] -------------------------------------------------
[INFO] Build Summary:
[INFO] Passed: 1, Failed: 0, Errors: 0, Skipped: 0
[INFO] -------------------------------------------------
[INFO]
[INFO] --- maven-invoker-plugin:3.0.0:verify (integration-test-master) # root-maven-parent ---
[INFO] -------------------------------------------------
[INFO] Build Summary:
[INFO] Passed: 1, Failed: 0, Errors: 0, Skipped: 0
[INFO] -------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Moreover, by only running the failing test from command line as:
mvn invoker:integration-test#integration-test-hotfix invoker:verify -Pit-tests
The sub-build of the test project fails, the output is correctly marked as Failed in the test summary, and the build is correctly ending with FAILURE.
Question: why when executing multiple integration tests using the maven-invoker-plugin, although a test is failed, it is marked as Passed in the test summary and the build does not fail, while running only the isolated test everything fails correctly?
Note: no invoker property file is used.
Issue solved with the following explanation, although I think something could be improved in the behavior of the plugin (see below).
The whole maven-invoker-plugin was reduced to the following configuration:
<profile>
<id>it-tests</id>
<build>
<plugins>
<!-- Integration tests configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<streamLogs>true</streamLogs>
<goals>
<goal>clean</goal>
<goal>generate-sources</goal>
</goals>
<settingsFile>src/it/settings.xml</settingsFile>
<failIfNoProjects>true</failIfNoProjects>
<cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
</configuration>
<executions>
<execution>
<id>integration-test-release</id>
<goals>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Basically: only one plugin execution, instead of an execution per test, which indeed was verbose and non scalable, but forced by the need of having different values for the same property in each integration test. Apparently, this is not possible via pom configuration and only achievable - unless I am not mistaken - via a test.properties file.
Hence, as a complement to the configuration above, I added in each and every integration test project folder a test.properties file with the following content e.g.:
scmBranch=master
De facto replacing what in the pom.xml file was (as part of an execution of the maven-invoker-plugin:
<properties>
<scmBranch>master</scmBranch>
</properties>
This mechanism (single execution of the plugin + test properties file per test folder) fixed the issue, allowing the build to have multiple integration tests each with its own different value for the same property. Hopefully this solution may help troubleshooting similar issues.
Here is the final result from the build correctly aggregating tests and effectively respecting their sub-build output (while before the build was generating 6 Build Summary of Passed: 1 each time, although not correct).
[INFO] --- maven-invoker-plugin:3.0.0:verify (pom-integration-test) # root-maven-parent ---
[INFO] -------------------------------------------------
[INFO] Build Summary:
[INFO] Passed: 6, Failed: 0, Errors: 0, Skipped: 0
[INFO] -------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
However, some questions remain:
Without using the test.properties file, how to achieve the same via pom.xml configuration? Normally, it should only be an alternative, not a mandatory and only possible solution. That's why this is rather a uncomplete feature (a bug?) to me.
Having multiple execution of the plugin results in test summaries at the end of the build which correctly follow the executions order, the number of tests executed (always 1 per execution, in this case), but apparently do not reflect the effective result of each sub-build. Why? This is rather a bug or a misbehavior of the plugin due to an unexpected usage of it, perhaps.
use this configuration :-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<configuration>
<rules>
<banDuplicateClasses>
<findAllDuplicates>true</findAllDuplicates>
</banDuplicateClasses>
</rules>
<fail>false</fail>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<version>1.0-alpha-1</version>
</dependency>
</dependencies>
</plugin>
for more refer this link :
http://maven.apache.org/enforcer/maven-enforcer-plugin/

How to run Spek tests with Maven?

I'm trying to run Spek tests with Maven. I have set up maven like this:
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration/>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Additionally I have a few Spek tests in src/test/kotlin. I can run these fine within the IDE, but when I run mvn test they are completely ignored by the surefire plugin (it reports 0 tests being run). Is it possible to run Spek tests with maven and if so, how would this be set up? I cannot find anything about it on the spek homepage.
I could reproduce your issue with a small sample project, that you can find on GitLab.com.
If you run mvn clean test, surefire won't find any tests:
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # spek-maven-sample ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.074 s
[INFO] Finished at: 2016-07-27T00:49:14+02:00
[INFO] Final Memory: 36M/363M
[INFO] ------------------------------------------------------------------------
This can be circumvented by explicitly including test specs in the Surefire plugin. Say, all your specs are named *Spec.*, then explicitly configuring surefire in your pom.xml:
<build>
<plugins>
<!-- other build plugins like the kotlin-maven-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<includes>
<include>**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
will lead to executing tests
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # spek-maven-sample ---
[INFO] Surefire report directory: C:\Dev\IDEA\spek-test\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running NonsenseTestableSpec
Proof that 'should return true' ran
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.077 sec
Results :
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.335 s
[INFO] Finished at: 2016-07-27T01:02:12+02:00
[INFO] Final Memory: 26M/363M
[INFO] ------------------------------------------------------------------------
You can find the full working example on the branch "explicit-surefire-config" of the mentioned repository.

why jmeter assertion failure but maven project mark success

I use jmeter-maven-plugin for maven and jmeter
In jmeter , I have some assertion failure , but why the maven project also marked success?
someone help me. Tanks!
here is my maven project pom.xml
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.10.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<overrideRootLogLevel>debug</overrideRootLogLevel>
<testFilesIncluded>
<jMeterTestFile>${includedTestFiles}</jMeterTestFile>
</testFilesIncluded>
<testFilesExcluded>
<excludeJMeterTestFile>${excluedTestFiles}</excludeJMeterTestFile>
</testFilesExcluded>
<jmeterPlugins>
<plugin>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-standard</artifactId>
</plugin>
</jmeterPlugins>
<propertiesJMeter>
<dateQueryValueS>${dateQueryValueS}</dateQueryValueS>>
</propertiesJMeter>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-standard</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
here is the build
mvn verify -DincludedTestFiles=*unshipOrder.jmx -DexcluedTestFiles=noneOfExclued -DdateQueryValueS="2016-04-28 09:09:53"
[INFO]
[INFO] -------------------------------------------------------
[INFO] P E R F O R M A N C E T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO]
[info]
[debug] JMeter is called with the following command line arguments: -n -t E:\study\jmeter\src\test\jmeter\xbn-online-unshipOrder.jmx -l E:\study\jmeter\target\jmeter\results\20160513-xbn-online-unshipOrder.jtl -d E:\study\jmeter\target\jmeter -L DEBUG -j E:\study\jmeter\target\jmeter\logs\xbn-online-unshipOrder.jmx.log
[info] Executing test: xbn-online-unshipOrder.jmx
[debug] Creating summariser <summary>
[debug] Created the tree successfully using E:\study\jmeter\src\test\jmeter\xbn-online-unshipOrder.jmx
[debug] Starting the test # Fri May 13 10:20:31 CST 2016 (1463106031631)
[debug] Waiting for possible shutdown message on port 4445
[debug] summary + 1 in 1s = 1.9/s Avg: 370 Min: 370 Max: 370 Err: 0 (0.00%) Active: 1 Started: 1 Finished: 0
[debug] summary + 1 in 0.1s = 10.4/s Avg: 64 Min: 64 Max: 64 Err: 1 (100.00%) Active: 0 Started: 1 Finished: 1
[debug] summary = 2 in 1s = 3.2/s Avg: 217 Min: 64 Max: 370 Err: 1 (50.00%)
[debug] Tidying up ... # Fri May 13 10:20:32 CST 2016 (1463106032341)
[debug] ... end of run
[info] Completed Test: xbn-online-unshipOrder.jmx
[INFO]
[INFO] Test Results:
[INFO]
[INFO] Tests Run: 1, Failures: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.629 s
[INFO] Finished at: 2016-05-13T10:20:32+08:00
[INFO] Final Memory: 22M/223M
[INFO] ------------------------------------------------------------------------
I think this is the way Maven works.
Here:
Maven executes the project through its lifecycle. While doing so its executes the plugins defined/configured in the pom.xml(Everything on the effective POM (in eclipse terms)).
So here "jmeter-maven-plugin" is one executor that's being executed during this process. The plugin does its job and provides the results.
Also maven completes its work with a SUCCESS note.Because the build from Mavens perspective is successful.
(This will be similar if you run JUnit/TestNG test suite)
Here its up to us to find a way(tool) to interpret the generated results in a presentable manner.
Try below:
Put it on a CI tool like Jenkins.(Explained in one of the links in
the answer by #DmitriT)
Use maven 3.0 dash board
jmeter-analysis-maven-plugin
jmeter-graph-maven-plugin
If you use version 2.6.0 of plugin or upper , you just have to set this:
<executions>
<execution>
<id>performance test</id>
<goals><goal>jmeter</goal></goals>
</execution>
<execution>
<id>verify</id>
<goals><goal>results</goal></goals>
</execution>
</executions>
Actually by default it should be failing, it's hard to say what's wrong without seeing your test plan and log files. What assertion is being used and how it is configured?
In the meantime you can try working it around by adding the following line to <configuration> section:
<ignoreResultFailures>false</ignoreResultFailures>
References:
Setting
JMeter Maven Plugin
Five Ways To Launch a JMeter Test without Using the JMeter GUI
You need to add this configuration to your POM file within the <configuration> tag
<scanResultsForFailedRequests>true</scanResultsForFailedRequests>
<ignoreResultFailures>false</ignoreResultFailures>
Also try taking out the <configuration> tag from the <executions> tag
and finally the executions block should look like this
<executions>
<execution>
<id>configure</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<execution>
<id>performance test</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>

Embedded error: Failed to transfer file: http://localhost:4502/apps/myProject-core.jar. Return code is: 401

I use the following profile to deploy my osgi bundle to CQ5/crx:
<id>deployToAuthor</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>echo Deployment auf Authoren-Instanz, myProject</id>
<phase>install</phase>
<configuration>
<tasks>
<echo
message="Deployment auf Instanz AUTHOR ! (${install.host}:${install.port}), myProject!"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-felix-bundle-author</id>
<phase>install</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>${project.build.directory}</fromDir>
<includes>*.jar</includes>
<excludes>pom.xml</excludes>
<serverId>${install.host}</serverId>
<url>dav:${webdav.protocol}://${install.host}:${install.port}</url>
<toDir>apps/${portal.name}/install</toDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I get the following Error:
[INFO] Tests are skipped.
[INFO] [bundle:bundle {execution: default-bundle}]
[WARNING] Bundle path.myProject:myProject-core:bundle:1.5.18-SNAPSHOT : Export path.myProject.components.alerts, has 1, private references [au.com.bytecode.opencsv],
[WARNING] Bundle path.myProject:myProject-core:bundle:1.5.18-SNAPSHOT : Export path.myProject.unionhtmlimport, has 1, private references [path.myProject.unionhtmlimport.impl],
[INFO] [resources:copy-resources {execution: copy-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [install:install {execution: default-install}]
[INFO] Installing C:\path\myProject\myProject-core\target\myProject-core.jar to C:\path\.m2\repository\path\myProject\myProject-core\1.5.18-SNAPSHOT\myProject-core-1.5.18-SNAPSHOT.jar
[INFO] [bundle:install {execution: default-install}]
[INFO] Installing path/myProject/myProject-core/1.5.18-SNAPSHOT/myProject-core-1.5.18-SNAPSHOT.jar
[INFO] Writing OBR metadata
[INFO] [antrun:run {execution: echo Deployment auf Authoren-Instanz, myProject}]
[INFO] Executing tasks
[echo] Deployment auf Instanz AUTHOR ! (localhost:4502), Project myProject!
[INFO] Executed tasks
[INFO] [wagon:upload {execution: upload-felix-bundle-author}]
[INFO] Uploading C:\path\myProject\myProject-core\target\myProject-core.jar to http://localhost:4502/apps/myProject/install/myProject-core.jar ...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error handling resource
Embedded error: Failed to transfer file: http://localhost:4502/apps/myProject/install/myProject-core.jar. Return code is: 401
Seems to be quite complicated. Why not to use Maven Sling plugin?
<project>
<properties>
<sling.url>http://localhost:4502</sling.url>
<sling.username>admin</sling.username>
<sling.password>admin</sling.password>
</properties>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>maven-sling-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<bundleFileName>${project.build.directory}/${project.build.finalName}.jar</bundleFileName>
<user>${sling.username}</user>
<password>${sling.password}</password>
<slingUrl>${sling.url}/system/console</slingUrl>
</configuration>
</plugin>
...
Usage:
mvn clean package sling:install
Also, please take a look on a sample project using this plugin: Sling-Query.

How to echo in Maven without Antrun plugin?

How can I print to the console while executing a mvn command (in a phase/goal), but not using Maven Antrun plugin?
Why I reject Antrun solutions:
The overhead in code to print a single message is massiv.
The output is no formated like maven output
I cannot attach a severity to the message (e.g. DEBUG, INFO, ERROR, etc)
Currently an Ant-echo looks like this (see line with "hello world"):
[INFO] --- maven-antrun-plugin:1.7:run (default) # ejpd-alertmanager-ear ---
[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks
main:
[echo] hello world
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
However, I expect it to look like this (see line with "hello world").
[INFO] --- maven-antrun-plugin:1.7:run (default) # ejpd-alertmanager-ear ---
[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks
[INFO] hello world
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I'm positive, I am missing something here, since I cannot be the first to raise this demand. Thank you for any smart hint.
You should try the Maven Echo plugin:
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>maven-echo-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>echo</goal>
</goals>
</execution>
</executions>
<configuration>
<echos>
<echo>This is the Text which will be printed out.</echo>
</echos>
</configuration>
</plugin>
Or furthermore take a deeper look into the integration test of the plugin.
which is available via Maven Central. BTW: If you have further requests/improvements just file in an issue.
You can use Björn Ekryd's Echo Maven Plugin, which is published in Maven Central.
It has a normal amount of XML required for a Maven plugin, the output is formatted like the other Maven log lines, and you can assign a severity level to your message (default is INFO).
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<version>1.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>echo</goal>
</goals>
<configuration>
<message>war has changed</message>
<level>INFO</level>
</configuration>
</execution>
</executions>
</plugin>
[INFO] --- maven-war-plugin:2.4:war (default-war) # mymodule ---
[INFO] Packaging webapp
[INFO] Processing war project
[INFO]
[INFO] --- echo-maven-plugin:1.2.0:echo (default) # mymodule ---
[INFO] war has changed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Also, this plugin has 95% code coverage, which is pretty cool.
You can use Groovy Maven Plugin for this.
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
log.info('Test message: {}', 'Hello, World!')
</source>
</configuration>
</execution>
</executions>
</plugin>
The configuration above will produce the following output:
[INFO] Test message: Hello, World!
I haven't tried this myself but there is a plugin here which may help:
http://code.google.com/p/maven-echo-plugin/

Resources