Maven: Does it work for not Java code? - maven

I'm newbie to maven (just 2 days playing with it).
I've some problems setting up maven with jacoco plugin and surefire/failsafe.
Despite it reads and copies the source files it doesn't compile them!
I set new directories as I don't follow the standard maven directory layout but it seems not working. The problem is that I cannot change my project's layout as it's the company's.
So, Im trying to solved it manually.
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.sonar</groupId>
<artifactId>example-java-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Code Coverage - Maven and JaCoCo running tests</name>
<properties>
<!-- Tell SonarQube to execute unit tests during analysis-->
<sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
<!-- Tell SonarQube to use Jacoco as the code coverage engine to generate the reports -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<!-- Display logs to see where the analyzer spends time -->
<sonar.showProfiling>true</sonar.showProfiling>
<sonar.branch>14.1</sonar.branch>
<sonar.language>tcl</sonar.language>
<project.exclude.list>target/**</project.exclude.list>
<test.failOnError>true</test.failOnError>
<basedir>.</basedir>
<!-- Used to locate the profile specific configuration file. -->
<build.profile.id>dev</build.profile.id>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Only unit tests are run by default. -->
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
<!-- Define where the jacoco reports are output -->
<jacoco.it.execution.data.file>${project.build.directory}/coverage-reports/jacoco-it.exec</jacoco.it.execution.data.file>
<jacoco.ut.execution.data.file>${project.build.directory}/coverage-reports/jacoco-ut.exec</jacoco.ut.execution.data.file>
<jacoco.it.execution.destfile>${project.build.directory}/coverage-reports/jacoco-it.exec</jacoco.it.execution.destfile>
<jacoco.ut.execution.destfile>${project.build.directory}/coverage-reports/jacoco-ut.exec</jacoco.ut.execution.destfile>
</properties>
<!-- Creating profiles for Development and Integration Testing
'dev' profile (default): used during development, only unit tests are run.
'integration-test' profile: used to run integration tests. -->
<profiles>
<profile>
<id>dev</id>
<!-- Dev profile is active by default -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!--Used to locate the profile specific configuration file-->
<build.profile.id>dev</build.profile.id>
<!-- Only unit tests are run by default. -->
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
<build>
<filters>
<!--Specifies path to the properties file, which contains profile specific configuration-->
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>integration-test</id>
<properties>
<!--Used to locate the profile specific configuration file-->
<build.profile.id>integration-test</build.profile.id>
<!-- Only integration tests are run. -->
<skip.integration.tests>false</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
<build>
<filters>
<!-- Specifies path to the properties file, which contains profile specific configuration. -->
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>all-tests</id>
<properties>
<build.profile.id>all-tests</build.profile.id>
<!-- All tests are run. -->
<skip.integration.tests>false</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
</profile>
</profiles>
<build>
<finalName>maven-integration-testing</finalName>
<sourceDirectory>.</sourceDirectory>
<testSourceDirectory>test/tcl</testSourceDirectory>
<filters>
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
<resources>
<resource>
<filtering>true</filtering>
<directory>.</directory>
<includes>
<include>*.tcl</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<filtering>true</filtering>
<directory>test/tcl</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerVersion>1.5</compilerVersion>
<source>1.5</source>
<target>1.5</target>
<showWarnings>true</showWarnings>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.8.1</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<!-- States that the plugin's add-test-source goal is
executed at generate-test-sources phase. -->
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<!-- Configures the source directory of integration tests -->
<sources>
<source>test/tcl</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<!-- Use the Surefire Maven plugin to run our unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.16</version>
</dependency>
</dependencies>
<configuration>
<!-- Sets the VM argument line used when unit tests are run.
we want to create a code coverage report for our unit tests,
we have to ensure that the JaCoCo agent is running
when our unit tests are run -->
<argLine>${surefireArgLine}</argLine>
<!-- Skips unit tests if the value of skip.unit.tests property is true -->
<skipTests>${skip.unit.tests}</skipTests>
<includes>
<include>test/tcl/*.tcl</include>
</includes>
<!-- Excludes integration tests when unit tests are run. -->
<excludes>
<exclude>**/IT*.java</exclude>
</excludes>
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</plugin>
<!-- Failsafe Maven plugin is used to execute our integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<executions>
<!-- States that both integration-test and verify goals
of the Failsafe Maven plugin are executed. -->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- we want to create a code coverage report for our integration tests,
we have to ensure that the JaCoCo agent is running
when our integration tests are run -->
<argLine>${failsafeArgLine}</argLine>
<!-- Skips integration tests if the value of skip.integration.tests property is true -->
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
<!-- JaCoCo Maven Plugin
1) provides us an access to the JaCoCo runtime agent which records
execution coverage data.
2) creates code coverage reports from the execution data recorded
by the JaCoCo runtime agent.
-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.4.201312101107</version>
<executions>
<!-- Make the agent run before the tests are run -->
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${jacoco.ut.execution.data.file}</destFile>
<!-- Sets the name of the property containing the settings for JaCoCo runtime agent. -->
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<!-- Make sure that the jacoco report task is run when package is executed -->
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<!-- Prepares the property pointing to the JaCoCo runtime agent which
is passed as VM argument when Maven the Surefire plugin is executed.-->
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${jacoco.ut.execution.data.file}</destFile>
<!-- Sets the name of the property containing the settings for JaCoCo runtime agent. -->
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<!--Ensures that the code coverage report for unit tests is
created after unit tests have been run. -->
<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>${jacoco.ut.execution.data.file}</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
<!-- Prepares the property pointing to the JaCoCo runtime agent which
is passed as VM argument when Maven the Failsafe plugin is executed. -->
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${jacoco.it.execution.data.file}</destFile>
<!-- Sets the name of the property containing the settings for JaCoCo runtime agent.-->
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<!-- Ensures that the code coverage report for integration tests after integration tests have been run.-->
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${jacoco.it.execution.data.file}</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- TESTING DEPENDENCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
</project>
.
**output**:
[INFO] ------------------------------------------------------------------------
[INFO] Building Code Coverage - Maven and JaCoCo running tests 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:prepare-agent (jacoco-initialize) # example-java-maven ---
[INFO] surefireArgLine set to -javaagent:.m2/repository/org/jacoco/org.jacoco.agent/0.6.4.201312101107/org.jacoco.agent-0.6.4.201312101107-runtime.jar=destfile=/util/target/coverage-reports/jacoco-ut.exec
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:prepare-agent (pre-unit-test) # example-java-maven ---
[INFO] surefireArgLine set to -javaagent:.m2/repository/org/jacoco/org.jacoco.agent/0.6.4.201312101107/org.jacoco.agent-0.6.4.201312101107-runtime.jar=destfile=/util/target/coverage-reports/jacoco-ut.exec
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) # example-java-maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 41 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # example-java-maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-test-source (add-integration-test-sources) # example-java-maven ---
[INFO] Test Source directory:util/test/tcl added.
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) # example-java-maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # example-java-maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) # example-java-maven ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:report (post-unit-test) # example-java-maven ---
[INFO] Skipping JaCoCo execution due to missing execution data file
[INFO]
[INFO] --- maven-jar-plugin:2.2:jar (default-jar) # example-java-maven ---
[INFO] Building jar:util/target/maven-integration-testing.jar
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:report (jacoco-site) # example-java-maven ---
[INFO] Skipping JaCoCo execution due to missing execution data file
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:prepare-agent (pre-integration-test) # example-java-maven ---
[INFO] failsafeArgLine set to -javaagent:.m2/repository/org/jacoco/org.jacoco.agent/0.6.4.201312101107/org.jacoco.agent-0.6.4.201312101107-runtime.jar=destfile=util/target/coverage-reports/jacoco-it.exec
[INFO]
[INFO] --- maven-failsafe-plugin:2.16:integration-test (integration-tests) # example-java-maven ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- jacoco-maven-plugin:0.6.4.201312101107:report (post-integration-test) # example-java-maven ---
[INFO] Skipping JaCoCo execution due to missing execution data file
[INFO]
[INFO] --- maven-failsafe-plugin:2.16:verify (integration-tests) # example-java-maven ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-install-plugin:2.3:install (default-install) # example-java-maven ---
[INFO] Installing util/target/maven-integration-testing.jar to .m2/repository/org/codehaus/sonar/example-java-maven/1.0-SNAPSHOT/example-java-maven-1.0-SNAPSHOT.jar
[INFO] Installing util/pom.xml to .m2/repository/org/codehaus/sonar/example-java-maven/1.0-SNAPSHOT/example-java-maven-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.054s
[INFO] Finished at: Fri Jan 03 13:35:38 GMT 2014
[INFO] Final Memory: 12M/132M
[INFO] ------------------------------------------------------------------------
>
EDIT:
Also, I wonder if Maven works for projects not with Java code.
Is there any way to make it support a scripting language? And run its tests?

