How to solve Exception: basedir doesnot exist - maven

I am trying to dockerize a springboot project using maven.
So i ran a command
mvn package -Pdocker '-Dmaven.test.skip=true' docker:build
Below is the image of how the file structure of the project is
image and below is the error
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project poplar: Exception caught: basedir C:...\server\target does not exist -> [Help 1]
I am trying to find out how i can solve the problem because from the project structure there is no target folder for the root project poplar though the subprojects have target folders in them.

An easy fix is to create the target directory in the base project directory. For more details about the issue see here. The error is reproduced here
I would suggest you change the project structure and add a maven sub-module responsible for building the docker container.

Related

IntelliJ - Why does the target folder is created with an padlock?

I hope you guys can help me with this, after running testng, the target folder is created with a padlock
and due this I can't run mvn clean test cause this folder can't be removed by maven
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project TestCases: Failed to clean project: Failed to delete /Users/administrator/qa-automation/01LoginProject/TestCases/target/surefire-reports/testng.css -> [Help 1]
How can I prevent the target from being created without the padlock?
Padlock on a project folder means it contains a read-only class.
See this article for more information on file types and icon references in IntelliJ IDEA.

Teamcity Issue :Unable to add module to the current project as it is not of packaging type 'pom'

I am trying to add Maven build step in TeamCity to generate Maven archetype.
mvn archetype:generate
This works fine in command prompt.
Unfortunately it throws below error in TeamCity:
Failed to execute goal
org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate
(default-cli) on project pso-jms-listener-archetype:
org.apache.maven.archetype.exception.InvalidPackaging: Unable to add
module to the current project as it is not of packaging type 'pom'
I created a new folder and tried executing it there, but still throws the same error
Any suggestions would help.
You may already have a POM file in the directory where mvn archetype:generate is executed.
For Maven, archetype is
a Maven project templating toolkit. An archetype is defined as an
original pattern or model from which all other things of the same kind
are made.
In short, you are creating a project (from a template) in an other project.
In your project folder, delete the file pom.xml and use mvn archetype:generate again.

SonarQube scan failing with "is already part of project XXX error is already part of project"

Recently I upgraded sonarqube from 4.0 to 4.3.3. Post upgrade when I try to run the maven build I am getting the error:
Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.4:sonar (default-cli) on project xxx on project yyy Module "abc.def.xyz" is already part of project of other project.
The issue is we scan on multiple branches so we will have modules with the same name.
Is there a way to turn off this validation?
Assume you have multiple modules Maven project with below structure:
com.company:project
com.company:project-module1
com.company:project-module2
In your java source code, now "com.company:project" renamed to "com.company:myProject", so new java source strucutre becomes:
com.company:myProject
com.company:project-module1
com.company:project-module2
When you build new source and push analysis data to Sonar, it prompt:
[ERROR] Failed to execute goal
org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
(default-cli) on project myProject: Module
"com.company:project-module1" is already part of project
"com.company:project" -> [Help 1]
This error is because the "com.company:project-module1" already executed and registered into Sonar before and now it belongs to "com.company:project" project whihc no longer exist in your source code anymore.
Solution:
In Sonar project configuration --> Update key, change the project "com.company:project" key from "com.company:project" to "com.company:myProject", rerun Maven build and push to Sonar, issue will solve.

Maven deployment issues

I have a maven project that is built using the archetype-site.
I left the default directory structure as it is and added a directory for my files, so my current structure is this:
MyProject
-> src
-> pages
-> target
-> pom.xml
The pages directory is the one I added and it has a variety of HTML/CSS/JS files.
I've defined a remote repository on my pom.xml and have added the credentials to the relevant section in the settings.xml file of maven.
I'm getting the following error which I do not understand when I'm trying to deploy. Googling also did not help.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project MyProject: Failed to deploy artifacts: Could not find artifact MyProject:MyProject:jar:1.0-20121022.153807-1 in MyProject (https://bitbucket.org/MyApp/MyProject) -> [Help 1]

Maven deploy fails on Maven parent project

I have a maven project with the following hierarchy as created with NetBeans:
root/
Parent/
pom.xml
Project 1/
pom.xml
Project 2/
pom.xml
....
Project x/
pom.xml
When I try the release:perform it fails when attempting to deploy:
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project (C:\checkout\pom.xml) has 1 error
[ERROR] Non-readable POM C:\checkout\pom.xml: C:\checkout\pom.xml (The system cannot find the file specified)
It looks like the plugin expects the pom to be on the root folder. I was unable to find a customization point on the plug-in to specify the pom.xml location.
Is this not possible, or did I organize the project wrong?
Searching on the net I found this post which pointed me to a question with the answer here.
It looks like you are trying to run mvn release:perform from your checkout root directory, while you should cd to Parent instead.
I assume that your project is indeed stored under Subversion or some other Maven-supported version control tool and that you checked it out in your C:\checkout directory.

Resources