maven-protoc-plugin configuration in pom.xml incor

2019-05-13 22:32发布

问题:

Problem I am solving: I need a Maven plugin for Protobuf and from my google searches, I have concluded that the maven-protoc-plugin has the most mindshare at the moment. The most recent activity on this plugin was in March 2013 which is also very encouraging (Link: https://code.google.com/p/protobuf/issues/detail?id=476)

My roadblocks: I am unable to get the plugin to work. Specifically, I am unable to get the plugin to download. I use Maven with Eclipse [Eclipse Java EE IDE for Web Developers, Version: Juno Service Release 1 Build id: 20120920-0800] I have put the relevant snippets of the configuration I have added to my pom.xml below. There were multiple references that led me to this configuration but I am not being allowed to post them here. I have tried to reference them in some way (for complete information) and have noted issues with each of them:

  • Ref 1: On github (github.com), there is a location
    sergei-ivanovSLASHmaven-protoc-plugin - This has the configuration
    for the plugin repository but the URL mentioned in this resource is a 404 resource

  • Ref 2: The github HTTP location (sergei-ivanov.github.io) has an HTML file at maven-protoc-pluginSLASHproject-summary.html which has a
    Download URL that is not working either

  • Ref 3: The github location (sergei-ivanov.github.io) has another HTML file at /maven-protoc-pluginSLASHusage.html - This URL has a snippet that shows the configuration for: maven-protoc-plugin,
    maven-compiler-plugin and the protobuf-java dependency. It does NOT
    have a plugin repository configuration.

My XML is on pastebin at http://pastebin.com/VPyH3CPr

I am trying to run a goal in the plugin with the following commands through Eclipse Run Configuration: Goals: maven-protoc-plugin:protobufcompile Profiles: dev

I get the following messages: [INFO] Scanning for projects... [WARNING] The POM for com.google.protobuf.tools:maven-protoc-plugin:jar:0.3.1 is missing, no dependency information available [WARNING] Failed to retrieve plugin descriptor for com.google.protobuf.tools:maven-protoc-plugin:0.3.1: Plugin com.google.protobuf.tools:maven-protoc-plugin:0.3.1 or one of its dependencies could not be resolved: [ERROR] No plugin found for prefix 'maven-protoc-plugin' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\.m2\repository), all-repos (/artifactory/all-repos)] -> [Help 1] Some other errors here. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] URL for confluence/display/MAVEN/NoPluginFoundForPrefixException

Questions:

  1. Can I get a complete snippet of XML that needs to be added to the POM to get the maven-protoc-plugin to work?
  2. The plugin repository locations in the references I have listed seem to be dead ends. So, what is a valid place I can get the plugin from?
  3. Alternately, can somebody suggest what is wrong with my XML? The error output shows that my configuration is not having an effect during plugin resolution.
  4. I am relatively new to Maven and hence this newbie type of question: Can I just define goal names for the plugin like I did (protobufcompile) or does a Maven plugin come with pre-defined names that I cannot change?
  5. Tangentially related to the main problem in this entry: My .m2 directory was created when I created a Maven project and everything in it was automatically populated. My question is: Where is Maven getting the repository locations it is configuring in the settings.xml file from?

回答1:

If you want Sergei Ivanov fork of maven-protoc-plugin originally maintained by David Trott, just download one of Ivanov's relases such as 0.3.1 and install it manually.

cd maven-protoc-plugin-maven-protoc-plugin-0.3.1
mvn clean install

Then just follow the site usage guide to set up your project.

While I do recommend you to stick with Ivanov's fork; if you don't need the toolchain support or other contributed features, Trott's repo is still up and running.



回答2:

Regarding questions 3-5...

3. Alternately, can somebody suggest what is wrong with my XML? The error output shows that my configuration is not having an effect during plugin resolution.

Based on the xml you provided, the fact that you can't resolve the dependency is going to cause an error when you try to run a lifecycle. Also your one of your goals will cause an error, see below.

4. I am relatively new to Maven and hence this newbie type of question: Can I just define goal names for the plugin like I did (protobufcompile) or does a Maven plugin come with pre-defined names that I cannot change?

No, you can't. Goals are defined by the plugins you are using. Phases are defined by maven and are basically just different places in the build lifecycle

5. Tangentially related to the main problem in this entry: My .m2 directory was created when I created a Maven project and everything in it was automatically populated. My question is: Where is Maven getting the repository locations it is configuring in the settings.xml file from?

There are a few central repositories, which I don't know off the top of my head, but they basically hold all the plugins.

You can also have private repositories which is common for individual businesses to have.