maven-surefire-report-plugin is not called during building - maven-surefire-plugin

I defined the following pom.xml file for generating of reports during an integration testing.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
If the mvn verify is executed,there are no reports created. I have to use mvn surefire-report:report for generating.
The above mentioned pom.xml file is parent for two children to be clear.
Does anyone know what is wrong?

Actually the above solution works just only if it is defined in child pom.xml file. It does not work in parent one. Is it bug or what is going on? I spent several hours when I got it!

Related

How would I build a spring boot rest api project containing embedded reactjs front end code

I have a spring boot rest api project, using maven, into whose src folder I have a reactjs project. What I need to know is how would I change the pom.xml file so that a jar file is created that is executable for the complete application, both frontend and rest api.
This link will help you out: https://medium.com/#itzgeoff/including-react-in-your-spring-boot-maven-build-ae3b8f8826e
You just need to run the npm/yarn command from the pom.xml
Here is a sample:
<execution>
<id>yarn-install</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>build-frontend</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>
Check this post, I highly encourage you to do a quick search in google before posting questions here
https://spring.io/guides/tutorials/react-and-spring-data-rest/

Wildfly-Swarm enable debug

I've managed to convert my "war" application to a hollow jar.
My biggest issue is that even after following the documentation, still cannot enable debug mode (my desired port is 8784)
I am pretty sure that I am missing something but ... what?
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${wildfly-swarm.version}</version>
<executions>
<execution>
<id>package</id>
<goals>
<goal>package</goal>
</goals>
<configuration>
<hollow>true</hollow>
<properties>
<swarm.debug.port>8784</swarm.debug.port>
<debug.port>8784</debug.port>
<swarm.debug.bootstrap>true</swarm.debug.bootstrap>
<java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
</properties>
</configuration>
</execution>
</executions>
</plugin>
The swarm.sebug.port property is only relevant when starting the application via the Swarm Maven plugin, or when using the Swarm Arquillian adapter. When starting the application using java -jar myapp-swarm.jar, you need to use the standard Java way of enabling remote debugging, i.e. something like java -Xdebug -agentlib:jdwp=transport=dt_socket,address=8784,server=y,suspend=n -jar myapp-swarm.jar.
You may want to look into:
https://issues.jboss.org/browse/THORN-1321
or
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206848015-Breakpoints-not-working-when-debugging-simple-Java-EE-app-on-wildfly?page=1#community_comment_360000176459
The first link is the relevant one. I am including the second one just for further information if you are using IntelliJ for IDE.
Briefly, here is my pom configuration:
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${version.wildfly.swarm}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<debugPort>5005</debugPort>
<properties>
<swarm.debug.port>5005</swarm.debug.port>
</properties>
</configuration>
</plugin>
After starting the application with the mvn swarm plugin, I am connecting with a remote debugger.
Good luck!
Edit (2019.05.31):
My current setup for debugging in the pom.xml is the following:
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${version.wildfly.swarm}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmArguments>
<jvmArgument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmArgument>
</jvmArguments>
</configuration>
</plugin>

Resolving Izpack artifacts using maven dependency

I have Izpack installer which packs a pre-configured server and installs in target directory. This server is around 500Mb. Currently I have checked in this src/main/resources folder of installer maven project.But having this big server in git is making the git pulls very slow. So i am planning to keep this server as maven artifact in nexus and add its dependency to installer maven project. This way i can create a maven profile to pull this server from nexus on demand. I am yet to figure out how to copy this dependency to staging folder using a maven plugin(any help would be greatly appreciated). My question here, is it a right approach? or is there any better way to do this. Thanks in advance.
You can use the maven dependency plugin to copy a dependeny to a specific folder.
You can use it to either copy all dependencies or even unpack those dependencies.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<outputDirectory>${izpack.staging}/content/ninjolibs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
This is what i did. I uploaded wso2.zip to nexus as zip artifact and configured pom.xml of my installer module to use this dependency.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-binaries</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wso2</groupId>
<artifactId>wso2is</artifactId>
<version>5.0.0</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>src/main/resources/wso2/binary</outputDirectory>
<destFileName>wso2is-5.0.0.zip</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

Maven plugin additional executions

I need to execute the same maven plugin more than once in the same phase.
What I want:
Execute maven-assembly-plugin
Execute myplugin (depends on step 1)
Execute maven-assembly-plugin again (depends on step 2)
Execute myplugin again (depends on step 3)
Execution order when I define the plugins sequentially (same order as above):
Execute maven-assembly-plugin
Execute maven-assembly-plugin again
Execute myplugin
Execute myplugin again
My solution is to combine all executions in my own plugin to control the exact order, but I don't think it's the best way to do it. Thanks !
Do you absolutely have to run the plugins during the same exact phase? Can't you use some other related phase? Maven has a lot of phases nowadays :) e.g. "prepare-package" vs. "package". I would probably try to define multiple executions for the plugin like this (bwt this is not a real-world scenario):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>assembly1</id>
<goals>
<goal>assembly</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
<execution>
<id>assembly2</id>
<goals>
<goal>assembly</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
Not sure if it will work for your desired order though. Might be worth a try.

Maven Proguard processing a library jar that other applications will depend one

Here is what my build plug in stanza looks like:
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<options>
<option>-dontshrink</option>
<option>-dontnote</option>
<option>-allowaccessmodification</option>
<option>-dontskipnonpubliclibraryclasses</option>
<option>-dontskipnonpubliclibraryclassmembers</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jsse.jar</lib>
</libs>
</configuration>
</plugin>
Here is what I get from execution of mvn clean package
[proguard] Error: You have to specify '-keep' options for the shrinking step.
How do I specify the keep options for a library where I just want obfuscation?
You must define with the -keep option the entry points of your application, because you can't obfuscate it. For example if your main class is obfuscated it will be renamed and you won't be able to launch it. The same for public interfaces of your APIs.

Resources