When I try create a new maven project (with several archetypes, not only the one below), I am facing this error:
Unable to create project from archetype [org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE]
Unable to add module to the current project as it is not of packaging type 'pom'
Anyone know why this is happening, and how to solve it?
It seems that your directory is not empty.
this command line works for me: (in an empty directory)
mvn archetype:generate -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart
the result is:
[INFO] Using property: groupId = fr.myGroupId
[INFO] Using property: artifactId = MyApplication
Define value for property 'version': 1.0-SNAPSHOT: :
[INFO] Using property: package = fr.myGroupId
Confirm properties configuration:
groupId: fr.myGroupId
artifactId: MyApplication2
version: 1.0-SNAPSHOT
package: fr.myGroupId
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: fr.myGroupId
[INFO] Parameter: packageName, Value: fr.myGroupId
[INFO] Parameter: package, Value: fr.myGroupId
[INFO] Parameter: artifactId, Value: MyApplication2
[INFO] Parameter: basedir, Value: /home/ABC-OBJECTIF/philippe.demanget/workspace/pdemanget/tmp/mvn
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: /home/ABC-OBJECTIF/philippe.demanget/workspace/pdemanget/tmp/mvn/MyApplication2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.764s
[INFO] Finished at: Tue Apr 22 13:35:17 CEST 2014
[INFO] Final Memory: 14M/216M
[INFO] ------------------------------------------------------------------------
I can reproduce your error by doing this command line inside the newly created directory:
cd MyApplication
mvn archetype:create -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart
[...] [INFO] BUILD FAILURE
I got the same issue, solved by manually removing a unused pom.xml file at the root of workspace directory
You have to remove the already existing pom.xml or if you need it to execute the maven command, try adding <packaging>pom</packaging>
to your pom.
Since if you have an already existing in the current directory, it should match with the package structure. It is always to good to start with no pom file in the parent directory.
This should work.
I was having the same problem using Windows PowerShell in a newly created directory with nothing in it. I tried the command using the regular Windows Command Prompt, and it worked fine.
I simply created new workspace and it worked for me..
Related
I'm trying to install a module to local repository so that I can call its classes in another module.
IDEA shows me that the install process has been successfully done.
[INFO] --- maven-install-plugin:2.4:install (default-install) # commonJT808 ---
[INFO] Installing E:\学习测试\GpsTransferTest\commonJT808\target\GpsTest.jar to C:\Users\ASUS\.m2\repository\com\test\commonJT808\1.0-SNAPSHOT\commonJT808-1.0-SNAPSHOT.jar
[INFO] Installing E:\学习测试\GpsTransferTest\commonJT808\pom.xml to C:\Users\ASUS\.m2\repository\com\test\commonJT808\1.0-SNAPSHOT\commonJT808-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
And I have verify in my local repo, [files][1] exist.
However when I try to use it in another module, it doesn't work. The IDE gives me a tip like "failed to read artificat descriptor for commonJT808:jar:1.0-SNAPSHOT".
How can I solve it?
In Jenkins, I have a Maven project with the following structure:
x proftaakmaven
- AutosimulatieSysteem
- LandenMonitoringSysteem
- PolitieSysteem
x Verplaatsingssysteem
- VerplaatsingREST
- VerplaatsingSOAP
- VerplaatsingCommon
- VerplaatsingenRabbitMQ
- RabbitMQ-Proof-of-Concept
- VerplaatsingenRabbitMQTestClient
The Maven reactor constructs this building order:
[INFO] Reactor Build Order:
[INFO]
[INFO] AutoSimulatie
[INFO] LandenMonitorSysteem
[INFO] PolitieSysteem
[INFO] VerplaatsingenSysteem
[INFO] VerplaatsingenCommon
[INFO] VerplaatsingenREST
[INFO] VerplaatsingenSOAP
[INFO] RabbitMQ-Proof-of-Concept
[INFO] VerplaatsingenRabbitMQ
[INFO] VerplaatsingenRabbitMQTestClient
[INFO] proftaakmaven
However, due to a current failure in 'LandenMonitorSysteem' source code, Maven fails on building the other modules as well. This makes the Jenkins job fail.
I have tried running Maven with --fail-never and --fail-at-end. But neither seem to have any effect.
How would I be able to continue building all the modules, even if one fails?
Thanks.
--fail-at-end should be the thing to use.
If that doesn't work you could use -pl to specify the list of working projects.
If you use the -am flag as well you can specify the target you are interested in building and Maven will calculate the dependency tree for you.
I.E. mvn clean install -pl VerplaatsingenRabbitMQTestClient -am
I have found the solution. The problem was the way that I provided the argument. In Jenkins 2.0, the job should be configured like this :
The settings inside the job
I am trying to understand what mvn clean:clean actually does.
mvn -B help:describe -Dcmd=clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sample-one 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) # sample-one ---
[INFO] 'clean' is a lifecycle with the following phases:
* pre-clean: Not defined
* clean: org.apache.maven.plugins:maven-clean-plugin:2.5:clean
* post-clean: Not defined
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.689 s
[INFO] Finished at: 2015-12-10T10:20:16-08:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
It appears to me that mvn clean:clean is same as doing mvn org.apache.maven.plugins:maven-clean-plugin:2.5:clean. Therefore I am assuming the first clean in mvn clean:clean is just an alias for org.apache.maven.plugins:maven-clean-plugin:2.5. Similarly mvn maven-surefire-plugin:2.12.4:test is same as mvn surefire:test.
So somehow, maven-surefire-plugin:2.12.4 seems to refer to surefire and org.apache.maven.plugins:maven-clean-plugin:2.5 to clean.
When I look at the effective-pom, I see the following
maven-surefire-plugin
2.12.4
default-test
test
test
maven-clean-plugin
2.5
default-clean
clean
clean
As you can see, the pom doesnt seem to define alias. So following are my questions
Is my understanding about plugin aliases correct
If my understanding about aliases is correct - a) how and where are they defined? b) Is there a way to list all aliases.
From official Maven documentation about plugins development:
Shortening the Command Line
There are several ways to reduce the amount of required typing:
If you need to run the latest version of a plugin installed in your local repository, you can omit its version number. So just use mvn sample.plugin:hello-maven-plugin:sayhi to run your plugin.
You can assign a shortened prefix to your plugin, such as mvn hello:sayhi. This is done automatically if you follow the convention of using ${prefix}-maven-plugin (or maven-${prefix}-plugin if the plugin is part of the Apache Maven project). You may also assign one through additional configuration - for more information see Introduction to Plugin Prefix Mapping.
Finally, you can also add your plugin's groupId to the list of groupIds searched by default. To do this, you need to add the following to your ${user.home}/.m2/settings.xml file:
<pluginGroups>
<pluginGroup>sample.plugin</pluginGroup>
</pluginGroups>
At this point, you can run the mojo with mvn hello:sayhi.
So, alias are not defined in the pom file but part of built-in mechanism of maven. Further details are also provided in the official documentation about Plugin Prefix Resolution.
I am trying to integrate a standard maven project with SonarQube through Jenkins. SonarQube has been added a Post-Build Action to the project build.
I can see Sonar invoked correctly in the console output of the build, but it doesn't find any files to index. The Sonar analysis finishes successfully as far as I can tell but reports are empty.
The same command run locally from command line against a local SonarQube installation works correctly.
Jenkins: 1.605
Sonar: 5.1 (runs on the same machine as Jenkins, off a
MySQL DB)
Jenkins Maven Plugin: 2.8
Jenkins SonarQube Plugin: 2.2
I've added SonarQube section in Jenkins -> Configure Jenkins section with server URL and DB URL.
The only configuration parameter on SonarQube additional properties in projects post build actions is -Dsonar.scm.disabled=true, which I believe turns off the uncommitted files check.
[sonarcore] $ /usr/share/apache-maven/bin/mvn -f /var/lib/jenkins/workspace/sonarcore/myproject-core/pom.xml -e -B sonar:sonar -Dsonar.scm.disabled=true -Dsonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8 -Dsonar.host.url=http://localhost:9000/
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject-core 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:2.5:sonar (default-cli) # myproject-core ---
[INFO] SonarQube version: 5.1
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /var/lib/jenkins/workspace/sonarcore/myproject-core/target/sonar
INFO: SonarQube Server 5.1
[INFO] [10:23:00.144] Load global repositories
[INFO] [10:23:00.327] Load global repositories (done) | time=185ms
[INFO] [10:23:00.336] Server id: 20150413092802
[INFO] [10:23:00.338] User cache: /var/lib/jenkins/.sonar/cache
[INFO] [10:23:00.353] Install plugins
[INFO] [10:23:00.409] Install JDBC driver
[INFO] [10:23:00.422] Create JDBC datasource for jdbc:mysql://localhost:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8
[INFO] [10:23:01.722] Initializing Hibernate
[INFO] [10:23:03.174] Load project repositories
[INFO] [10:23:03.198] Load project repositories (done) | time=24ms
[INFO] [10:23:03.198] Load project settings
[INFO] [10:23:03.424] Load technical debt model
[INFO] [10:23:03.447] Apply project exclusions
[INFO] [10:23:03.647] ------------- Scan myproject-core
[INFO] [10:23:03.651] Load module settings
[INFO] [10:23:03.758] Load rules
[INFO] [10:23:03.826] Base dir: /var/lib/jenkins/workspace/sonarcore/myproject-core
[INFO] [10:23:03.826] Working dir: /var/lib/jenkins/workspace/sonarcore/myproject-core/target/sonar
[INFO] [10:23:03.827] Source paths: pom.xml, src/main/java
[INFO] [10:23:03.827] Test paths: src/test/java
[INFO] [10:23:03.827] Binary dirs: target/classes
[INFO] [10:23:03.828] Source encoding: UTF-8, default locale: en_US
[INFO] [10:23:03.828] Index files
[INFO] [10:23:03.853] 0 files indexed
[INFO] [10:23:03.894] Sensor Lines Sensor
[INFO] [10:23:03.895] Sensor Lines Sensor (done) | time=1ms
[INFO] [10:23:03.896] Sensor QProfileSensor
I found another similar thread on SO that said I need to install more plugins, but I haven't been able to find which plugins do I need.
Analysing with SonarQube causes 0 files indexed and no reports (Maven Project)
I havent added SonarQube Runner on Jenkins as I don't think it is needed. Please see here https://stackoverflow.com/a/13473275/4473028
In your server:
You need to have installed the Sonar runner on your server and you need to have the variable SONAR_RUNNER_HOME properly set.
In your jenkins configuration:
You need to set the configurations for the sonarQube Scanner like this:
Sonar configuration in Global Tool Configuration
Once you install the plugin, you will be able to configure it as a step of execution in the configuration of the job.
In your job configuration:
You need to indicate the path of the sonar-project.properties file and the instance of sonnar-runner that you already configured in the step before like this: sonar step configuration
What on earth does this mean? Cant find any help via google.
> mvn release:prepare
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Base 1.0.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) # base ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.386s
[INFO] Finished at: Tue Oct 08 08:22:46 EST 2013
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project base: You don't have a SNAPSHOT project in the reactor projects list. -> [Help 1]
release:prepare command is supposed to prepare your snapshot project for the release. It sounds like you don't have such a snapshot project.
Here's the full details what it'll do: http://maven.apache.org/maven-release/maven-release-plugin/examples/prepare-release.html
If you're sure you should be releasing, you should be working on a maven module that has version ending with -SNAPSHOT.
Update: like noted by #khmarbaise in the comments, if your release has failed, you should do release:rollback to go back to previous state. Note though that it is not supported if you release through jenkins (jenkins issue), and it won't rollback the tags.
Don't needed manually edit pom.xml.
You can use "mvn versions:set" for batch update, something like this:
mvn versions:set -DnewVersion=1.0.3-SNAPSHOT
I've had the same error with Jenkins. In a previous release, Jenkins updated the version of the POM to a non-snapshot version, but the build failed before Jenkins could set the version to a -SNAPSHOT version again. Afterwards, making a release resulted in the error described above.
Fixing this is easy: just manually change the version of your app in pom.xml to a -SNAPSHOT version.
I know this is an old question but I had this issue recently and I found 2 solutions that others may find useful. I am using bamboo as my CI tool. The issue was that there was an error in the bamboo build leaving bamboo in an incorrect state. It had locally updated my project pom.xml with the new release version but had not checked this into SVN. The two solution that worked for me were:
Either
Delete the bamboo build-dir directory for the project and run the release again: rm -rf /opt/bamboo-home/xml-data/build-dir/PROJECT_NAME-RELEASE-JOB1
OR
Run the maven release from the command line using the following commands:
mvn release:prepare -DignoreSnapshots -Dresume=false
mvn release:perform
No need to update versions manually as that is time consuming, if version change is all you need, there is a different command that only updates the pom versions, just like updating them manually:
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=1.0.XX-SNAPSHOT