mvn command without anything throws build failure error - maven

Okay, I am totally new to maven and just installed one.
I have configured JAVA_HOME so that when I type mvn -version, the message shows with
Apache Maven 3.3.9
Maven home: /user/share/maven
Java version: 1.8.0_131, ...
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
And I just typed "mvn" out of curiosity, which throw an error back at me.
Now when I am trying to clean using mvn clean,
I get all the errors related to build failure.
Can someone tell me where to go next from here?

You need a pom.xml file in your current working directory. Put this into a new pom.xml and you'll see the error change to something more descriptive:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1</version>
</project>

Related

Maven release plugin

Hi Meier I have used the following goal
mvn org.codehaus.mojo:versions-maven-plugin:2.7:update-property -
Dproperty=emom.web.dependency.shr.version -DallowSnapshots=true
My Job B pom.xml is
<dependency>
<groupId>com.safeway.app</groupId>
<artifactId>emom-shr</artifactId>
<version>${emom.web.dependency.shr.version}</version>
</dependency>
Under the properties it has version harcoded
<emom.web.dependency.shr.version>19.6.5-
SNAPSHOT</emom.web.dependency.shr.version>
My Job A pom.xml
<groupId>com.safeway.app</groupId>
<artifactId>emom-shr</artifactId>
<version>20.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
When I run the above goal maven is picking the latest version i,e(20.1.0)
from artifactory but when I check the pom.xml of Job B under properties it still says 19.6.5 I need a way to change the 19.6.5 or current version to latest version available. Am I doing something wrong not able to figure it out.
You need versions:update-property to update the content of properties in your POM.
See https://www.mojohaus.org/versions-maven-plugin/update-property-mojo.html

maven fails to recognize jetty is installed

fresh meat newbie on GCP / Maven on
OSX 10.14.3 with Visual Studio Code (latest)
GCP SpringBoot API with Maven
other questions on jetty seem to be further along than me.
the 'flow' below is to reveal steps to get to my question in the title...I think it's important to see how I got to where I am, and if you are so kind to offer help, you would want to know this? ok, here we go...
I downloaded the GCP getting-started-java github example and want to run the bookshelf example.
When I look at the multiple POM files I see that each references a project ID for GCP.
I can't use the same project ID as they are unique, just like GCP bucket names.
So, when I run
gcloud init
and select or create a configuration and make my own project with a unique project id, does that automatically override every POM file definition of project ID? Or do I need to do some maven clean command to change it???
Well... when I RTFM in each folder, it says to
mvn clean jetty:run-exploded -Dbookshelf.bucket=MY-BUCKET
heck even tried:
mvn jetty:run
and I get a build failure that says:
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups
so... I
brew install jetty
Then to 'get started' jetty says I have to copy the 'plug in' details into my POM file... which one, as there are several??
But when I installed the VS Code plugin, it already updated all POM files; I still get the "No plugin found for prefix 'jetty'" error
I guess I'll stop with that question:
how do I get maven to 'know' that jetty is installed and work with it?
When you use the shorthand plugin goal jetty:run-exploded or jetty:run maven is attempting to find the plugin. This shorthand form will need to resolve the groupId:artifactId:version:goal in order to run.
The long-hand form of that would be ...
$ mvn org.eclipse.jetty:jetty-maven-plugin:9.4.15.v20190215:run
To fix this, just add the plugin to your pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<build>
...
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.15.v20190215</version>
</plugin>
</plugins>
</pluginManagement>
...
</build>
</project>
The above will always use that specific version of jetty-maven-plugin when you use the shorthand syntax.
Alternatively, and with less control over which version to use, is to setup a pluginGroup in maven's $HOME/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<pluginGroups>
<pluginGroup>org.eclipse.jetty</pluginGroup>
</pluginGroups>
...
</settings>

Change version of Maven project without manipulating the POM file

Is it somehow possible to change the version of a Maven project without manipulating the POM file?
Let's say I have a Maven project with version 1.5.0-SNAPSHOT but I want to build it as 1.5.46.
The Versions Maven Plugin unfortunately modifies the POM files.
Since Maven 3.5.0 this is possible using a special predefined property: ${revision}. Define the property with a default value (e.g. 1.5.0-SNAPSHOT) and when needed, set it during execution to a specific version (e.g. 1.5.46).
For example, define the following in your pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>foo</artifactId>
<name>Foo Module</name>
<version>${revision}</version>
...
<properties>
<revision>1.5.0-SNAPSHOT</revision>
</properties>
</project>
Build it using the default value:
mvn clean install
This will produce an artifact identified as org.example:foo:1.5.0-SNAPSHOT.
In order to build a specific version, set the revision property, for example:
mvn clean install -Drevision=1.5.46
This will produce an artifact identified as org.example:foo:1.5.46.
For further details, see the Maven CI Friendly Versions page.
Try to override project version with
mvn versions:set -DnewVersion=<version>
in your particular case:
mvn versions:set -DnewVersion=1.5.46
You can
Make a copy of your pom as temppom.xml
Replace the version in temppom.xml
Build with mvn -f temppom.xml.
Delete temppom.xml.
Maven supports delivery friendly versions, see https://issues.apache.org/jira/browse/MNG-5576 .
For more details I would suggest to talk with #khmarbaise
The plugin provides a goal to revert the changes made by it:
mvn versions:revert

I am getting an error in mule 3.7 maven dependencies

when i am trying to update the dependencies in maven it is throwing an error "There was an error running the studio:studio goal on project " please help me in this.
You are probably using mule-app-maven-plugin without configuring extensions to true. Try to edit your pom.xml and make the config look like this:
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-app-maven-plugin</artifactId>
<version>1.0</version>
<extensions>true</extensions>
</plugin>
From the exception you're pasting in your comments, it looks like you're trying to build your Mule APP with a JRE, in this case you would need to build using a JDK, please make sure your JAVA_HOME environment variable points to a JDK and attempt the build.

Maven: Including external JAR in POM

I know questions like this have been asked and answered before, and have taken the time to read those threads, but somehow they won't help me. I have locally added own Java code to the DSpace software, and my code depends on another library, so I'll have to include this library (JAR) into the <dependencies> section of the POM, right? This is what my entry looks like:
<dependency>
<groupId>de.mannheim.ids</groupId>
<artifactId>pid</artifactId>
<version>0.0.1-SNAPSHOT</version>
<systemPath>/absolute/path/to/jar/pid-client-0.0.1-SNAPSHOT.jar</systemPath>
<scope>system</scope>
</dependency>
This does not help but results in a Compile Error - the relevant classes cannot be found. I have also tried mvn install:install-file -Dfile..., which tells me everything is fine with the jar (BUILD SUCCESS), but the subsequent mvn package fails with the usual error.
What could I be doing wrong?
You should be able to use the artifact as usual after using mvn install:install.
If that command returned Build successful you should be able to use this in your pom:
<dependency>
<groupId>de.mannheim.ids</groupId>
<artifactId>pid</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Maven will find it like it would find any jar in your local repository.

Resources