Robert Achmann
Robert Achmann

Reputation: 2035

maven fails to recognize jetty is installed

fresh meat newbie on GCP / Maven on

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?

Upvotes: 0

Views: 478

Answers (1)

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49462

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>

Upvotes: 1

Related Questions