On Gitlab jacoco maven plugin not creating report or folder - maven

I have a maven build with a jacoco plugin to measure coverage. This works locally and creates the report as expected. I then wanted to pull the report into gitlab and included the file as an artifact. This never worked though and using script command to list the directory I can see the the report folder has not been created.
from the pom.xml:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<configuration>
<output>file</output>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>./coverage-reports/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
From gitlab-ci.yml
UnitTest:
stage: test
services:
- name: postgres:latest
alias: postgres
script:
- mvn clean test -DargLine="-Dspring.datasource.url=jdbc:postgresql://postgres:5432/$POSTGRES_DB -Dspring.datasource.password=$POSTGRES_PASSWORD" -DcodegenFile="$CODEGEN_FILE"
- pwd
- ls
- cd target
- ls
- cd coverage-reports
- ls
- cd jacoco-ut
- ls
only:
- merge_requests
output from the build:
$ pwd
/builds/BJSS/Sheffield-Engineering/carbon-adjusted-workload-scheduler
$ ls
Dockerfile
README.md
checkstyle-suppressions.xml
checkstyle.xml
docker-compose.yml
docker_postgres_init.sql
documentation
hooks
maven-settings.xml
mvnw
mvnw.cmd
pom.xml
rest
src
target
$ cd target
1291$ ls
checkstyle-cachefile
checkstyle-checker.xml
checkstyle-result.xml
checkstyle-suppressions.xml
classes
generated-sources
generated-test-sources
maven-status
surefire-reports
test-classes
this works on my local computer just not on gitlab, any ideas please ?
thanks

Related

Maven deploy: deployment should fail if artifact already exists

If I configure my pom.xml as below:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>nexus</serverId>
<nexusUrl>https://nexus/</nexusUrl>
<skipStaging>false</skipStaging>
</configuration>
</plugin>
Then what happens is that on executing mvn deploy -this will deploy projectName-1.0-20180323.065217-1.jar on Nexus and the next deployment will have projectName-1.0-20180323.065217-2.jar deployed on nexus.
Is it possible to check if the snapshot version (in this case 1.0) is already present in nexus repo (and it gives a fail message that the version cannot be deployed).
The deployed version should be named as projectName-1.0.jar instead of projectName-1.0-20180323.065217-1.jar
The mvn deploy will fail if the artifact to be uploaded is already in the repository
Note: only if you upload as a "RELEASE", not a "SNAPSHOT".
Your build could check first if that release version exists:
mvn dependency:get -Dartifact=g:a:v -o -DrepoUrl=file://path/to/your/repo

want to run exec-maven-plugin when spring-boot running

My Spring-boot project structure is below
-Project
- src
- main
- java
- resources
- webapp
- test
- frontend
- src
- static
- config
- package.json
- (after "npm install") node_modules
- (after "npm run build") dist
what I want to do is
when a project is installed, run "npm install"
when "spring-boot:run" runs, run "npm run build" and moves contents in front/dist to /main/webapp
here is my pom.xml
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>exec-npm-install</id>
<phase>generate-sources</phase>
<configuration>
<executable>npm</executable>
<workingDirectory>./frontend</workingDirectory>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
I don't know how can I trigger exec-npm-install exection
with Eclipse maven build, I tried generate-sources, spring-boot:run, install and compile, package but it didn't run.
and I want to know what command should I put, to move dist when "spring-boot:run"
Few things -
As pointed by #khmarbaise as well, you should move your <plugins> tree out of the <pluginManagement> and also use <version> for the plugins you are using.
I don't know how can I trigger exec-npm-install exection
Since the execution is tied to the generate-sources phase of the execution. If you try and execute mvn generate-sources from command line on the project directory, you shall get the execution triggered. Also executing mvn test, mvn install, mvn package should do the needful. Take a look at the Maven - Lifecycle Reference for this.
I want to know what command should I put, to move dist when
"spring-boot:run"
If you want to copy the resources to the /webapp directory, you shall take a look at maven-resources-plugin and change its phase accordingly.

maven-dependency-plugin analyze - "Skipping project with no build directory"

