Index: lams_build/.classpath
===================================================================
diff -u -r49c977067df3da97570afce0d9a470d71c529169 -r62bb87b924ab3c6a68e521ba546488602d5f93f2
--- lams_build/.classpath (.../.classpath) (revision 49c977067df3da97570afce0d9a470d71c529169)
+++ lams_build/.classpath (.../.classpath) (revision 62bb87b924ab3c6a68e521ba546488602d5f93f2)
@@ -1,6 +1,7 @@
+
Index: lams_build/liblist.conf
===================================================================
diff -u
--- lams_build/liblist.conf (revision 0)
+++ lams_build/liblist.conf (revision 62bb87b924ab3c6a68e521ba546488602d5f93f2)
@@ -0,0 +1,2 @@
+build_related = catalina,httpunit,junit,middlegen,xdoclet,strutstestcase
+
Index: lams_build/liblist.txt
===================================================================
diff -u
--- lams_build/liblist.txt (revision 0)
+++ lams_build/liblist.txt (revision 62bb87b924ab3c6a68e521ba546488602d5f93f2)
@@ -0,0 +1,166 @@
+Deployed Libraries
+
+Folder Library Version License Vendor Description
+
+annotation annogen-0.1.0.jar 0.1.0
+
+axis axiom-api-1.0.jar 1.0 Apache License 2.0
+ axiom-impl-1.0.jar 1.0
+ axis2-adb-1.0.jar 1.0 Apache Software Foundation Axis 2.0
+ axis2-codegen-1.0.jar 1.0 Apache Software Foundation Axis 2.0
+ axis2-java2wsdl-1.0.jar 1.0 Apache Software Foundation Axis 2.0
+ axis2-jibx-1.0.jar 1.0 Apache Software Foundation Axis 2.0
+ axis2-kernel-1.0.jar 1.0
+ axis2-soapmonitor-1.0.jar 1.0 Apache Software Foundation Axis 2.0
+ axis2-xmlbeans-1.0.jar 1.0 Apache Software Foundation Axis 2.0
+
+cglib cglib-nodep-2.1_2.jar 2.1_2
+
+concurrent backport-util-concurrent-2.1.jar 2.1
+ concurrent-1.3.4.jar 1.3.4
+
+dom4j dom4j-1.5.2.jar 1.5.2 MetaStuff Ltd. dom4j : XML framework for Java
+
+ehcache ehcache-1.1.jar 1.1
+
+fckeditor FCKeditor-2.3.jar 2.3
+
+geronimo geronimo-spec-activation-1.0.2-rc4.jar 1.0.2-rc4 Apache License 2.0 Apache Software Foundation Java Activation Framework
+ geronimo-spec-javamail-1.3.1-rc5.jar 1.3.1-rc5 Apache License 2.0 Apache Software Foundation JavaMail API 1.3.1
+ geronimo-spec-jms-1.1-rc4.jar 1.1-rc4 Apache License 2.0 Apache Software Foundation J2EE JMS Specification
+
+hibernate hibernate3.jar 3.1.3
+
+j2ee jstl.jar 1.1.2 Sun Microsystems, Inc. JavaServer Pages Standard Tag Library (JSTL)
+
+jakarta-commons commons-beanutils.jar 1.6 Apache License 2.0 Apache Software Foundation Jakarta Commons Beanutils
+ commons-codec-1.3.jar 1.3 Apache License 2.0 Apache Software Foundation Jakarta Commons Codec
+ commons-collections.jar 3.1 Apache License 2.0 Apache Software Foundation Commons Collections
+ commons-digester.jar 1.6 Apache License 2.0 Apache Software Foundation Jakarta Commons Digester
+ commons-fileupload.jar 1.0 Apache Software License 1.1 Apache Software Foundation File upload component for Java servlets
+ commons-httpclient.jar 3.0.1 Apache License 2.0 Apache Software Foundation Jakarta Commons HttpClient
+ commons-lang-2.0.jar 2.0 Apache Software License 1.1 Apache Software Foundation Jakarta Commons Lang
+ commons-logging.jar 1.0.4 Apache License 2.0 Apache Software Foundation
+ commons-validator.jar 1.1.4 Apache License 2.0 The Apache Software Foundation Commons Validator
+
+jakarta-poi poi-2.5.1-final-20040804.jar 2.5.1-final-20040804
+
+jakarta-taglibs standard.jar 1.1.2 Apache Software Foundation JavaServer Pages Standard Tag Library (JSTL)
+
+jboss jboss-cache.jar 4.0.2 JBoss Inc. JBoss
+ jboss-common.jar 4.0.2 JBoss Inc. JBoss
+ jboss-jmx.jar 4.0.2 JBoss Inc. JBoss
+ jboss-system.jar 4.0.2 JBoss Inc. JBoss
+ jgroups.jar 4.0.2 JBoss Inc. JBoss
+
+jdom jdom.jar
+
+jfreechart gnujaxp.jar GPL Free Software Foundation
+ jcommon-1.0.0.jar 1.0.0
+ jfreechart-1.0.1.jar 1.0.1
+
+log4j log4j-1.2.13.jar 1.2.13
+
+mysql mysql-connector-java-3.1.12-bin.jar 3.1.12-bin
+
+odmg odmg-3.0.jar 3.0
+
+quartz quartz.jar 1.5.2 OpenSymphony
+
+smack smack.jar
+ smackx.jar
+
+spring spring.jar 1.2.8
+
+struts antlr.jar
+ jakarta-oro.jar oro Apache Software License 1.1
+ struts-el.jar el
+ struts.jar 1.2.7 Apache License 2.0 The Apache Software Foundation Struts Framework
+
+wddx wddx.jar 1.1
+
+wsdl4j wsdl4j-1.5.2.jar 1.5.2 IBM JWSDL
+
+wspolicy neethi-1.0.1.jar 1.0.1 Apache License 2.0 Apache Software Foundation
+
+xml jaxen-1.1-beta-8.jar 1.1-beta-8 Codehaus Universal Java XPath Engine
+ jibx-run-1.1-beta3.jar 1.1-beta3
+ xbean-2.1.0.jar 2.1.0
+ xercesImpl-2.7.1.jar 2.7.1
+ xml-apis-1.3.02.jar 1.3.02
+ XmlSchema-1.0.2.jar 1.0.2 Apache License 2.0 Apache Software Foundation XmlSchema API
+
+xstream jmock-2004-03-19.jar 2004-03-19
+ joda-time-0.98.jar 0.98 Joda Software License 1.0 Joda.org Joda Time
+ stax-1.1.1-dev.jar 1.1.1-dev StAX is the reference implementation of the St...
+ stax-api-1.0.jar 1.0
+ wstx-asl-2.9.3.jar 2.9.3 woodstox.codehaus.org StAX 1.0 API
+ xml-writer-0.2.jar 0.2
+ xom-1.0b3.jar 1.0b3
+ xpp3-1.1.3.4d_b4_min.jar 1.1.3.4d_b4_min
+ xstream-1.1.jar 1.1
+
+
+
+Build Related Libraries
+
+Folder Library Version License Vendor Description
+
+catalina catalina.jar 4.0.2 JBoss Inc. JBoss
+
+httpunit httpunit.jar 1.6
+ js.jar
+ nekohtml.jar
+ Tidy.jar
+ xercesImpl.jar
+ xmlParserAPIs.jar
+
+junit junit.jar
+
+middlegen middlegen-2.1.jar 2.1
+ middlegen-hibernate-plugin-2.1.jar 2.1
+ velocity-1.4-dev.jar 1.4-dev
+
+strutstestcase strutstest-2.1.3.jar 2.1.3
+
+xdoclet maven-xdoclet-plugin-1.2.3.jar 1.2.3
+ xdoclet-1.2.3.jar 1.2.3
+ xdoclet-apache-module-1.2.3.jar 1.2.3
+ xdoclet-bea-module-1.2.3.jar 1.2.3
+ xdoclet-borland-module-1.2.3.jar 1.2.3
+ xdoclet-caucho-module-1.2.3.jar 1.2.3
+ xdoclet-de-locale-1.2.3.jar 1.2.3
+ xdoclet-ejb-module-1.2.3.jar 1.2.3
+ xdoclet-exolab-module-1.2.3.jar 1.2.3
+ xdoclet-fr_FR-locale-1.2.3.jar 1.2.3
+ xdoclet-hibernate-module-1.2.3.jar 1.2.3
+ xdoclet-hp-module-1.2.3.jar 1.2.3
+ xdoclet-ibm-module-1.2.3.jar 1.2.3
+ xdoclet-java-module-1.2.3.jar 1.2.3
+ xdoclet-jboss-module-1.2.3.jar 1.2.3
+ xdoclet-jdo-module-1.2.3.jar 1.2.3
+ xdoclet-jmx-module-1.2.3.jar 1.2.3
+ xdoclet-jsf-module-1.2.3.jar 1.2.3
+ xdoclet-libelis-module-1.2.3.jar 1.2.3
+ xdoclet-macromedia-module-1.2.3.jar 1.2.3
+ xdoclet-mockobjects-module-1.2.3.jar 1.2.3
+ xdoclet-mvcsoft-module-1.2.3.jar 1.2.3
+ xdoclet-mx4j-module-1.2.3.jar 1.2.3
+ xdoclet-objectweb-module-1.2.3.jar 1.2.3
+ xdoclet-openejb-module-1.2.3.jar 1.2.3
+ xdoclet-oracle-module-1.2.3.jar 1.2.3
+ xdoclet-orion-module-1.2.3.jar 1.2.3
+ xdoclet-portlet-module-1.2.3.jar 1.2.3
+ xdoclet-pramati-module-1.2.3.jar 1.2.3
+ xdoclet-pt_BR-locale-1.2.3.jar 1.2.3
+ xdoclet-solarmetric-module-1.2.3.jar 1.2.3
+ xdoclet-spring-module-1.2.3.jar 1.2.3
+ xdoclet-sun-module-1.2.3.jar 1.2.3
+ xdoclet-sybase-module-1.2.3.jar 1.2.3
+ xdoclet-tjdo-module-1.2.3.jar 1.2.3
+ xdoclet-web-module-1.2.3.jar 1.2.3
+ xdoclet-webwork-module-1.2.3.jar 1.2.3
+ xdoclet-wsee-module-1.2.3.jar 1.2.3
+ xdoclet-xdoclet-module-1.2.3.jar 1.2.3
+ xjavadoc-1.5-snapshot050611.jar 1.5-snapshot050611
+
Index: lams_build/src/org/lamsfoundation/lams/build/Jar.java
===================================================================
diff -u
--- lams_build/src/org/lamsfoundation/lams/build/Jar.java (revision 0)
+++ lams_build/src/org/lamsfoundation/lams/build/Jar.java (revision 62bb87b924ab3c6a68e521ba546488602d5f93f2)
@@ -0,0 +1,171 @@
+/****************************************************************
+ * Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.build;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+/**
+ *
+ * View Source
+ *
+ *
+ * @author Fei Yang
+ */
+public class Jar implements Comparable {
+
+ static final String[] VERSION_ATT_NAMES = {"Implementation-Version","HttpUnit-Version","Hibernate-Version"};
+ static final String[] VENDOR_ATT_NAMES = {"Implementation-Vendor"};
+ static final String[] LICENSE_FILE_NAMES = {"LICENSE","LICENSE.txt"};
+ static final String[] DESC_ATT_NAMES = {"Specification-Title"};
+ static final String[] LICENSES = {"Apache License","Apache Software License","Joda Software License","GPL","LGPL"};
+
+ String name;
+ String version;
+ String license;
+ String vendor;
+ String description;
+
+ public int compareTo(Object o) {
+ return name.compareTo(((Jar)o).name);
+ }
+
+ static Jar buildJar(File file) throws IOException{
+ Jar jar = new Jar();
+ jar.name = file.getName();
+ JarFile jarFile = new JarFile(file);
+ Manifest manifest = jarFile.getManifest();
+ Attributes mainAttributes = manifest.getMainAttributes();
+ for(String versionAtt : VERSION_ATT_NAMES){
+ jar.version = mainAttributes.getValue(versionAtt);
+ if(jar.version != null){
+ int index = jar.version.indexOf(' ');
+ if(index!=-1)
+ jar.version = jar.version.substring(0, index).trim();
+ break;
+ }
+ }
+ if(jar.version == null){//try parsing file name
+ int index1 = jar.name.lastIndexOf('-');
+ if(index1!=-1){
+ int index2 = jar.name.indexOf(".jar");
+ jar.version = jar.name.substring(index1+1, index2);
+ int index = index1;
+ while(jar.version.indexOf('.')==-1){
+ String s = jar.name.substring(0, index);
+ index = s.lastIndexOf('-');
+ if(index==-1)
+ break;
+ else{
+ jar.version = jar.name.substring(index+1,index2);
+ }
+ }
+ }
+ }
+ for(String vendorAtt:VENDOR_ATT_NAMES){
+ jar.vendor = mainAttributes.getValue(vendorAtt);
+ if(jar.vendor!=null)
+ break;
+ }
+ for(String descAtt:DESC_ATT_NAMES){
+ jar.description = mainAttributes.getValue(descAtt);
+ if(jar.description!=null)
+ break;
+ }
+ ZipEntry licenseZipEntry = null;
+ for(String licenseFilename:LICENSE_FILE_NAMES){
+ licenseZipEntry = jarFile.getEntry("META-INF/"+licenseFilename);
+ if(licenseZipEntry!=null)
+ break;
+ }
+ if(licenseZipEntry!=null){
+ BufferedInputStream is = new BufferedInputStream(jarFile.getInputStream(licenseZipEntry));
+ List bytes = new LinkedList();
+ byte b;
+ while((b=(byte)is.read())!=-1){
+ bytes.add(b);
+ }
+ byte[] bs = new byte[bytes.size()];
+ int i = 0;
+ for(Byte B : bytes){
+ bs[i] = B;
+ i++;
+ }
+ String licenseTxt = new String(bs);
+ //out.println(licenseTxt);
+ //out.println();
+ jar.license = parse(licenseTxt);
+ //out.println("License:"+jar.license);
+ //out.println();
+ is.close();
+ }
+ if(jar.version!=null) jar.version = cleanQuotes(jar.version);
+ if(jar.description!=null) jar.description = cleanQuotes(jar.description);
+ if(jar.vendor!=null) jar.vendor = cleanQuotes(jar.vendor);
+ return jar;
+ }
+
+ static String parse(String licenseTxt){
+ String licenseName = "";
+ int licenseIndex = -1;
+ for(String license:LICENSES){
+ licenseIndex = licenseTxt.indexOf(license);
+ if(licenseIndex!=-1){
+ licenseName = license;
+ break;
+ }
+ }
+ int versionIndex = licenseTxt.indexOf("Version");
+ String version = "";
+ if(versionIndex!=-1){
+ int i = licenseTxt.indexOf(' ', versionIndex);
+ int i1 = licenseTxt.indexOf(',', i+1);
+ int i2 = licenseTxt.indexOf(' ', i+1);
+ version = licenseTxt.substring(i, Math.min(i1, i2)).trim();
+ }
+ StringBuilder result = new StringBuilder();
+ if(licenseName.length()>0){
+ result.append(licenseName);
+ if(version.length()>0){
+ result.append(' ').append(version);
+ }
+ }
+ return result.toString();
+ }
+
+ static String cleanQuotes(String txt){
+ if(txt.indexOf('"')!=-1&&txt.indexOf('"')==0&&txt.lastIndexOf('"')==txt.length()-1){
+ txt = txt.substring(1, txt.length()-1);
+ }
+ return txt;
+ }
+
+}
Index: lams_build/src/org/lamsfoundation/lams/build/JarFolder.java
===================================================================
diff -u
--- lams_build/src/org/lamsfoundation/lams/build/JarFolder.java (revision 0)
+++ lams_build/src/org/lamsfoundation/lams/build/JarFolder.java (revision 62bb87b924ab3c6a68e521ba546488602d5f93f2)
@@ -0,0 +1,67 @@
+/****************************************************************
+ * Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.build;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ *
+ * View Source
+ *
+ *
+ * @author Fei Yang
+ */
+public class JarFolder implements Comparable {
+
+ String name;
+ List jars = new LinkedList();
+
+ void add(Jar jar){
+ jars.add(jar);
+ }
+ public int compareTo(Object o) {
+ return name.compareTo(((JarFolder)o).name);
+ }
+
+ static JarFolder buildJarFolder(File file) throws IOException{
+ JarFolder folder = new JarFolder();
+ folder.name = file.getName();
+ File[] jars = file.listFiles(
+ new FilenameFilter(){
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
+ }
+ }
+ );
+ for(File jar:jars){
+ folder.add(Jar.buildJar(jar));
+ }
+ return folder;
+ }
+
+}
Index: lams_build/src/org/lamsfoundation/lams/build/ThirdPartyLibraryListGenerator.java
===================================================================
diff -u
--- lams_build/src/org/lamsfoundation/lams/build/ThirdPartyLibraryListGenerator.java (revision 0)
+++ lams_build/src/org/lamsfoundation/lams/build/ThirdPartyLibraryListGenerator.java (revision 62bb87b924ab3c6a68e521ba546488602d5f93f2)
@@ -0,0 +1,278 @@
+/****************************************************************
+ * Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.build;
+
+import static java.lang.System.out;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ *
+ * This class is used to generate a list of the 3rd party libraries distributed
+ * with LAMS 2.x. The list is published on the LAMS wiki page: Common
+ * Java Libraries. The list generated will be persisted in the file
+ * liblist.txt. Whenever new libraries are added or old libraries are updated or
+ * deprecated libraries are removed, this program can be used to regenerate the
+ * list so that you can copy it and update the wiki page easily.
+ *
+ *
+ * View Source
+ *
+ *
+ * TODO add merge function
+ *
+ * @author Fei Yang
+ */
+public class ThirdPartyLibraryListGenerator {
+
+ static final String DEPLOYED_LIBS = "Deployed Libraries";
+
+ static final String BUILD_RELATED_LIBS = "Build Related Libraries";
+
+ static final String FOLDER = "Folder";
+
+ static final String LIBRARY = "Library";
+
+ static final String VERSION = "Version";
+
+ static final String LICENSE = "License";
+
+ static final String VENDOR = "Vendor";
+
+ static final String DESC = "Description";
+
+ static final String NEWLINE = "\n";
+
+ static final String BUILD_RELATED = "build_related";
+
+ static List buildRelated = new LinkedList();
+
+ static List deployedJarFolders = new LinkedList();
+
+ static List buildRelatedJarFolders = new LinkedList();
+
+ static List existingDeployedJarFolders = new LinkedList();
+
+ static List existingBuildRelatedJarFolders = new LinkedList();
+
+ static final int FLD = 0;
+
+ static final int LIB = 1;
+
+ static final int VER = 2;
+
+ static final int LIC = 3;
+
+ static final int VDR = 4;
+
+ static Properties loadProperties(String propertyFileName) {
+ try {
+ InputStream propFile = new FileInputStream(propertyFileName);
+ Properties props = new Properties();
+ props.load(propFile);
+ return props;
+ } catch (FileNotFoundException e) {
+ String errorMsg = "File:" + propertyFileName + " was not found";
+ throw new RuntimeException(errorMsg, e);
+ } catch (IOException e) {
+ String errorMsg = "IO error occured during loading file "
+ + propertyFileName;
+ throw new RuntimeException(errorMsg, e);
+ }
+ }
+
+ static void config() {
+ Properties props = loadProperties("liblist.conf");
+ String[] brs = props.getProperty(BUILD_RELATED).split(",");
+ for (String br : brs) {
+ buildRelated.add(br);
+ }
+ }
+
+ // TODO Finish me
+ static void init() throws IOException {
+ File file = new File("liblist.txt");
+ if (file.exists()) {
+ final Integer NOT_STARTED = 0;
+ final Integer DEPLOYED_STARTING = 1;
+ final Integer DEPLOYED_STARTED = 2;
+ final Integer BUILD_STARTING = 3;
+ final Integer BUILD_STARTED = 4;
+ BufferedReader br = new BufferedReader(new FileReader(file));
+ String line;
+ Integer status = NOT_STARTED;
+ while ((line = br.readLine()) != null) {
+ if (line.startsWith(DEPLOYED_LIBS)) {
+ continue;
+ }
+ if (line.startsWith(FOLDER)) {
+
+ }
+ }
+ }
+ }
+
+ static void scan() throws IOException {
+ File lib = new File("lib");
+ File[] folders = lib.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return !name.equals("CVS")
+ && !name.equals("lams")
+ && new File("lib" + File.separatorChar + name)
+ .isDirectory();
+ }
+ });
+ for (File folder : folders) {
+ if (buildRelated.contains(folder.getName())) {
+ buildRelatedJarFolders.add(JarFolder.buildJarFolder(folder));
+ } else {
+ deployedJarFolders.add(JarFolder.buildJarFolder(folder));
+ }
+ }
+ }
+
+ static void output() throws IOException {
+ StringBuilder sb = new StringBuilder();
+ int[] width = getWidthOfColumns(deployedJarFolders);
+ outputHeader(sb, width, DEPLOYED_LIBS);
+ for (JarFolder folder : deployedJarFolders) {
+ outputJarFolder(sb, width, folder);
+ }
+ sb.append(NEWLINE).append(NEWLINE);
+ width = getWidthOfColumns(buildRelatedJarFolders);
+ outputHeader(sb, width, BUILD_RELATED_LIBS);
+ for (JarFolder folder : buildRelatedJarFolders) {
+ outputJarFolder(sb, width, folder);
+ }
+ writeFile(sb.toString());
+ }
+
+ static void writeFile(String content) throws IOException {
+ BufferedWriter writer = new BufferedWriter(
+ new FileWriter("liblist.txt"));
+ writer.write(content);
+ writer.close();
+ }
+
+ private static void outputJarFolder(StringBuilder sb, int[] width,
+ JarFolder folder) {
+ append(sb, folder.name, width[FLD]);
+ if (folder.jars.size() > 0) {
+ Jar jar = folder.jars.get(0);
+ append(sb, jar.name, width[LIB]);
+ append(sb, jar.version, width[VER]);
+ append(sb, jar.license, width[LIC]);
+ append(sb, jar.vendor, width[VDR]);
+ append(sb, jar.description, 0);
+ sb.append(NEWLINE);
+ for (int i = 1; i < folder.jars.size(); i++) {
+ jar = folder.jars.get(i);
+ append(sb, "", width[FLD]);
+ append(sb, jar.name, width[LIB]);
+ append(sb, jar.version, width[VER]);
+ append(sb, jar.license, width[LIC]);
+ append(sb, jar.vendor, width[VDR]);
+ append(sb, jar.description, 0);
+ sb.append(NEWLINE);
+ }
+ } else {
+ sb.append(NEWLINE);
+ }
+ sb.append(NEWLINE);
+ }
+
+ static void outputHeader(StringBuilder sb, int[] width, String header) {
+ sb.append(header).append(NEWLINE).append(NEWLINE);
+ append(sb, FOLDER, width[FLD]);
+ append(sb, LIBRARY, width[LIB]);
+ append(sb, VERSION, width[VER]);
+ append(sb, LICENSE, width[LIC]);
+ append(sb, VENDOR, width[VDR]);
+ append(sb, DESC, 0);
+ sb.append(NEWLINE);
+ sb.append(NEWLINE);
+ }
+
+ static void append(StringBuilder sb, String s, int width) {
+ if(s==null) s="";
+ sb.append(s);
+ for (int i = 0; i < width - s.length(); i++) {
+ sb.append(' ');
+ }
+ }
+
+ static int[] getWidthOfColumns(List jarFolders) {
+ int[] width = new int[] { FOLDER.length(), LIBRARY.length(),
+ VERSION.length(), LICENSE.length(), VENDOR.length() };
+ for (JarFolder folder : jarFolders) {
+ if (folder.name.length() > width[FLD]) {
+ width[FLD] = folder.name.length();
+ }
+ for (Jar jar : folder.jars) {
+ if (jar.name.length() > width[LIB]) {
+ width[LIB] = jar.name.length();
+ }
+ if (jar.version!=null && jar.version.length() > width[VER]) {
+ width[VER] = jar.version.length();
+ }
+ if (jar.license!=null && jar.license.length() > width[LIC]) {
+ width[LIC] = jar.license.length();
+ }
+ if (jar.vendor!=null && jar.vendor.length() > width[VDR]) {
+ width[VDR] = jar.vendor.length();
+ }
+ }
+ }
+ for (int i = 0; i < 5; i++) {
+ width[i] += 3;// extra 3 spaces between columns
+ }
+ return width;
+ }
+
+ /**
+ * @param args
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+ config();
+ //init();
+ scan();
+ output();
+ out.println("Done!");
+ }
+
+}