Related

Jenkins Artifactory Plugin - Maven wrapper not publishing custom artifacts which have been installed

When building my Maven project, I expect the Jenkins Artifactory Plugin to deploy/publish artifacts which I successfully maven-install (ie, copied from the /target folder to my local maven repo).
The Jenkins-Artifactory plugin binds to the install phase of the Maven lifecycle. It is publishing the pom files for the modules of my project, but not the build files I need (which I have installed).
UPDATE: JFrog have confirmed this is a bug with the plugin: https://github.com/jfrog/jenkins-artifactory-plugin/issues/665 - I will post an update to this question once it is resolved.
PLEASE NOTE: A normal pom which simply creates a jar works as expected. This is specifically to do with publishing a custom artifact type having used the maven-install-plugin.
Some details:
The build process creates .bar files
These .bar files are added to /target using the maven-install-plugin execution shown below
The .pom files are being uploaded to Artifactory
The .bar files are not being uploaded to Artifactory
<execution>
<id>custom-install</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<generatePom>true</generatePom>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<file>${project.build.directory}/${project.build.finalName}.bar</file>
<packaging>bar</packaging>
</configuration>
</execution>
Logs:
16:50:39 [main] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-install-plugin:2.5.2:install-file (custom-install) # MyMavenModule ---
16:50:39 [main] INFO org.codehaus.plexus.PlexusContainer - Installing /opt/jenkins/workspace/my-project/build/develop/2/MyMavenModule/target/MyMavenModule-1.0.0.bar to /home/jenkins-user/.m2/repository/my/project/group/MyMavenModule/1.0.0/MyMavenModule-1.0.0.bar
16:50:40 [pool-1-thread-1] INFO org.jfrog.build.extractor.maven.ArtifactoryManagerBuilder - [pool-1-thread-1] Deploying artifact: https://artifactory.mycompany.com/artifactory/libs-local/my/project/group/MyMavenModule/1.0.0/MyMavenModule-1.0.0.pom
Versions:
Jenkins: 2.332.1
Artifactory: 6.16.0 Pro
Jenkins Artifactory Plugin: 3.16.1
Maven: 3.8.5
Maven install plugin: 3.0.0-M1
Pipeline / Plugin configuration
rtMavenResolver (
id: "resolver-${config.serverKey}",
serverId: config.serverKey,
releaseRepo: config.repos.resolve.release,
snapshotRepo: config.repos.resolve.snapshot
)
rtMavenDeployer (
id: "deployer-${config.serverKey}",
serverId: config.serverKey,
releaseRepo: config.repos.deploy.release,
snapshotRepo: config.repos.deploy.snapshot,
deployArtifacts : config.deployArtifacts,
includePatterns: config.repos.deploy.includePatterns,
excludePatterns: config.repos.deploy.excludePatterns,
properties: config.repos.deploy.properties,
)
rtBuildInfo (
captureEnv: true,
buildName: config.buildName,
buildNumber: config.buildNumber
)
def mvn(goals) {
rtMavenRun (
tool: config.tools.maven,
pom: 'pom.xml',
goals: "-U -e -B -V -Dstyle.color=always $goals",
opts: '-Dmaven.test.failure.ignore=false -Djansi.force=true',
deployerId: "deployer-${config.artifacts.serverKey}",
resolverId: "resolver-${config.artifacts.serverKey}",
buildName: config.artifacts.buildName,
buildNumber: config.artifacts.buildNumber
)
}
<<<snip>>>
mvn 'install -Dmaven.test.skip=true -DskipTests'
Reproducible Example:
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<url>http://maven.apache.org</url>
<groupId>com.example</groupId>
<artifactId>MyModule</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<properties>
<exec-maven-plugin-version>1.6.0</exec-maven-plugin-version>
<maven-install-plugin-version>3.0.0-M1</maven-install-plugin-version>
</properties>
<build>
<plugins>
<!-- Note: See 'http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html' for details -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven-install-plugin-version}</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
<id>custom-install</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<generatePom>true</generatePom>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<file>${project.build.directory}/${project.build.finalName}.bar</file>
<packaging>bar</packaging>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>Windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin-version}</version>
<executions>
<execution>
<id>execution.compile.windows.buildBAR</id>
<phase>compile</phase>
<configuration>
<workingDirectory>${project.build.directory}</workingDirectory>
<executable>buildBAR.cmd</executable>
<arguments>
<argument>${iib.toolkit.path.windows}</argument>
<argument>${project.artifactId}</argument>
<argument>${project.build.finalName}</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin-version}</version>
<executions>
<execution>
<id>execution.compile.unix.buildBAR</id>
<phase>compile</phase>
<configuration>
<workingDirectory>${project.build.directory}</workingDirectory>
<executable>sh</executable>
<arguments>
<argument>buildBAR.sh</argument>
<argument>${project.artifactId}</argument>
<argument>${project.build.finalName}</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
</project>
buildBAR.cmd
SET moduleName=%1
SET barfileName=%2
echo %moduleName% > %barfileName%.bar
buildBAR.sh
#!/bin/sh
moduleName=$1
barfileName=$2
echo $moduleName > $barfileName.bar
mvn clean install yeilds:
PS C:\dev\barbuilder> mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.example:MyModule >------------------------
[INFO] Building MyModule 1.0.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # MyModule ---
[INFO] Deleting C:\dev\barbuilder\target
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (execution.compile.windows.buildBAR) # MyModule ---
C:\dev\barbuilder\target>SET moduleName=MyModule
C:\dev\barbuilder\target>SET barfileName=MyModule-1.0.0-SNAPSHOT
C:\dev\barbuilder\target>echo MyModule 1>MyModule-1.0.0-SNAPSHOT.bar
[INFO]
[INFO] --- maven-install-plugin:3.0.0-M1:install (default-install) # MyModule ---
[INFO] Skipping artifact installation
[INFO]
[INFO] --- maven-install-plugin:3.0.0-M1:install-file (custom-install) # MyModule ---
[INFO] Installing C:\dev\barbuilder\target\MyModule-1.0.0-SNAPSHOT.bar to C:\Users\denham.coote\AppData\Local\.m2\repository\com\example\MyModule\1.0.0-SNAPSHOT\MyModule-1.0.0-SNAPSHOT.bar
[INFO] Installing C:\Users\DENHAM~1.COO\AppData\Local\Temp\mvninstall1034342466988970935.pom to C:\Users\denham.coote\AppData\Local\.m2\repository\com\example\MyModule\1.0.0-SNAPSHOT\MyModule-1.0.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.217 s
[INFO] Finished at: 2022-04-04T12:29:59+01:00
[INFO] ------------------------------------------------------------------------
PS C:\dev\barbuilder>

