The Artima Developer Community
Sponsored Link

Java Buzz Forum
Groovy mavenisms again: Building a lib dir from dependencies

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Groovy mavenisms again: Building a lib dir from dependencies Posted: Dec 3, 2004 8:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Groovy mavenisms again: Building a lib dir from dependencies
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
To follow on in the same vein as my last post, I also have had the need now and then to take my maven world, and build a lib directory snapshot of my projects dependencies to pass on to others. This was used with people not using maven, and for awhile for my IDE to point too (although now I can % maven idea). The only annoying part of maven idea is that it whipes your config each time, and you can't share the project as the files are all absolute to your own personal maven repo. Maven Jar Builder #!/bin/env groovy # ----------------------------------------------------------------------------- # maven2jar.g: Take a given project.xml and build a directory with jar files # ----------------------------------------------------------------------------- import groovy.util.XmlParser import java.io.* import java.nio.channels.* # -- Enforce the project.xml and dir if (args.length 1) ? args[1] : "."; badFiles = [] mavenLocalRepository = System.getProperty("user.home") + "/.maven/repository" # -- Open up the file and do the work project = new XmlParser().parse(projectxml) project.dependencies.dependency.each { groupId = it.groupId[0].text() artifactId = it.artifactId[0].text() version = it.version[0].text() fromFileName = "${mavenLocalRepository}/${groupId}/jars/${artifactId}-${version}.jar" toFileName = "${todir}/${artifactId}-${version}.jar" println "-----------------------------------------------------------------------" println " Copying From: ${fromFileName}" println " Copying To : ${toFileName}" try { copyFile(new File(fromFileName), new File(toFileName)) } catch (Exception e) { println "Error: Could not copy: ${e}" } } # -- Define the function to copy the files def copyFile(inFile, outFile) { FileChannel sourceChannel = new FileInputStream(inFile).getChannel() FileChannel destinationChannel = new FileOutputStream(outFile).getChannel() sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel) sourceChannel.close() destinationChannel.close() }

Read: Groovy mavenisms again: Building a lib dir from dependencies

Topic: Careful with Gentoo Apache 1.3.32... Previous Topic   Next Topic Topic: [Nov 19, 2004 06:51 PST] 14 Links

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use