/* * Geotools2 - OpenSource mapping toolkit * http://geotools.org * (C) 2003, Geotools Project Managment Committee (PMC) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * */ import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FilenameFilter; import java.io.IOException; import java.io.PrintStream; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; /** * Quick utility that will update you Eclipse .project and .classpath file * to reflect the last build. *

* This utility will process buildReport.txt to determine * the build order (and to ensure that you actually try building with * maven first).

*

* For each project in buildReport.txt:

* * Example: *
 * maven build
 * java org.geotools2.build.GT2Eclipse
 * 
*

* If you are running this from eclipse remember to hit refresh afterwords.

* * @see org.geotools2.build * @author jgarnett, Refractions Reasearch Inc. * @version CVS Version */ public class GT2Eclipse { /** * List of demos based on geotools-demos */ public static Set demos(String path){ Set set = new TreeSet(); File geotools2demos = new File( path, "geotools-demos" ); String dir[] = geotools2demos.list(); String src; for( int i=0; imaven build command */ public static Set targets(String path){ try { BufferedReader buildReport = new BufferedReader( new FileReader( new File( path, "buildReport.txt") ) ); Set set = new TreeSet(); buildReport.readLine(); // skip first line String line; while( (line = buildReport.readLine()) != null ){ line = line.substring( line.indexOf(':')+1 ); line = line.substring( 0, line.indexOf(' ') ); // a few corrections if( line.equals( "oracle-spatial") ) line = "oraclespatial"; if( line.equals( "java2drendering") ) line = "Java2DRendering"; if( line.equals( "wmsserver")) continue; System.out.println("target "+line ); set.add( line ); } File geotools2src = new File( path, "geotools-src" ); String dir[] = geotools2src.list(); String src; for( int i=0; i'); int end = line.indexOf('<', start ); return line.substring( start+1, end ); } static public List process( String path, String target ) { List list = new LinkedList(); try { BufferedReader project = new BufferedReader( new FileReader( new File( path, target ) ) ); String line; line = project.readLine(); // first line // skip till dependencies for ( ; line != null; line = project.readLine() ){ line = line.trim(); if( line.equals( "" ) ) break; } for( ; line != null; line = project.readLine() ){ line = line.trim(); if( line.equals( "" ) ) break; if( line.equals( "" ) ){ String id = null; String version = null; for(; line != null; line = project.readLine() ){ line = line.trim(); if( line.equals( "" ) ) break; if( line.startsWith("")) id = tag( line ); if( line.startsWith("")) version = tag( line ); if( line.startsWith("")) id = tag( line ); } if( version.equals("0.1") || version.indexOf("SNAPSHOT") != -1 ){ break; // intra module dependency } else { // JTS/jars/JTS-1.3.jar list.add( id + "/jars/"+id+"-"+version+".jar" ); } } } return list; } catch (FileNotFoundException e) { e.printStackTrace(); System.err.println( "Please run maven.build from your geotools2 directory." + "This will generate the file buildReports.txt required" ); } catch (IOException e){ e.printStackTrace(); System.err.println( "Problem understanding the file buildReports.txt" ); } return list; } public static void entry( PrintStream classpath, String project, String path, String target ){ if( new File( project, path+"/"+target+"/src").exists() ){ classpath.println(" " ); } if( new File( project, path+"/"+target+"/tests/unit").exists() ){ classpath.print(" " ); } } public static void main( String args[] ) { String dir = null; if( args.length == 0 ){ dir = "../geotools2"; } else if( args[0].equals("-h") || args[0].equals("-help")){ System.out.println("use: java GT2Eclipse geotools2directory"); System.out.println(); System.out.println("Please run maven build prior to using this utility"); System.exit(0); } else { dir = args[0]; } PrintStream classpath = System.out; PrintStream project = System.out; try { File file = new File( dir, ".classpath"); classpath = new PrintStream( new FileOutputStream( file, false)); System.out.println( "Writing .classpath to:"+file ); file = new File( dir, ".project"); project = new PrintStream( new FileOutputStream( file, false)); } catch (FileNotFoundException e) { e.printStackTrace(); System.out.println("Could not create files at:"+dir ); System.exit(1); } classpath.println(""); classpath.println(""); String target; Set targets = targets( dir ); for( int t=1; t" ); for( Iterator i=dependencies( dir, targets ).iterator(); i.hasNext();){ String jar = (String) i.next(); classpath.println(" " ); } classpath.println(" "); classpath.println(" " ); classpath.println(""); classpath.close(); project.println(""); project.println(""); project.println(" gtbuild"); project.println(" Welcome to the homepage of the GeoTool2 build process In the left side bar you should see a list of active modules, visit each for more details on the status of each module."); project.println(" "); project.println(" "); project.println(" "); project.println(" "); project.println(" org.eclipse.jdt.core.javabuilder"); project.println(" "); project.println(" "); project.println(" "); project.println(" "); project.println(" "); project.println(" org.eclipse.jdt.core.javanature"); project.println(" "); project.println(""); } }