在这里完成Maven newb,所以请原谅任何滥用的术语等。
我在 Maven 3 中构建了一个自定义插件(一个定义了 git rebase 目标的插件)。我能够:
mvn install
Run Code Online (Sandbox Code Playgroud)
没问题。然后我可以从命令行调用目标:
mvn edu.clemson.cs.rsrg:git-plugin:rebase
Run Code Online (Sandbox Code Playgroud)
一切都是金色的。我的目录中有这个可爱的 git-plugin-XXX.jar 文件target。
我想让我的自定义目标可用于另一个项目,这样当开发团队的其他成员拉取该项目的源时,他们可以免费获得我的插件(或至少在 之后mvn build)。
我的理解是纯粹的解决方案是为该组设置一个 maven 存储库并在那里加载我的插件,但这对于单个 hacky 插件来说似乎有点过分。
想法?
到目前为止,我已经通过三个不同的插件进行了尝试:
addjars-maven-plugin:add-jars
<插件>
<groupId>com.googlecode.addjars-maven-plugin</groupId>
<artifactId>addjars-maven-plugin</artifactId>
<版本>1.0.4</version>
<执行>
<执行>
<目标>
<goal>add-jars</goal>
</目标>
<配置>
<资源>
<资源>
<目录>${basedir}/plugins</directory>
</资源>
</资源>
</配置>
</执行>
</执行>
</插件>
在以下期间给我这个错误mvn build:
[ERROR] Error resolving version for plugin 'edu.clemson.cs.rsrg:git-plugin' from the repositories [local (/home/hamptos/.m2/repository), central (http://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository
它还导致我后来的格式化插件失败。(显然它读取了 jar 并确定了组名/插件名,但随后它会在我的本地存储库中查找它?当然它不在那里——我正在尝试安装它。)
build-helper:attach-artifacts
<插件>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<版本>1.7</version>
<执行>
<执行>
<id>附加工件</id>
<阶段>安装</阶段>
<目标>
<goal>附加工件</goal>
</目标>
<配置>
<神器>
<神器>
<file>${basedir}/plugins/git-plugin-0.1.0a.jar</file>
<type>jar</type>
</神器>
</神器>
</配置>
</执行>
</执行>
</插件>
在以下期间给我这个错误mvn build:
[ERROR] Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.7:attach-artifact (attach-artifacts) on project RESOLVE: Execution attach-artifacts of goal org.codehaus.mojo:build-helper-maven-plugin:1.7:attach-artifact failed: For artifact {edu.clemson.cs.rsrg:RESOLVE:12.09.01a:jar}: An attached artifact must have a different ID than its corresponding main artifact.
(解决:12.09.01a 是主项目。显然这里出了点问题,因为插件和主项目肯定有不同的 artifactID。试图将项目附加到自身之上?)
maven-install-plugin:install-file
<插件>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<版本>2.3.1</version>
<执行>
<执行>
<id>安装-git-plugin</id>
<phase>初始化</phase>
<目标>
<目标>安装文件</目标>
</目标>
<配置>
<file>${basedir}/plugins/git-plugin-0.1.0a.jar</file>
<packaging>jar</packaging>
<groupId>edu.clemson.cs.rsrg</groupId>
<artifactId>git-plugin</artifactId>
<版本>0.1.0a</version>
</配置>
</执行>
</执行>
</插件>
似乎工作正常,直到我尝试调用其中一个目标,例如mvn edu.clemson.cs.rsrg:git-plugin:rebase,此时它给了我这个错误:
[ERROR] Failed to execute goal edu.clemson.cs.rsrg:git-plugin:0.1.0a:rebase (default-cli) on project RESOLVE: Execution default-cli of goal edu.clemson.cs.rsrg:git-plugin:0.1.0a:rebase failed: Unable to load the mojo 'rebase' (or one of its required components) from the plugin 'edu.clemson.cs.rsrg:git-plugin:0.1.0a': com.google.inject.ProvisionException: Guice provision errors:
[ERROR]
[ERROR] 1) Error in ComponentFactory:ant-mojo
[ERROR] at ClassRealm[plugin>edu.clemson.cs.rsrg:git-plugin:0.1.0a, parent: sun.misc.Launcher$AppClassLoader@e776f7]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=edu.clemson.cs.rsrg:git-plugin:0.1.0a:rebase)
| 归档时间: |
|
| 查看次数: |
1515 次 |
| 最近记录: |