Can't get maven-assembly-plugin to package tests - maven-3

I would like to produce a fat/standalone jar which contains both my test classes and test-scope dependencies.
Using the maven-jar-plugin, I can create a jar which contains my test classes but it does not contain dependencies.
Reading the internet, appears the solution is to combine maven-jar-plugin with maven-assembly-plugin.
I tried following these instructions https://jitblog.net/build-maven-standalone-tests/ but have had no success.
Here is a repro of my issue: https://github.com/yanakad/commons-compress-test
Run mvn clean package
Expected: target/fatJar.jar will contain both SnakeYaml and TestClass
Observed: SnakeYaml is indeed there but TestClass is not
My maven version is Apache Maven 3.6.0
Looking at the maven execution, it seems that
`[INFO] --- maven-assembly-plugin:3.2.0:single (fat-testjar) # compress-test ---`
is run before
`[INFO] --- maven-jar-plugin:3.2.0:test-jar (default) # compress-test ---`
Not sure if that's the cause or a red herring, or how to fix...Any insight much appreciated

So it did turn out to be a silly mistake but leaving here in case it helps someone else
maven-jar-plugin and maven-assembly-plugin run in the same build phase. Maven apparently executes plugins in the lexical order of the file. So the fact that the assembly plugin was running before the jar plugin was in fact the problem.
The solution was to reorder the plugins in the pom.xml files to have maven-jar-plugin appear before maven-assembly-plugin

Related

How to read settings from Jenkins in Gradle?

I use Jenkins to build Gradle, but there was a problem when reading the settings.
I use the 'net.linguica.maven-settings' plugin and in build.gradle wrote the line:
mavenSettings { userSettingsFileName = project.property('maven.settings.location) }
And now I can run the build like this:
gradle -Pmaven.settings.location=/u01/test.xml clean build publish
But when building, I get dependency errors.
Could not resolve org.springframework.boot:spring-boot-configuration-processor:2.1.6.RELEASE.
Required by:
project :
Skipped due to earlier error
Could not resolve org.junit.jupiter:junit-jupiter-api:5.8.0.
What do I need to do?
Maven doesn't intrinsically know where to get dependencies from. It will look to the setting.xml for a list of repositories and look for any dependencies from there. If you list multiple repositories is will check each one until it finds the dependencies listed in the pom file.
I suspect because you are overriding the settings the file you are using doesn't have a repository listed which has the dependency you need.
That is what the error message is telling you - "I looked though all the registries I know about but couldn't find org.junit.jupiter:junit-jupiter-api:5.8.0 in any of them"
You can read a bit about it here https://maven.apache.org/settings.html under "Repositories"

class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found

I have somewhat common problem with ant not being able to find the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec. However, the common solutions don't work for me:
ensuring that the jsch.jar and ant-jsch.jar exists in the classpath
ensuring that there are not multiple different versions of the mentioned jars
ensuring that ant -diagnostics is infact seeing the jars
I have no idea what I should try out next. The output I get is the good 'ol:
build.xml: Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found.
This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
-/usr/share/ant/lib
-/opt/home/myname/.ant/lib
-a directory added on the command line with the -lib argument
Do not panic, this is a common problem.
The commonest cause is a missing JAR.
My setup:
ant version: Apache Ant(TM) version 1.9.2 compiled on January 22 2014
ant-jsch version: 1.9.2
jsch version: 0.1.52
Ant diagnostics log can be found here: http://pastebin.com/q5AURxuk
As seen from the diagnostics log, the jars are there but ant reports:
sshexec : Not Available (the implementation class is not present)
I also extracted the jar file and ensured that the class is there.
Any ideas?
I've been hit by nearly the same problem, especially ant -diagnostics shows that sshexec task is "Not available".
On my system the solution was to install package "ant-optional" additionally (as I've already posted here: ANT can't find specific libraries)
Maybe this helps.
Regards
Came across a problem very similar to yours, problem with SCP rather than SSH but otherwise the same. Tou don't say if you compiled Ant yourself ot used a binary distribution, but or us it turned out to be a problem with the ant-jsch.jar not compiling properly. There was no suggestion of a problem on compile, but the jar was much smaller than expected, only 6k. We fixed the issue by using the ant-jsch.jar from the binary distribution, which is 48k. This was with ant-1.9.4 and ant-1.9.5, Java 1.8.0_45.

is sonar multi-module broken?

trying to make a multi module project I dowloaded the samples in github: I use this folder
https://github.com/SonarSource/sonar-examples/tree/master/projects/multi-module/sonar-runner/java-sonar-runner-modules-own-configuration-file as a project base dir
In a command line in this folder, I type /opt/sonar-runner/bin/sonnar-runner
First thing I find is that sonar-project.properties has a property named sonar.sources=src, but executing throws
Exception in thread "main" org.sonar.runner.RunnerException: You must define mandatory properties: sources
Then I correct this property with sources=src and runner execution finish, adds the project to my sonar server, but no code, modules or file is detected. It is like if all project is empty.
It is exactly the same with other examples and with my own project. No matter if is java, python...
Any help is welcome
You are using an old version of Sonar Runner and/or Sonar. Please update to the latest versions (Sonar Runner 2.2 and Sonar 3.5.1).

Maven 3 Parallel build Projects Skipped

Does anybody know of any reason why some of my projects are marked as SKIPPED at the end of a successful maven build?
please note that the 'skip chain' always starts with my web project which includes the following features:
jspc-maven-plugin
war plugin with overlay
maven-dependency-plugin
It could be due to OutOfMemoryError's inside Maven. We had similar problem with Maven skipping half of the modules. Increasing memory for Maven process itself solved the issue. I don't know if it is specific to some particular plugin behaving bad or to the Maven core.

SAXParseException Using Maven-JAXB2 0.7.5 Plugin, Only On Maven 3

I seem to be having issues with the maven-jaxb2-plugin (Version 0.7.5) when using Maven 3. The issue doesn't occur when using Maven 2.2.x, and it only became an issue when I upgraded to Maven 3.
Following is the maven output after executing mvn clean test:
[ERROR] Error while parsing schema(s).Location
[ file:/C:/dev/smart-07-2011/mpg-money-send-service/src/main/resources/META-INF/mpg/schemas/XRSIMoneySend.xsd{218,45}].
org.xml.sax.SAXParseException: src-resolve:
Cannot resolve the name 'common:ResponseBody' to
a(n) 'type definition' component.
However, the tests execute fine when using Maven 2. I've been searching for resources online if there's any known issue between Maven 3 and JAXB2, but I couldn't find any resources. Effective POM for the build using Maven 2 or Maven 3 is identical.
Incidentally, in the past I was able to use the maven-jaxb2-plugin on Maven 3 just fine; this build, however is special in that the XSD is in a dependent JAR, so it could be a configuration issue; but I'm not sure what configuration I would need to set in the POM or bindings.
Are there any resources I could use to resolve this issue, or any resolution steps I could take? Thanks a lot!

Resources