Software Configuration Management Stuff

Tuesday, 28 June 2011

gmaven with groovy++

It took me a while to scratch around and find all the right bits. If you want to use groovy++ and the latest gmaven plugin then here's a sample pom that does the trick.

Groovy++ can be replaced with org.codehaus.groovy:groovy-all:1.8.0. Groovy++ is useful in that it does compile time type checking. This can save a huge amount of wasted in trying to figure out runtime errors.

The latest gmaven requires the use of annomojo annotations.

Ihave to thanks Evgeny Goldin for posting some working examples on his blog. His github collection of gmaven plugins is very handy both as a reference and for getting various tricky tasks accomplished.

 <?xml version="1.0" encoding="UTF-8"?>  
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
      <modelVersion>4.0.0</modelVersion>  
      <groupId>org.thump</groupId>  
      <artifactId>neil-maven-plugins</artifactId>  
      <version>1.0-SNAPSHOT</version>  
      <packaging>maven-plugin</packaging>  
      <dependencies>  
           <dependency>  
                <groupId>org.mbte.groovypp</groupId>  
                <artifactId>groovypp-all</artifactId>  
                <version>0.4.217</version>  
           </dependency>  
           <dependency>  
                <groupId>junit</groupId>  
                <artifactId>junit</artifactId>  
                <version>4.7</version>  
                <scope>test</scope>  
           </dependency>  
           <dependency>  
                <groupId>org.codehaus.gmaven</groupId>  
                <artifactId>gmaven-mojo</artifactId>  
                <version>1.3</version>  
           </dependency>  
           <dependency>  
                <groupId>org.jfrog.maven.annomojo</groupId>  
                <artifactId>maven-plugin-anno</artifactId>  
                <version>1.4.0</version>  
           </dependency>  
      </dependencies>  
      <build>  
           <plugins>  
                <plugin>  
                     <groupId>org.apache.maven.plugins</groupId>  
                     <artifactId>maven-plugin-plugin</artifactId>  
                     <version>2.7</version>  
                     <dependencies>  
                          <dependency>  
                               <groupId>org.apache.maven.plugin-tools</groupId>  
                               <artifactId>maven-plugin-tools-api</artifactId>  
                               <version>2.7</version>  
                          </dependency>  
                          <dependency>  
                               <groupId>org.jfrog.maven.annomojo</groupId>  
                               <artifactId>maven-plugin-tools-anno</artifactId>  
                               <version>1.4.0</version>  
                               <scope>runtime</scope>  
                          </dependency>  
                     </dependencies>  
                </plugin>  
                <plugin>  
                     <groupId>org.codehaus.gmaven</groupId>  
                     <artifactId>gmaven-plugin</artifactId>  
                     <version>1.3</version>  
                     <configuration>  
                          <providerSelection>1.7</providerSelection>  
                     </configuration>  
                     <executions>  
                          <execution>  
                               <id>generate-stubs</id>  
                               <phase>generate-sources</phase>  
                               <goals>  
                                    <goal>generateStubs</goal>  
                               </goals>  
                          </execution>  
                          <execution>  
                               <id>compile-groovy</id>  
                               <phase>process-sources</phase>  
                               <goals>  
                                    <goal>compile</goal>  
                               </goals>  
                          </execution>  
                     </executions>  
                     <dependencies>  
                          <dependency>  
                               <groupId>org.mbte.groovypp</groupId>  
                               <artifactId>groovypp-all</artifactId>  
                               <version>0.4.217</version>  
                          </dependency>  
                          <dependency>  
                               <groupId>org.codehaus.gmaven.runtime</groupId>  
                               <artifactId>gmaven-runtime-1.7</artifactId>  
                               <version>1.3</version>  
                               <exclusions>  
                                    <exclusion>  
                                         <groupId>org.codehaus.groovy</groupId>  
                                         <artifactId>groovy-all</artifactId>  
                                    </exclusion>  
                               </exclusions>  
                          </dependency>  
                     </dependencies>  
                </plugin>  
           </plugins>  
      </build>  
 </project>  



A simple groovy mojo:

 import org.apache.maven.project.MavenProject;  
 import org.codehaus.gmaven.mojo.GroovyMojo  
 import org.jfrog.maven.annomojo.annotations.*  
 @Typed  
 @MojoGoal("sayhello")  
 @MojoPhase("package")  
 public class TestMojo extends GroovyMojo {  
      @MojoParameter ( expression = '${project}', required=true)  
      public MavenProject mavenProject  
      @MojoParameter  
      def public String message  
   void execute() {  
     log.info("Saying Hello")  
     println "${message}"  
   }  
 }  

Monday, 27 June 2011

Subversion with Groovy via AntBuilder() and svnant