mvn does not run test on appCenter

I want to run my appium test on AppCenter and I have followed this documents
https://learn.microsoft.com/en-us/appcenter/test-cloud/preparing-for-upload/appium#prerequisites
When I run appium script on appCenter it does not show any error but give me output as
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------
[INFO] Building run-test 1.0-SNAPSHOT
[INFO] ----------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # run-test ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # run-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # run-test ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # run-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.20:test (default-test) # run-test ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.testscripts.RegressionTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.247 s - in com.testscripts.RegressionTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # run-test ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: target/run-test-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-failsafe-plugin:2.20:integration-test (default) # run-test ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}.
[INFO]
[INFO] --- maven-failsafe-plugin:2.20:verify (default) # run-test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.623 s
[INFO] Finished at: 2018-08-06T07:39:58+02:00
[INFO] Final Memory: 17M/214M
[INFO] ------------------------------------------------------------------------
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>Cure.fit</groupId>
<artifactId>Cure.fit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Automation Test Project</name>
<description>Automation Test Project</description>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.appcenter</groupId>
<artifactId>appium-test-extension</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
<profiles>
<profile>
<id>repl</id>
<dependencies>
<dependency>
<groupId>com.javarepl</groupId>
<artifactId>javarepl</artifactId>
<version>428</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<classpathScope>test</classpathScope>
<arguments>
<argument>-Djansi.passthrough=true</argument>
<argument>-classpath</argument>
<classpath />
<argument>javarepl.Main</argument>
</arguments>
</configuration>
<executions>
<execution>
<id>runRepl</id>
<phase>process-test-classes</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Added for AppCenter/Test runs -->
<profile>
<id>prepare-for-upload</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/upload/dependency-jars/</outputDirectory>
<useRepositoryLayout>true</useRepositoryLayout>
<copyPom>true</copyPom>
<addParentPoms>true</addParentPoms>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>generate-pom</id>
<phase>package</phase>
<goals>
<goal>effective-pom</goal>
</goals>
<configuration>
<output>${project.build.directory}/upload/pom.xml</output>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-testclasses</id>
<phase>package</phase>
<goals>
<goal>testResources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/upload/test-classes</outputDirectory>
<resources>
<resource>
<directory>
${project.build.testOutputDirectory}
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
When I run the same project as mvn test I am able to run the test.
I have kept my JUnit testcase name as RegressionTest.java under src/test/java which extends Support.java which is also Junit file.
Could any one can help me what is the mistake I am doing.

