Grails actually has some of its own project management commands, such as Grails package,grails test-app,grails War. But the company is now basically using MAVEN to manage the project, so for the purpose of unified management, we have also let the Grails project be managed by MAVEN.
Grails and Maven are integrated by the MAVEN plug-in mechanism.
Next describe the steps for integration:
1. Configuring plugin Group in $home/.m2/settings.xml
<settings>
...
<pluginGroups>
<pluginGroup>org.grails</pluginGroup>
</pluginGroups>
</settings>
Before the configuration, to run the grails:help command to write this: mvn org.grails:help, after the configuration we can write: mvn grails:help.
2. We create a MAVEN managed Grails project
MVN org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate
-dgroupid=example-dartifactid=my-app
Grails-maven-archetype here is the version 1.2.0, as if the Maven3 integrated version is newer than this one.
3, enter My-app current directory, run MVN initialize
The following issues may occur during the run:
Resolving plugin JAR dependencies ...
:: Problems Summary::
:::: WARNINGS
Module not Found:org.hibernate#hibernate-core;3.3.1.ga
Then you add plugins.hibernate=1.3.2 in the Application.properties file
plugins.tomcat=1.3.2 of two plugins. Finally, run MVN compile to recompile the project.
4, we are using SpringSource tool Suite development, import engineering. The project requires an Excel operation, we use the Jxl.jar open source package. Configure the following in the Pom file:
<dependency>
<groupId>jxl</groupId>
<artifactId>jxl</artifactId>
<version>2.4.2</version>
</dependency>
The project was recompiled, but the file referencing the class in the JXL package was an error, saying the class could not be found. What's going on here? I am also very puzzled, the general Maven works like this can be.
Later, in the official document saw a sentence: Pom=true. Just add this sentence to the Grails.project.dependency.resolution method in the Conf/buildconfig.groovy file. As shown in figure:
Recompile, but still an error. The IDE is still unable to reference the classes in the JXL package. Later found a command found in Grails tools.
After execution, it has been added to the Grails dependencies.
Why is this, because there are two sets of mechanisms caused.
The first set of mechanisms: MAVEN's own mechanism for managing projects.
The second set of mechanisms: Grails also has its own set of management mechanisms.
In the vast majority of cases, MAVEN can be used to package, deploy, run tests, and manage projects through Grails's integrated plug-ins.
Grails can be packaged, deployed, run tests, and more managed through commands such as the Grails War.
Grails can also configure Pom=true to let Grails's management mechanism use the configuration in Pom without using its own management mechanism. At this point, you don't have to manage dependencies and resource pool configurations in Conf/buildconfig.groovy.