This took me a while to figure out and to get it all working.

I wanted to do svn operations from as groovy script without going near the svnkit API.

The other problem was having the runtime dependencies available from wherever the script is run from.


 @GrabConfig(systemClassLoader=true)  
                     @GrabResolver(name="fid", root="http://path-to-internal-repo/nexus/content/groups/mygroup")  
                     @Grab(group='org.tmatesoft.svnkit', module='svnkit', version='1.3.5')   
                     @Grab(group='org.tigris', module='svnant', version='1.3.0')   
                     @Grab(group='org.tigris', module='svnClientAdapter', version='0.9.102')   
                     @Grab(group='org.tmatesoft.svnkit', module='svnkit-javahl', version='1.3.5')  
                def message='Commited by jenkins admin - updated parent pom to my:parent:1.23'  
                     def ant = new AntBuilder()  
 ant.svn(username:"username", password:"password",failonerror:"false") {  
                     commit(file: pomFile, message:message )  
                }  
 ant.typedef(resource: "org/tigris/subversion/svnant/svnantlib.xml")  
ant.svn(username:"user", password:"password")
{
 checkout(url: "svn://svnserver/project/trunk", destPath: "/home/user/topath")
}






Using ~/.groovy/grapeConfig.xml

 <ivysettings>  
  <settings defaultResolver="downloadGrapes"/>  
  <resolvers>  
   <chain name="downloadGrapes">  
     <ibiblio name="local" root="file:${user.home}/.m2/repository/" m2compatible="true"/>    
    <filesystem name="cachedGrapes">  
     <ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>  
     <artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>  
    </filesystem>  
     <ibiblio name="fid" root="http://path-to-internal-repo/nexus/content/groups/mygroup" m2compatible="true"/>   
    <!-- todo add 'endorsed groovy extensions' resolver here -->  
    <!--<ibiblio name="ibiblio" m2compatible="true"/> -->  
   </chain>  
  </resolvers>  
 </ivysettings>  

Tuesday, 9 December 2008

yum problems

Prob with yum: [Errno -1] Metadata file does not match checksum Trying other mirro

yum clean metadata

Monday, 25 February 2008

Perforce Versus Subversion ?

The two leading light-weight source control tools on the market at the moment ? What are their pros and cons ?

What they have in common:

  • database backend
  • atomic transactions
  • fast branching and labeling operations
  • work over TCP/IP
  • client/server architecture
  • multi-platform support
  • strong command line tools (you can do everything you need on the command line)
Where things differ:

  • Perforce stores all information about developer's sandboxes and checkouts on the server . Perforce uses 'workspaces' (client specs) to track the relationship between checked-out code and its location on the server.
  • With perforce you have to open a file for edit before you can work on it
  • You can't move things around in the repository
  • Supports multiple change lists (you can break up your commit into smaller chunks)
  • Doesn't version directories
  • Can checkout single file
  • Limited integration with eclipse
  • Merge tracking
Subversion

  • SVN Creates .svn directories in developer's sandboxes on checkout.
  • You can move things (files, directories) around in the repository directly
  • Branching and tagging are all 'copy' operations
  • Subversion works offline
  • Have to checkout a directory (not a single file)
  • No easy way to split a commit into chunks with their own message
  • Does version directories (implications for refactoring)
  • Slick integration with eclipse
  • Merge tracking (coming)

Thinking of using Orcale Express for a development environment

Here's quite a good summary of the 'limitations' of oracle express. Seems a very fair set of restrictions to me.

http://www.oracle.com/technology/pub/articles/cunningham-database-xe.html

Basic init script for Perforce (p4d) on Suse

I've hacked this by chmoding p4d setuid user p4d. P4d should probably be launched with an su - or maybe there's some clever checking of daemon unix ownership by Suse.



/bin/sh

## Description: Start perforce server daemon
# Short-Description: Start perforce server daemon


# location of p4d
P4D=/usr/bin/p4d

# location of the repository
P4D_OPTS="-d -r /var/perforce"

# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_status -s display "skipped" and exit with status 3
# rc_status -u display "unused" and exit with status 3
# rc_failed set local and overall rc status to failed
# rc_failed set local and overall rc status to
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
# rc_active checks whether a service is activated by symlinks
# rc_splash arg sets the boot splash screen to arg (if active)
. /etc/rc.status

# First reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - user had insufficient privileges
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.

case "$1" in
start)
echo -n "Starting resource P4D (Perforce)"
if checkproc $P4D; then
rc_status -v
else
startproc $P4D $P4D_OPTS
rc_status -v
fi
;;
stop)
echo -n "Shutting down P4D (Perforce)"
killproc $P4D
rc_status -v
;;
try-restart|condrestart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
rc_exit
Powered by Blogger.