Maven runs profile executions only after the build executions

Given a following maven pom.xml development profile
<profiles>
<profile>
<id>development</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.0.4</version>
<executions>
<execution>
<id>01-liquibase.dropAll</id>
<phase>process-resources</phase>
<configuration>
[...skip...]
</configuration>
<goals>
<goal>dropAll</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
and main section of pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<includes>package/pm/entity/**/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<persistenceXmlFile>${project.parent.basedir}/forms-webapp/src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
</configuration>
<executions>
<execution>
<id>02-enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.0.4</version>
<executions>
<execution>
<id>03-liquibase.update</id>
<phase>process-resources</phase>
<configuration>
[...skipped...]
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
<!-- for tests -->
<execution>
<id>04-liquibase-test.dropAll</id>
<phase>process-test-resources</phase>
<configuration>
[...skipped...]
</configuration>
<goals>
<goal>dropAll</goal>
</goals>
</execution>
<execution>
<id>05-liquibase-test.update</id>
<phase>process-test-resources</phase>
<configuration>
[...skipped...]
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I expect that executions will run in the following order:
....
01-liquibase.dropAll
03-liquibase.update
....
But in build log I see:
[INFO] --- liquibase-maven-plugin:3.0.4:update (03-liquibase.update) # forms-entity ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: src/main/resources/liquibase.properties
[INFO] 'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:postgresql://localhost/pman_trunk
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO]
[INFO] --- liquibase-maven-plugin:3.0.4:dropAll (01-liquibase.dropAll) # forms-entity ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: src/main/resources/liquibase.properties
[INFO] 'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:postgresql://localhost/pman_trunk
[INFO] ------------------------------------------------------------------------
Is there any way to fix this wrong execution order?
The executions for id 01-liquibase.dropAll and 03-liquibase.update are executing on the same phase.
You could always move the execution with id 01-liquibase.dropAll to an earlier phase such as generate-resources
<id>01-liquibase.dropAll</id>
<phase>process-resources</phase>
See the Default Lifecycle section in Maven Lifecycle Reference.

