Monday, February 21, 2011

Geotools SWT/JFace module and its RCP integration

After some discussion in the geotools mailinglist about the possibility of a SWT port of the geotools swing module, Ian Mayo from the Debrief project funded the port. He also wanted the resulting port and documentation to be Open Sourced (thanks!).

The result looks like:


A tutorial adn the source code about how to get there are here.

Wednesday, February 16, 2011

Copy Maven Dependency Tree jars

Well, it is the second time I need to get the jar on which a maven project depends on and copy them into a non-maven application. Sure mvn dependency:tree is your friend to see which jars you need to copy. And there are also maven tasks that can do the copy. But what if I want to copy them over without polluting the pom? I couldn't find a quick way (I am sure someone will tell me :)), so I created a groovy script that would do that for me.

Here it is, change the path to the repo, change the path into which to copy to, and run the thing.




// copy also source jars?
def alsoSources = false;
// copy also javadoc jars?
def alsojavaDocs = false;
// your maven repo path
def repo = "/home/moovida/.m2/repository/"
// path to which to copy them
def copyPath = "/home/moovida/development/gt-swt-port-hg/rcp-gt-swt/libs/"


def mvnCommand = "mvn dependency:tree";
def proc = mvnCommand.execute();
proc.waitFor();

def output = proc.in.text;
// clean out what we need
def lista=[];
def lines = output.split("\n");
def depsList = [];
def startIndex = -1;
def endIndex = -1;
for (int i = 0; i < lines.size(); i++){
def line = lines[i];
if(line.startsWith("[INFO] [dependency:tree]")){
startIndex = i + 1;
continue;
}
if(startIndex != -1 && line.startsWith("[INFO] ----------")){
endIndex = i - 1
break;
}
if(startIndex == -1){
continue;
}

lista << line;
}

println "Search for:"
lista.each{
println it
}

println "---------------------------------------"
println "---------------------------------------"

// find jars
def basedir = new File(repo)
def files = [];
basedir.eachDirRecurse () { dir ->
dir.eachFileMatch(~/.*.jar/) { file ->
files << file
}
}

// extract name pattern and version
def fileBeginList = []
def versionList = []
lista.each{
def split = it.split(":");
fileBeginList << split[1]
versionList << split[3]
println "${split[1]} --- ${split[3]}"
}

def finalList = [];
// extract right jars paths from list
for (it in files){
def name = it.getName()
def path = it.getAbsolutePath()

if(!alsoSources && name.matches(".*sources.*")){
continue;
}
if(!alsojavaDocs && name.matches(".*javadoc.*")){
continue;
}

for (int i = 0; i < fileBeginList.size(); i++){
def fBegin = fileBeginList.get(i);
def version = versionList.get(i);
if(name.startsWith(fBegin)){
if(name.matches(".*"+version+".*")){
finalList << it;
break;
}
}
}
}

println "---------------------------------------"
println "---------------------------------------"
println "Found:"
finalList.each{
println it
}


println "---------------------------------------"
println "---------------------------------------"
if(copyPath){
println "Copy deps jars to: ${copyPath}"
finalList.each{
def name = it.getName();
def path = it.getAbsolutePath();
def newPath = new File(copyPath, name).getAbsolutePath();
new AntBuilder().copy ( file : path , tofile : newPath )
}
}





Worked well for me.

Thursday, February 3, 2011

uDig 1.2.1 is out

Copied over from the official uDig blog:

We have recently released uDig 1.2.1. This is an incremental update with mainly bug fixes but there are a few notable features added as well.

  • Additional style editor pages; thanks to the JGrass project and Hydrologis
  • Access to the latest GeoTools renderer with support for hatch patterns
  • Access to world+image "bmp" files
  • Experimental - WMS 1.3.0 support
  • Updated "submit log" in the help menu
Additional documentation:

  • Updated online help capturing the new style pages style pages
  • Updated intro documentation for users and developers

For developers:

  • We have migrated to a new git repository http://gitorious.org/udig
  • Access to the latest GeoTools 2.7 Release Candidate

The new release can be accessed and downloaded from http://udig.refractions.net/download/