I'm running mvn dependency:analyze-only & im getting the error below. Can someone point me to the correct config for running the maven dependency analyzer?.
FYI, my project builds fine with maven, so im not sure what its looking for. I also listed my pom.xml for the plugin.
this is the error im getting
[INFO]
[INFO] --- maven-dependency-plugin:2.10:analyze-only (default-cli) # MFC ---
[INFO] Skipping project with no build directory
...
This is my pom.xml for the dependency plugin
...
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze</goal>
</goals>
<configuration>
<failOnWarning>true</failOnWarning>
<outputDirectory>c:\TEMP\</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Note that the dependency:analyze-only goal is used in preference to dependency:analyze since it doesn't force a further compilation of the project, but uses the compiled classes produced from the earlier test-compile phase in the lifecycle.
The project's dependencies will then be automatically analyzed during the verify lifecycle phase
If you have not compiled or run your tests before, you will get that message.
Then you must execute as follows
>mvn verify dependency:analyze-only
or simply
> mvn verify
UPDATE
Your pluging goal must be <goal>analyze-only</goal> not <goal>analyze</goal> plugin then must be
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<failOnWarning>true</failOnWarning>
<outputDirectory>c:\TEMP\</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
do the change and execute mvn verify dependency:analyze-only or verify and it should works.

Using appassembler as a daemon script to run apache-camel route fails during reboot

I have an apache camel route that used appassembler to run the route as a linux(redhat)service. I created a symlink to the service wrapper as /etc/init.d/daemon-science. When I try to run the symlink as a service it is working fine but when I reboot it is not pointing in the right folder.
The wrapper.log shows an error:
FATAL | wrapper | 2015/06/25 14:02:37 | Unable to resolve the full path of the configuration file, /etc/etc/wrapper.conf: No such file or directory
My pom.xml has an entry
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.8.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
</goals>
</execution>
</executions>
<configuration>
<daemons>
<daemon>
<id>daemon-science</id>
<mainClass>org.apache.camel.spring.Main</mainClass>
<generatorConfigurations>
<generatorConfiguration>
<generator>jsw</generator>
<includes>
<include>linux-x86-32</include>
<include>linux-x86-64</include>
<include>windows-x86-64</include>
</includes>
</generatorConfiguration>
</generatorConfigurations>
<platforms>
<platform>jsw</platform>
</platforms>
</daemon>
</daemons>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>echodir</id>
<goals>
<goal>run</goal>
</goals>
<phase>verify</phase>
<inherited>true</inherited>
<configuration>
<target>
<mkdir dir="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science/logs"/>
<chmod file="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science/bin/daemon-science" perm="755"/>
<chmod file="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science/bin/wrapper-linux-x86-64" perm="755"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
Somehow the BASEDIR part of service wrapper is getting a different path during reboot:
# discover BASEDIR
BASEDIR=`dirname "$0"`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
ls -l "$0" | grep -e '->' > /dev/null 2>&1
if [ $? = 0 ]; then
#this is softlink
_PWD=`pwd`
_EXEDIR=`dirname "$0"`
cd "$_EXEDIR"
_BASENAME=`basename "$0"`
_REALFILE=`ls -l "$_BASENAME" | sed 's/.*->\ //g'`
BASEDIR=`dirname "$_REALFILE"`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
cd "$_PWD"
fi
# Wrapper
WRAPPER_CMD="./wrapper"
WRAPPER_CONF="$BASEDIR/etc/wrapper.conf"
I can manually change the value of BASEDIR, but when I re-compile I need to manually change the BASEDIR again.
Should be BASEDIR ="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science"
Is there a way to fix the error?
Thanks in advance.

selecting test file (jmx file) not working with jmeter-maven-plugin

I want to select only one JMeter test file (jmx file) to run at one time. I have the following in my pom.xml:
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<testFilesIncluded>
<jMeterTestFile>ionix-${foo.bar}.jmx</jMeterTestFile>
</testFilesIncluded>
<overrideRootLogLevel>DEBUG</overrideRootLogLevel>
<testResultsTimestamp>false</testResultsTimestamp>
</configuration>
</execution>
</executions>
</plugin>
I have multiple jmx files in src/test/jmeter. It turns out those jmx files are always run by the jmeter plugin no matter what, even if I run maven with command like below:
mvn clean -Dfoo.bar=nonsense jmeter:jmeter
According to the documentation, my settings above should only execute ionix-${foo.bar}.jmx. (Whether the file ionix-${foo.bar}.jmx exists doesn't seem to make a difference in my case.) So, what am I missing here?
Thank you very much.
Enable debug in Maven by adding -X to see what is happening .
could you list content of folder that contains jmx files

Resources