简体   繁体   English

如何通过Maven pom.xml安装Grails插件?

[英]How to install Grails plugins through Maven pom.xml?

I'm building a Grails project with Maven, which is the required way of building at my company. 我正在用Maven建立一个Grails项目,这是我公司建立的必要方式。

On my local machine, I have installed a Grails plugin in the usual way grails install-plugin foo . 在我的本地机器上,我以通常的方式安装了Grails插件grails install-plugin foo Of course, when the project is built by Maven on the build server, it knows nothing about this plugin. 当然,当项目由构建服务器上的Maven构建时,它对此插件一无所知。

I've seen that the following can be useful for the case where the plugin is available in the plugins directory of Grails: 我已经看到以下内容对于插件在Grails的plugins目录中可用的情况很有用:

<plugin> 
  <groupId>org.grails</groupId> 
  <artifactId>grails-maven-plugin</artifactId> 
  <version>1.1</version> 
  <extensions>true</extensions> 
  <executions> 
    <execution> 
      <id>create plugins folder</id> 
      <phase>validate</phase> 
      <goals> 
        <goal>install-plugin</goal> 
      </goals> 
      <configuration> 
        <pluginUrl>${env.GRAILS_HOME}/plugins/grails-hibernate-1.1.zip</pluginUrl>                 
      </configuration> 
    </execution> 
  </executions>           
</plugin> 

but suppose the plugin was not on the machine at all? 但是假设插件根本不在机器上? What would the pluginUrl be in the case where Maven or Grails will need to go to the internet to find the plugin? 在Maven或Grails需要访问互联网查找插件的情况下, pluginUrl会是什么?

Edit: 编辑:

I've found that the pluginName and pluginVersion tags are useful, and I've added the following execution to the grails-maven-plugin : 我发现pluginNamepluginVersion标签很有用,我在grails-maven-plugin添加了以下执行:

<execution>
  <id>Hibernate plugin</id>
  <phase>validate</phase>
  <goals>
    <goal>install-plugin</goal>
  </goals>
  <configuration>
    <pluginName>hibernate</pluginName>
    <pluginVersion>1.3.7</pluginVersion>
  </configuration>
</execution>

This almost works. 几乎可行。 If I check out my code in a new directory, and delete the contents of my plugins directories, Maven is able to build the project, successfully finding all plugin dependencies. 如果我在新目录中检出我的代码,并删除我的插件目录的内容,Maven就能够构建项目,成功找到所有插件依赖项。

Yet it still doesn't work on the build server. 但它仍然无法在构建服务器上运行。 Any ideas? 有任何想法吗?

Try adding this dependency to your pom.xml 尝试将此依赖项添加到您的pom.xml

<dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>fields</artifactId>
    <version>1.3</version>
    <type>zip</type>
    <scope>runtime</scope>
</dependency>

when you recompile your App maven will download and install the plugin 当你重新编译你的应用程序时,maven将下载并安装该插件

You need to use Grails Maven plugin, so the pom will get updated with changes to the plugin list. 您需要使用Grails Maven插件,因此pom将通过更改插件列表进行更新。 Have a look at Grails documentation describing Maven integration , especially the section on "mavenizing" the project. 看看描述Maven集成的Grails文档 ,特别是关于“对项目进行”整理的部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM