Sonar `should be relative to project baseDir` error in travis - eclipse

Some time between the 11th September and the 14th September, running sonar through our travis build started failing with an org.eclipse.dawnsci.targetplatform should be relative to project baseDir error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project org.eclipse.scanning: Dir /home/travis/build/eclipse/org.eclipse.dawnsci/org.eclipse.dawnsci.targetplatform should be relative to project baseDir -> [Help 1]
Looking through the pom.xml the org.eclipse.dawnsci module does stand out as being different to all of the others:
<modules>
<module>org.eclipse.scanning.target.platform</module>
<module>../org.eclipse.dawnsci</module>
<module>org.eclipse.scanning.api</module>
...
</modules>
I have tried updating sonar-project.properties from
sonar.exclusions=**/*.xml,**/*.class
to each of the following:
sonar.exclusions=**/*.xml,**/*.class,../org.eclipse.dawnsci
sonar.exclusions=**/*.xml,**/*.class,org.eclipse.dawnsci*
sonar.exclusions=**/*.xml,**/*.class,org.eclipse.dawnsci**
but none of these changes helped.
After previous problems I have added --fail-never to the mvn -q sonar:sonar command in .travis.yml so this problem won't prevent pull requests being merged, but it would be nice to have sonar reports on our repo again.
Any suggestions about how I can fix our travis build would be appreciated?

We changed the way we validate project layout, and it leads to this error. A ticket was created to track this change, and we are currently discussing options (like updating the SonarQube Scanner for Maven). Feel free to follow it for updates, and sorry for the inconvenience.
For your specific case, one workaround is to create a build profile, and exclude module ../org.eclipse.dawnsci when running the SonarCloud analysis. Or move the module to be under the project basedir (and avoid using .. in module location).
As a side note, there is no point maintaining the file sonar-project.properties if you are using the Scanner for Maven (mvn sonar:sonar) since the Scanner for Maven will only read configuration from pom.xml.

As suggested by Julien H. - SonarSource Team adding a profile did solve this problem.
In the pom.xml I changed
<modules>
<module>org.eclipse.scanning.target.platform</module>
<module>../org.eclipse.dawnsci</module>
...
</modules>
to
<profiles>
<profile>
<id>externalModules</id>
<activation><activeByDefault>true</activeByDefault></activation>
<modules>
<module>../org.eclipse.dawnsci</module>
</modules>
</profile>
</profiles>
<modules>
<module>org.eclipse.scanning.target.platform</module>
...
</modules>
so that the module is included by default.
I then added -P !externalModules to my mvn sonar:sonar command in .travis.yml so that it was excluded when running sonar analysis.

I stumbled over the same problem and finally came to the conclusion that this has all been fixed in the latest sonar-maven-plugin 3.4. You can simply upgrade your dependency to this:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>

Related

Disable modules in owasp dependency-check maven plugin

In my project I use dependency-check-maven to run OWASP verifications. Project contains several java modules and a front end module. Configuration in pom is basic one like this
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>5.3.2</version>
<configuration>
<failBuildOnCVSS>4</failBuildOnCVSS>
<suppressionFiles>
<suppressionFile>owasp-suppressions.xml</suppressionFile>
</suppressionFiles>
<cveUrlBase>...</cveUrlBase>
<cveUrlModified>...</cveUrlModified>
<format>ALL</format>
<assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
<cveValidForHours>24</cveValidForHours>
</configuration>
</plugin>
Is it possible to configure the plugin such way that it ignores my front end module but analyses all other ones?
I try to run mvn -Dowasp.dependency-check.excludes=frontend-1.0.1-SNAPSHOT.jar org.owasp:dependency-check-maven:aggregate in the root folder of my project but verification is done in frontend as well
I've the same issue to ignore some javascript modules to be analyzed by the dependency check.
As you can see at https://github.com/jeremylong/DependencyCheck/issues/1009 the developers have an open PR to resolve this request.
I've solved this by not building the javascript module:
mvn verify -pl '!frontend'
It's just a workaround to get the results of the dependency-check locally.
Maybe there exists better ideas?

Getting "The POM for <name> is invalid, transitive dependencies (if any) will not be available" only in Eclipse

