简体   繁体   English

Grails-最低安装要求

[英]Grails - Minimum Installation for build

We have a defined a platform environment that includes specific Java, Ant, and Subversion versions. 我们已经定义了一个平台环境,其中包括特定的Java,Ant和Subversion版本。 The idea is that someone with this platform can checkout any project in our repository, run a build command, and can build that project without downloading any software, or doing any specific setup in order for the build to work. 这个想法是,使用此平台的人可以签出我们存储库中的任何项目,运行构建命令,并且可以在不下载任何软件或进行任何特定设置的情况下构建该项目,以使构建正常进行。

This is mainly done for my personal convenience (after all, I defined this platform). 这样做主要是出于个人方便(毕竟,我定义了该平台)。 I run the Jenkins server, and want to be able to build any project without going through a lot of conniptions. 我运行Jenkins服务器,并希望能够在不经历很多麻烦的情况下构建任何项目。 Jenkins should be able to do a checkout and build without any specific instructions or environment setup. Jenkins应该能够在没有任何特定说明或环境设置的情况下进行结帐和构建。

If a special product is needed, I usually ask that this product be included in the project's directory structure. 如果需要特殊产品,我通常会要求将此产品包含在项目的目录结构中。 For example, if a project depends upon Ant-Contrib to build, the antcontrib.jar should be in the project, and the <taskdef> should point to that jar in the project. 例如,如果一个项目依赖于Ant-Contrib来构建,则antcontrib.jar应该在项目中,而<taskdef>应该指向项目中的那个jar。

We have one Grails project, and I was hoping there was some way I could include a minimal Grails installation in that project just to do build. 我们有一个Grails项目,我希望可以通过某种方式在该项目中包含一个最小的Grails安装来进行构建。 All I have to run are the following commands: 我只需要运行以下命令:

  • grails clean
  • grails war

I understand that for development reasons, you may need a complete Grails installation, but I'm just interested in the build itself. 我了解出于开发原因,您可能需要完整的Grails安装,但是我只是对构建本身感兴趣。

I was thinking of installing Grails inside the project, but I downloaded Grails, and in the grails/dist folder, there are 33 Grails jars. 我当时想在项目中安装Grails,但我下载了Grails,在grails / dist文件夹中有33个Grails jar。 Under the lib folder, there are 300+ jars. lib文件夹下,有300多个jar。 Under the src folder, there are another 33 Grails jars. src文件夹下,还有33个Grails罐。 That's a wee bit too much to include inside the project as part of a checkout just so I can do a build. 太少了,无法作为检出的一部分包含在项目中,只是我可以进行构建。

Is there a compact subset that can be used just to run the build? 是否有一个仅可用于运行构建的紧凑子集?

If not, I'll have to install Grails on our build server. 如果没有,我将不得不在我们的构建服务器上安装Grails。 This isn't too much of an issue, but it does mean that anyone who wants to build this project must first install Grails. 这不是什么大问题,但这确实意味着任何想要构建此项目的人都必须首先安装Grails。 Plus, I'll have to document that this project needs a special installation and how it's done and all other dependencies. 另外,我将不得不记录该项目需要特殊的安装,完成方式以及所有其他依赖性。

If your version of Grails is new enough (2.1 or newer), there is actually a built-in command to generate a wrapper script which can be used without having to have Grails installed, for exactly the purpose you mentioned. 如果您的Grails版本足够新(2.1或更高版本),则实际上有一个内置命令可生成包装器脚本,而无需安装Grails即可使用该脚本,以达到您提到的目的。

The documentation says: 该文件说:

The Grails Wrapper allows a Grails application to built without having to install Grails and configure a GRAILS_HOME environment variable. Grails Wrapper允许构建Grails应用程序,而无需安装Grails和配置GRAILS_HOME环境变量。 The wrapper includes a small shell script and a couple of small bootstrap jar files that typically would be checked in to source code control along with the rest of the project. 包装器包括一个小的shell脚本和几个小的引导jar文件,通常将它们与项目的其余部分一起签入源代码控制。 The first time the wrapper is executed it will download and configure a Grails installation. 第一次执行包装程序时,它将下载并配置Grails安装。 This wrapper makes it more simple to setup a development environment, configure CI and manage upgrades to future versions of Grails. 这个包装器使设置开发环境,配置CI以及管理Grails未来版本的升级变得更加简单。 When the application is upgraded to the next version of Grails, the wrapper is updated and checked in to the source code control system and the next time developers update their workspace and run the wrapper, they will automatically be using the correct version of Grails. 当应用程序升级到下一个Grails版本时,包装程序将更新并签入源代码控制系统,而下一次开发人员更新工作区并运行包装程序时,他们将自动使用正确版本的Grails。

See the complete docs here: http://grails.org/doc/2.1.0/guide/single.html#wrapper 请参阅此处的完整文档: http : //grails.org/doc/2.1.0/guide/single.html#wrapper

I created a pom to mavenize my test grails app using create-pom . 我创建了一个pom来使用create-pom美化我的测试grails应用。 It looks like the below. 如下图所示。 Key items to note: 注意的关键事项:

  • Grails Version can be set which ever version you need. 可以设置Grails版本。 No need to install Grails. 无需安装Grails。 Maven would pull dependencies accordingly. Maven将相应地拉出依赖关系。
  • Note the dependency item grails-dependency which would pull the essential items grails would need. 请注意,依赖项grails-dependency将拉动grails所需的基本项。
  • Note the maven plugin grails-maven-plugin in the plugin section. 注意插件部分中的maven插件grails-maven-plugin This plugin hepls in running maven lifecycle in the Grails app. 该插件可在Grails应用程序中运行Maven生命周期。
  • We also get the option to fork the JVM for this grails app build instead of overloading the JVM when required using maven. 我们还可以得到选项fork的JVM这个Grails的应用程序,而不是构建使用maven需要时超载JVM的。

Once all the essential dependencies are, all you need to create a WAR is to run mvn install provided Apache Maven is install in the build box. 一旦所有基本依赖关系都存在,只要在构建框中mvn install Apache Maven,创建WAR所需要的就是运行mvn install

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example.test</groupId>
    <artifactId>TestGrailsApp</artifactId>
    <packaging>grails-app</packaging>
    <version>0.1</version>
    <name>TestGrailsApp</name>
    <description>TestGrailsApp</description>

    <properties>
        <grails.version>2.2.0</grails.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.grails</groupId>
            <artifactId>grails-dependencies</artifactId>
            <version>${grails.version}</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.grails</groupId>
            <artifactId>grails-test</artifactId>
            <version>${grails.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.grails</groupId>
            <artifactId>grails-plugin-testing</artifactId>
            <version>${grails.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.grails.plugins</groupId>
            <artifactId>tomcat</artifactId>
            <version>${grails.version}</version>
            <scope>provided</scope>
            <type>zip</type>
        </dependency>

    </dependencies>

    <build>
        <pluginManagement />

        <plugins>
     ...
            <plugin>
                <groupId>org.grails</groupId>
                <artifactId>grails-maven-plugin</artifactId>
                <version>${grails.version}</version>
                <configuration>
                    <!-- Whether for Fork a JVM to run Grails commands -->
                    <fork>true</fork>
                </configuration>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
.....

</project>

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

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