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

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.

Related

Error executing maven goal for Apache Camel with spring archetype

I'm new to maven and I'm trying to create a Apache Camel project using maven. I ran the following maven command to run a maven goal (all in the same command line):
mvn archetype:generate
-DgroupId=com.mycompany.app –DartifactId=camel-first-app
–DarchetypeGroupId=org.apache.camel.archetypes –DarchetypeArtifactId=camel-archetype-spring -DinteractiveMode=false -X
I get a build failure from maven with an exception saying:
"org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory"
I'm doing this without having the POM.xml file in the current directory because in the Maven Guide it says you don't need one to begin with.

How to skip some java files from compilation in maven using command line?

I am using maven with jenkins. On eclipse the project build works fine. When I use jenkins I get the following error
[ERROR] /E:/jenkins/workspace/product/src/test/java/com/new/ftp/FTPTest.java:[102,55] package com.fasterxml.jackson.databind does not exist
The options for maven are as follows:
mvn clean install -X
I want to know if I can pass some arguements to maven to skip that package. I don't want to modify my pom.xml yet .
P.S - The project consists of a main pom.xml which calls other child modules.

Maven 3 - Unable to find archetype

I have created a customized archetype, customA-web-archetype. Within the project folder, customA-web-archetype , I ran mvn clean install archetype:update-local-catalog which was successful. Now when I run mvn archetype:generate -DarchetypeCatalog=local outside the folder to use the archetype, I am getting the following error:
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
Your filter doesn't match any archetype (hint: enter to return to initial list)
FYI- When I was setting up Maven, I moved the .m2 to a different directory rather than using the default home directory. I made the appropriate change to settings.xml so that it can find the .m2 in the updated directory structure.
I am not using any repo manager such as Nexus. Just a local m2 repo sitting on the same box as the archetype project.
To run the archetype command, you need to specify the groupId, artefactId and version of your archetype, as well as those of your future maven project.
You should try the following command, with your own parameters:
mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=yourArchetypeGroupId -DarchetypeArtifactId=yourArchetypeArtifactId -DarchetypeVersion=yourArchetypeVersion -DgroupId=projectGroupId -DartifactId=projectArtifactId -DinteractiveMode=false
After upgrading from Maven 2 to 3 we found the same problem. The fix was to change the version of the archetype-packaging and maven-archetype-plugin from 2.2 to 3.0.0 in the archetype pom.
I looks like maven moved the location of it's archetype repository file from ~/.m2 to ~/.m2/repositories which is why generate wasn't finding it.
One strange behavior I'm still seeing is that if I just do
mvn archetype:generate
it doesn't show my local archetypes, however if I do a
mvn archetype:generate -DarchetypeCatalog=local
it shows up. Hope this helps.
Have you tried crawling the repo to create a catalog? Perhaps it's missing / broken? Archetype plugin has crawl goal, which parses the repo and creates catalog.xml.
mvn archetype:help
[... snip ...]
archetype:crawl
Crawl a Maven repository (filesystem, not HTTP) and creates a catalog file.

Could not resolve dependencies for project, except when called with package

I have an EAR project, defined very similarly as the reference project of WildFly. In addition to that, I have another JAR project JarProject
which is included in:
parent's pom.xml (as a <module> and in its <dependencyManagement>)
the EjbProject's pom.xml (with the scope provided)
the EarProject's pom.xml (with the default scope, compile)
The problem is that when executing mvn eclipse:eclipse or mvn wildfly:deploy (from the parent project) it fails with the error
[ERROR] Failed to execute goal on project EjbProject: Could not resolve dependencies for project groupId:EjbProject:jar:0.0.4-SNAPSHOT: Could not find artifact groupId:JarProject:jar:0.0.4-SNAPSHOT -> [Help 1]
It somehow looks the JarProject in the local repository, and does not see it in the parent project.
Very important note: mvn package works without problems, as mvn package wildfly:deploy or mvn package eclipse:eclipse do, but without pacakgeing before eclipse:eclipse, it fails.
Maven version: 3.0.4 and 3.3.3
I'm not sure I got the question. Hope this will help...
Goals "eclipse:eclipse" and "wildfly:deploy" do not trigger building of your projects. To use a project as a dependency it needs to be built from the parent pom or installed in you repository.
When you do mvn package eclipse:eclipse the package triggers the build of the JarProject.
If you want do be able to do only mvn eclipse:eclipse then you need to perform a mvn install on your JarProject first.

maven-bundle-plugin: The defined artifact is not an archetype

I configured the "maven-bundle-plugin" from Apache Felix as a Maven Archetype in Eclipse (since it was missing), but when I try to create a new Maven project with it, I get as error:
Unable to create project from archetype [org.apache.felix:
maven-bundle-plugin:2.3.5 -> ]
The defined artifact is not an archetype
I then tried the same procedure with ops4j Pax (which is pre-configured in Eclipse), which seems to be something similar, and it worked, so I think I'm doing it right and the problem is with "maven-bundle-plugin".
What does the error message mean, and what can I do to fix it, or am I somehow getting this all wrong?
[EDIT] While I can create the project with ops4j Pax, I afterward get:
Project build error: Unknown packaging: bundle
which as apparently been fixed in 2009! So this obviously doesn't work either.
I finally had success with the following procedure:
cd workspace
mvn org.ops4j:maven-pax-plugin:create-bundle -Dpackage=demo.service
-DbundleGroupId=demo.service -DbundleName=demo.service-bundle
-Dversion=0.1
cd demo.service-bundle
mvn org.ops4j:maven-pax-plugin:eclipse
# Import project as Eclipse project
# (I haven't try to import it as maven project)
And btw, it took me about ages to work out why this doesn't work in a Windows batch file: that is because mvn is itself a batch file, and so you have to use "call".

Resources