Unable to execute wsdl2java with maven

I want to execute wsdl2java with maven but I have the following build failure :
[INFO] --- maven-dependency-plugin:2.1:copy (default) # mogopay ---
[INFO] Configured Artifact: javax.xml.bind:jaxb-api:2.2:jar
[INFO] Configured Artifact: javax.xml.ws:jaxws-api:2.2:jar
[INFO] Copying jaxb-api-2.2.jar to c:\Users\EBIZNEXT\git\mogopay-core\mogopay\target\endorsed\jaxb-api-2.2.jar
[INFO] Copying jaxws-api-2.2.jar to c:\Users\EBIZNEXT\git\mogopay-core\mogopay\target\endorsed\jaxws-api-2.2.jar
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (copy-tomcat-resources) # mogopay ---
[INFO] Executing tasks
[INFO] Executed tasks
[INFO]
[INFO] --- cxf-codegen-plugin:2.4.2:wsdl2java (CXF Payline) # mogopay ---
[INFO] Running wsdl2java in fork mode...
[INFO] Building jar: C:\Users\EBIZNEXT\AppData\Local\Temp\cxf-tmp-679212\cxf-codegen5225275003143491559.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:30.351s
[INFO] Finished at: Tue Jan 22 18:28:57 CET 2013
[INFO] Final Memory: 14M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.4.2:wsdl2java (CXF Payline) on project mogopay:
[ERROR] Exit code: 1 - Exception in thread "main" org.apache.cxf.tools.common.ToolException: java.lang.reflect.UndeclaredThrowableException
[ERROR] at
...
[ERROR] Caused by: java.lang.NoSuchMethodException: javax.xml.bind.annotation.XmlElementRef.required()
[ERROR] at java.lang.Class.getDeclaredMethod(Class.java:1954)
[ERROR] at com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.java:107)
[ERROR] ... 27 more
[ERROR]
[ERROR] Command line was: "c:\Program Files\Java\jdk1.7.0\jre\bin\java.exe" -Djava.endorsed.dirs=c:\Users\EBIZNEXT\git\mogopay-core\mogopay\target/endorsed -jar
C:\Users\EBIZNEXT\AppData\Local\Temp\cxf-tmp-679212\cxf-codegen5225275003143491559.jar C:\Users\EBIZNEXT\AppData\Local\Temp\cxf-tmp-679212\cxf-w2j3628405823287
641812args
This project is built in grails 2.0.3. It seems that the problem comes from Jaxb because the current version in grails uses jaxb-api-2.1 while the project needs jaxb 2.2. I have updated my pom as it has been suggested from this answer : Set Java Compliance Level in CXF wsdl2java and also here : Example 7 - Using JAXB/JAX-WS 2.2 with Java 6. But when I execute maven command : mvn clean install, I get the error above.
Here is my pom (I removed the unimportant parts):
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArguments>
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.endorsed.dirs=${project.build.directory}/endorsed</argLine>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2</version>
</artifactItem>
<artifactItem>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
...
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<fork>once</fork>
<additionalJvmArgs>-Djava.endorsed.dirs=${project.build.directory}/endorsed</additionalJvmArgs>
</configuration>
<dependencies>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>CXF Payline</id>
<phase>process-resources</phase>
<configuration>
<sourceRoot>${basedir}/src/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/java/wsdl/Payline_DirectPaymentAPI.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Any suggestion would be appreciated
Java 7 already includes jaxb 2.2 (actualy 2.2.4-1 as you can see here), so you don't need to add any dependency to that artifact. If this artifact conflicts with grails 2.0.3 dependencies, try excluding jaxb from grails dependency, maybe grails is happy with jaxb 2.2.
This should be a comment, but I'm begind a proxy that filters javascript and I cannot use comments feature. Sorry for my English to!