I have recently upgraded to JAXB 2.2.11 and noticed in my Eclipse console the following message:
10/15/14, 11:42:46 PM GMT+2: [INFO] Creating new launch configuration
10/15/14, 11:42:58 PM GMT+2: [INFO] C:\Projects\workspaces\mj2p\maven-jaxb2-plugin-project\tests\JAXB-1044
10/15/14, 11:42:58 PM GMT+2: [INFO] mvn -B -X -e clean install
10/16/14, 12:09:07 AM GMT+2: [WARN] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for com.sun.xml.bind:jaxb-impl:2.2.11
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} #
10/16/14, 12:09:07 AM GMT+2: [WARN] The POM for com.sun.xml.bind:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for com.sun.xml.bind:jaxb-xjc:2.2.11
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} #
10/16/14, 12:09:07 AM GMT+2: [WARN] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for com.sun.xml.bind:jaxb-core:2.2.11
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} #
What puzzles me is that I am not getting this warning in console. The poms in question also seems to be correct. I am sure I am using the same Maven installation in the console and in Eclipse (m2e). The repository also seems to be correct.
Does anyone happen to know, what could be causing this?
Please note that this is not a duplicate for (almost
identically-named) question:
The POM for <name> is invalid, transitive dependencies (if any) will not be available
This question is about the differences between Maven execution in the console and from the Eclipse.
The pom for com.sun.xml.bind.jaxb-impl has com.sun.xml.bind:jaxb-parent has its parent.
jaxb-parent pom has the following section:
<profile>
<id>default-tools.jar</id>
<activation>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<properties>
<tools.jar>${java.home}/../lib/tools.jar</tools.jar>
</properties>
</profile>
<profile>
<id>default-tools.jar-mac</id>
<activation>
<file>
<exists>${java.home}/../Classes/classes.jar</exists>
</file>
</activation>
<properties>
<tools.jar>${java.home}/../Classes/classes.jar</tools.jar>
</properties>
</profile>
In your Eclipse, neither of the profile seems to be activated due to which ${tools.jar} does not have a value.
One possibility could be JAVA_HOME value is set incorrectly.
After further investigation it appears that I have the same problem as in this question:
Maven not picking JAVA_HOME correctly
The solution thanks to #rustyx (please upvote that answer):
To fix the issue you need to start Eclipse using the JRE from the JDK by adding something like this to eclipse.ini (before -vmargs!):
-vm
C:\<your_path_to_jdk170>\jre\bin\javaw.exe
the pom for com.sun.xml.bind:jaxb-osgi:jar:2.2.10 is invalid issue.
worked for me after updating the rest-assured version to 4.1.1.
As others pointed out, this might happen because the JRE is setup incorrectly within Eclipse.
I solved it by adding the correct entry (pointing to where mi JDK is installed) inside Window>Preferences>Java>Installed JRE's
After this change, a project clean might be necessary.

An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException

