Thursday, September 2, 2010

Building Groovy Projects with Maven

I built a prototype project just to prove I could get Maven to build and test a Groovy project in Eclipse.  Here's what I ended up using in the pom.xml file:


 4.0.0
 com.practice
 groovy-first
 1.0-SNAPSHOT

 
  
   junit
   junit
   4.4
  
  
   org.codehaus.gmaven.runtime
   gmaven-runtime-1.7
   1.3
  
 

 
  
   
    org.codehaus.gmaven
    gmaven-plugin
    1.3
    
     
      
       generateStubs
       compile
       generateTestStubs
       testCompile
      
     
    
   
  
 

From here you can run any standard Maven goals, compile, test, package, etc.  The gmaven-plugin translates those and performs the corresponding action within the plugin.

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.practice:groovy-first:jar:1.0-SNAPSHOT 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- gmaven-plugin:1.3:generateStubs (default) @ groovy-first ---
[INFO] Generated 6 Java stubs
[INFO] 
[INFO] --- maven-resources-plugin:2.4.1:resources (default-resources) @ groovy-first ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\sandbox\practice\groovy-first\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ groovy-first ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- gmaven-plugin:1.3:compile (default) @ groovy-first ---
[INFO] Compiled 14 Groovy classes
[INFO] 
[INFO] --- gmaven-plugin:1.3:generateTestStubs (default) @ groovy-first ---
[INFO] Generated 1 Java stub
[INFO] 
[INFO] --- maven-resources-plugin:2.4.1:testResources (default-testResources) @ groovy-first ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\sandbox\practice\groovy-first\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ groovy-first ---
[INFO] Compiling 1 source file to C:\sandbox\practice\groovy-first\target\test-classes
[INFO] 
[INFO] --- gmaven-plugin:1.3:testCompile (default) @ groovy-first ---
[INFO] Compiled 1 Groovy class
[INFO] 
[INFO] --- maven-surefire-plugin:2.4.3:test (default-test) @ groovy-first ---
[INFO] Surefire report directory: C:\sandbox\practice\groovy-first\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.practice.FileIOTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.25 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.2:jar (default-jar) @ groovy-first ---
[INFO] Building jar: C:\sandbox\practice\groovy-first\target\groovy-first-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.953s
[INFO] Finished at: Thu Sep 02 08:50:57 MDT 2010
[INFO] Final Memory: 9M/16M
[INFO] ------------------------------------------------------------------------

No comments:

Post a Comment