Disable maven plugins when using a specific profile

I'm looking to find a way of disabling a plugin execution if running with a particular profile.
This is the opposite of running a plugin if a profile is selected.
My use case: My Maven build has a whole load of plugins, but when running on my dev machine, I want to skip some of them. Instead of commenting those plugins out locally, I want to be able just run the build with a "dev" profile. The plugins would continue to run on my continuous build.
Ideas?
There is a neat way to disable plugin execution when specific profile is active.
Firstly you need to add an identifier to plugin execution like:
<build>
<plugins>
<!-- (...) -->
<plugin>
<groupId>nl.geodienstencentrum.maven</groupId>
<artifactId>sass-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>styles-compilation</id> <!-- plugin execution identifier -->
<phase>generate-resources</phase>
<goals>
<goal>update-stylesheets</goal>
</goals>
</execution>
</executions>
</plugin>
Then you need to define a profile in which this plugin will NOT be executed:
<profiles>
<profile>
<id>no-sass</id>
<build>
<plugins>
<plugin>
<groupId>nl.geodienstencentrum.maven</groupId>
<artifactId>sass-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>styles-compilation</id> <!-- here there must be the same identifier as defined in <build><plugins> section -->
<phase>none</phase> <!-- this disables plugin -->
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Now if you run standard maven build:
mvn clean package
the sass-maven-plugin will be executed, yet when running:
mvn clean package -P no-sass
the sass-maven-plugin will not be executed.
Define your pom so that is has only the plugins you need in dev mode
Define a dev profile
Define a production profile which contains all plugins you want/need
Define the production profile as default
example pom:
<profiles>
<profile>
<id>production</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<!--
<plugin>
...
</plugin>
-->
</plugins>
</build>
</profile>
<profile>
<id>dev</id>
<!-- Some other logic here, if necessary.
Otherwise, there's no need for another profile. -->
</profile>
</profiles>
To run in Dev Mode you can call the following:
mvn -Pdev compile
To run in Production Mode just use the normal steps:
mvn compile
In case you don't want/need to define anything special in your dev profile, you can omit its declaration and call your Dev Mode like this (! disables a profile):
mvn -P!production compile
Be aware: you may need to escape the exclamation mark since it is a special character in bash:
mvn -P\!production compile
Building on Krzysiek's answer, you don't need to define explicit executions, just have a look at the output maven gives you and disable the default executions.
For instance, given the following output from maven:
[INFO] --- maven-resources-plugin:2.7:copy-resources (prepare-dockerfile) # tilbud ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
...
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) # tilbud ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
....
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # tilbud ---
...
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) # tilbud ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
...
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) # tilbud ---
....
The generated default execution names is listed in parenthesis after the plugin and goal. The following profile disables the plugins above:
<profiles>
<profile>
<id>packageOnly</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>default-resources</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testResources</id>
<phase>none</phase>
</execution>
<execution>
<id>prepare-dockerfile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

Resources