I'm developing a Java EE web project. When I try to add a dependency, this error message appears. I use Eclipse Kepler.
An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException
Could you help me?
Thank you.
I solved mine by deleting the .settings folder and .project file in the project and then reimporting the project.
For me worked the answer I found on CodeRanch, by user Maneesh Godbole:
Close eclipse.
Navigate to your "workspace" folder
Ensure the setting on your OS to view hidden files is turned on
Identify and delete the .metadata directory
Restart eclipse
Import project
I've had the same problem in one of my modules.
Running "mvn eclipse:eclipse" in the console/cmd solved the problem for me.
In our instance of this problem, we had pom.xml files where the m2e-specific life cycle mapping configuration
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
...
did not have the <version>1.0.0</version> part. When doing a Maven -> Update Project..., this causes the reported NullPointerException without a stack trace. When using a fresh Import... -> Existing Maven Projects, the same exception occurred, but with a stack trace that led me to find the above.
(This is with m2e 1.6.1.20150625-2338 in Eclipse Luna Service Release 2 (4.4.2).)
In case it helps anyone, in addition to deleting .settings and .project, I had to delete .classpath and .factorypath before being able to import the project successfully into Eclipse.
org.eclipse.m2e.core.prefs file is in .settings folder. If you face the problem of
An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException
Delete the project from eclipse then by deleting the .settings folder & .project file in the project -> then re-import the project.
None of the above methods worked for me. This might also arise due to the presence of circular dependency in your eclipse workspace. So if there are any other errors present in any of the other projects in your workspace, try to fix those and then this issue will be gone. This is how i eliminated the error.
This helped me: Project menu -> Clean... -> clean all projects
Eclipse has an error log. There you will see the complete stack trace. In my case it seems to be caused by a bad jar file combined with the java.util.zip libs not throwing a proper exception, just a NullPointerException.
I'm using:
Eclipse Java EE IDE for Web Developers.
Version: Neon.3 Release (4.6.3)
Build id: 20170314-1500
The fix/trick for me was deleting my local repository in ~/.m2/repository in order to remove local dependencies and rebuilding my project in which fresh dependencies are pulled down.
Above solutions did not work for me as the issue with open JDK 13 version
https://github.com/spotify/dockerfile-maven/issues/163
So I degraded to open JDK8 and it works for me
I had the same problem. None of the solutions here worked. I had to completely reinstall eclipse and make a new workspace. Then it worked!
I had this same issue across multiple projects and multiple workspaces, none of the solutions I found online worked for me. I'm using STS and the only thing that worked was to go into my STS directory and add a "-clean" to the top of the STS.ini file. You can then start up your workspace and run maven clean without errors. (you can also remove the -clean tag from the ini file so it doesn't clean everytime you start it)
Hope this helps someone.
The root issue in my case was a file conflict in the .settings folder. So, deleting the .settings folder would have resolved the Maven error, but I wanted to keep some of my local configuration files. I resolved the conflict, then tried a Maven update again and it worked.
I had the same issue ... solution at the end !
here the eclipse log:
java.lang.NullPointerException
at com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.getGaeRuntime(GaeRuntimeManager.java:85)
at com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.ensureGaeRuntimeWithSdk(GaeRuntimeManager.java:55)
at com.google.appengine.eclipse.wtp.maven.GaeFacetManager.addGaeFacet(GaeFacetManager.java:59)
at com.google.appengine.eclipse.wtp.maven.GaeProjectConfigurator.configure(GaeProjectConfigurator.java:46)
... it comes from "appengine maven wtp plugin" that try to get the type of GAE runtime, but seems to be null here (... getRuntimeType() --> NPE):
see class com.google.appengine.eclipse.wtp.maven/GaeRuntimeManager.java
private static IRuntime getGaeRuntime(String sdkVersion) {
IRuntime[] runtimes = ServerCore.getRuntimes();
for (IRuntime runtime : runtimes) {
if (runtime != null && **runtime.getRuntimeType()**.equals(GAE_RUNTIME_TYPE)) {
So, if you check in eclipse, Google App Engine is visible , but when you select it you'll see that no SDK is associated ...
SOLUTION:
in red on the screenshot ;-)
I encountered this same symptom and none of the solutions above were helpful. I finally got a stack trace of the problem by importing the ear project again to eclipse, and was able to trace this down to the org.eclipse.m2e.wtp.MavenDeploymentDescriptorManagement which was trying to delete a directory in windows' temp directory called ".mavenDeploymentDescriptorManagement", which caused an irrational NullPointerException from the java.io.File.exists() method, particularly because the code already had successfully done the same thing in a previous method with the same variable, then called file.isFile() without problem.
Checking this out on the file system revealed that the file could only be accessed with administrator privileges. Apparently I had at some point launched eclipse from an administrator console by mistake.
In the end I just made hidden files visible in windows explorer and deleted the temporary file manually, which solved the problem.
Just another possible source of the problem!
I found out that in my case it was the following resource block that caused it:
<project>
<build>
<resources>
<resource>
<directory>${basedir}/../some-folder</directory>
<targetPath>outputFolder</targetPath>
</resource>
<resources>
</build>
</project>
It included a folder from the project folder (the eclipse project is a subfolder of the versioned project folder).
In my case, I could remove the error by removing the block and replacing it with a call to the Build helper Maven plugin:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>my-own-very-cool-id-for-this-step</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${basedir}/../some-folder</directory>
<targetPath>outputFolder</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I had to reinstall eclipse, delete .m2 folder and rebuild the jars.
deleting the local maven repository helped me
In my case, the problem was a conflict of derived dependencies that were been used by other dependencies, and some of those derived dependencies versions were not available, maybe because some deploy that i forgot to do because with workspace resolution everything worked, but when moving to other environment all broke suddenly.
And also I was working with version ranges
maven was giving me this error:
Could not resolve dependencies for project
MyProject:MyProject:jar:1.0.0: Could not resolve version conflict
among Dependency-A:1.0.1 -> Dependency-B:1.1.0 ->
Dependency-C:1.0.0, Dependency-X:1.0.1 -> Dependency-Y:1.1.0 -> Dependency-C:1.0.0, Dependency-I:1.0.1 -> Dependency-J:1.1.0 -> Dependency-C:1.0.0
I tried all above and nothing worked, so...
THE SOLUTION: Use LATEST as version in all dependencies, so maven don't need to resolve all dependencies in ranges, wich must be used
with care because if you miss to deploy one of the dependencies the
build will fail
Only I suggest you to use LATEST if you are working with your own dependencies, otherwise in some third party future version, you could find some compilation or runtime errors
Avoid deleting the .metadata folder as it cleans up all settings, run configurations.
Instead, rename the .metadata folder --> Restart eclipse --> Import project
deleting the local .settings folder helped me
solution step is delete following files in project folder
.settings
.project
.classpath
I solved this problem like this: Project -> Clean -> %YOURPROJECT%
Click Here for image

Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1:war - Could not copy resource

I have a multi-module project that I'm trying to import in my Ubuntu 12.04 LTS's Eclipse Juno. (I already have done it successfully on Windows 7).
My project has six modules, the first four modules are successfully imported from the SVN Repository and built with Maven 3.0.5, but when I try to build the fifth called core, i receive the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1:war (default-war) on project core: Could not copy resource [/opt/workspace/core/target\preassembly]: File /opt/workspace/core/target\preassembly/scripts/Mask.js does not exist -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
As the error says, It looks like that Maven can't find the directory /opt/workspace/core/target\preassembly to copy the file /opt/workspace/core/target\preassembly/scripts/Mask.js.
But, this directory actually exists and the file Mask.js is in there. What looks strange to me is that backslash \ after target directory instead a common bar /. But I have no idea if this is a problem and how to solve it, I spent 2 days researching the Internet but unfortunately I've found nothing.
Here's my maven-war-plugin configuration section of parent project's pom.xml, where the backslashes appear
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}\preassembly</directory>
</resource>
</webResources>
</configuration>
</plugin>
I've also checked the owner of the directories on Ubuntu, and everything refers to the same owner that worked on the first four modules.
As I said above, the same version of eclipse, svn and maven works great on Windows.
Anyone ever had this problem? Thank you very much.
I was working on angular 8 and updated the code to angular 9 and then during build i got the same issue .For me clean build solved the issue.You can try clean build , hope that will help .

building spring batch sample application

I am trying to build the sample application for spring batch 2.1.6. (ie. spring-batch-2.1.6.RELEASE/samples/spring-batch-samples) using maven but am getting this error for a missing plugin:
[ERROR] Plugin
com.springsource.bundlor:com.springsource.bundlor.maven:1.0.0.RELEASE
or one of its dependencies could not be resolved: Failure to find
com.springsource.bundlor:com.springsource.bundlor.maven:jar:1.0.0.RELEASE
in http://repo1.maven.org/maven2 was cached in the local repository,
resolution will not be reattempted until the update interval of
central has elapsed or updates are forced ->
Is there another repository I can set up to get this plugin? I am a bit suprised to be getting this errror as this is the latest realease version of spring batch.
Here is the repository section from the pom as it came in the download:
<repositories>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle External</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
The project's parent pom has a bootstrap profile which contains the necessary repository definitions. Build the project with the command mvn test -P bootstrap and it will download the dependencies.
P.S. This is explained in the readme's instructions that how to build Spring Batch. It would be good if they would also tell how to do it in the instructions for using the samples - maybe you could file a bug report?
i am using maven3 and was able to solve this problem by adding this to my pom:
<pluginRepositories>
<pluginRepository>
<id>plugin.repo.maven.central2</id>
<url>http://objectstyle.org/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
The Spring batch Admin sample build is broken for sure. At least as of today.
The -Pbootstrap doesn't help and adding the repos in that profile in my local settings doens't help either.
When I attempted to build spring-batch-admin-sample, I found that I was missing dependencies of spring batch!
So I went to build that. There I found that I was missing org.neo4j:neo4j-cypher-dsl-1.9.M04 and also gemfire.7.0.1.jar. Adding repos doesn't help because of the maven2/3 incompatibility issues.
So a sure way to fix this is to go to each repo, download the missing dep and mvn install-file them.
So get the neo4j one here:
http://m2.neo4j.org/content/repositories/releases/org/neo4j/neo4j-cypher-dsl/1.9.M04/
Get the gemfire one from here:
https://repo.springsource.org/gemstone-release-cache/com/gemstone/gemfire/gemfire/7.0.1/
And then I ran into a foundrylogic.vpp dependency that I found here:
http://objectstyle.org/maven2/foundrylogic/vpp/vpp/2.2.1/
Don't forget to get the corresponding poms also to keep it clean and get all the transitives, if any.
Use the mvn install-file plugin described here to get all three deps to your local repo.
http://maven.apache.org/plugins/maven-install-plugin/usage.html
Now spring-batch should build clean.
Now if you go to build spring-batch-admin it will still fail because it depends on spring-batch-core-2.2.3.BUILD-SNAPSHOT whereas what we just built was version 3.0.0.BUILD-SNAPSHOT.
So go to spring-batch-admin-parent's pom and modify the pom like so:
<!-- <spring.batch.version>2.2.3.BUILD-SNAPSHOT</spring.batch.version> -->
<spring.batch.version>3.0.0.BUILD-SNAPSHOT</spring.batch.version>
And then step back to spring-batch-admin and mvn clean install should build the sample.
Hope this helps someone!
I installed maven 3.2.1 and it works.