aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Bush <ali_bush@gentoo.org>2008-07-05 14:02:45 +0000
committerAlistair Bush <ali_bush@gentoo.org>2008-07-05 14:02:45 +0000
commit5e3259cc6b226ede83149b19934f047a436727f8 (patch)
tree92fe42fe938a8f1cf109ddbecfd0eb8d1b5f972c
parentAdd MANIFEST files and updated Changelog (diff)
downloadjavatoolkit-5e3259cc6b226ede83149b19934f047a436727f8.tar.gz
javatoolkit-5e3259cc6b226ede83149b19934f047a436727f8.tar.bz2
javatoolkit-5e3259cc6b226ede83149b19934f047a436727f8.zip
Adding preliminarily, ruff, sucky and generally unfinished first draft of eclipse-build.py and supporting library.
svn path=/projects/javatoolkit/trunk/; revision=6401
-rw-r--r--setup.py5
-rwxr-xr-xsrc/py/eclipse-build.py106
-rw-r--r--src/py/javatoolkit/java/__init__.py10
-rw-r--r--src/py/javatoolkit/java/properties.py62
-rwxr-xr-xsrc/py/xml-rewrite-3.py24
5 files changed, 181 insertions, 26 deletions
diff --git a/setup.py b/setup.py
index e10c3d5..3952407 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,7 @@ setup (
maintainer = 'Gentoo Java Team',
maintainer_email = 'java@gentoo.org',
url = 'html://www.gentoo.org',
- packages = ["javatoolkit", "javatoolkit.maven", "javatoolkit.xml", "javatoolkit.parser"],
+ packages = ["javatoolkit", "javatoolkit.maven", "javatoolkit.xml", "javatoolkit.parser", "javatoolkit.java"],
package_dir = { 'javatoolkit' : 'src/py/javatoolkit' },
scripts = [
"src/py/maven-helper.py",
@@ -24,7 +24,8 @@ setup (
"src/py/buildparser",
"src/py/class-version-verify.py",
"src/py/build-xml-rewrite",
- "src/py/jarjarclean"
+ "src/py/jarjarclean",
+ "src/py/eclipse-build.py"
],
data_files = [ ( '/usr/share/man/man1', ['src/man/findclass.1'] ) ]
)
diff --git a/src/py/eclipse-build.py b/src/py/eclipse-build.py
new file mode 100755
index 0000000..b660f95
--- /dev/null
+++ b/src/py/eclipse-build.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# Copyright 2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public Licence v2
+
+# Authors
+# Alistair Bush <ali_bush@gentoo.org>
+
+from __future__ import with_statement
+import os
+import sys
+from optparse import OptionParser, make_option
+from xml.dom.minidom import parse
+from javatoolkit.java.properties import PropertiesParser
+
+
+__version__ = "$Revision: 1 $"[11:-2]
+
+if __name__ == '__main__':
+ usage = "Eclipse Ant Build File writer " + __version__ + "\n"
+ usage += "Copyright 2008 Gentoo Foundation\n"
+ usage += "Distributed under the terms of the GNU General Public Licence\n"
+ usage += "Please contact the Gentoo Java Team <java@gentoo.org> with problems.\n"
+ usage += "\nJust wait till I finish this."
+
+
+ option_list = [
+ make_option ( '-p', '--project', action='store', dest='project', help='Project Name' ),
+ make_option ( '-i', '--include', action='append', dest='includes', help='Files to include in jar' ),
+ make_option ( '-s', '--src', action='append', dest='source', help='Directories containing src to build' ),
+ make_option ( '-m', '--manifest', action='store', dest='manifest', help='Manifest File' ),
+ make_option ( '-f', '--file', action='store', dest='file', help='Eclipse build.properties file to parse.' ),
+ make_option ( '-o', '--output', action='store', dest='output', help='Output build.xml to this file' )
+ ]
+
+ parser = OptionParser( usage, option_list )
+ (options, args) = parser.parse_args()
+ #check parser options here.
+
+ if options.file:
+ properties = PropertiesParser( options.file )
+ #dom = parse( options.file )
+ #classpathentries = dom.getElementsByTagName('classpathentry')
+
+ #for entry in classpathentries:
+ # if entry.attributes['kind'] and entry.attributes['kind'].nodeValue == 'src':
+ # print entry.attributes['path'].nodeValue
+ # if entry.attributes['path']:
+ # src_dirs.append( entry.attributes['path'].nodeValue )
+
+ with open( options.output, 'w' ) as output:
+ output.write('<?xml version="1.0" encoding="UTF-8" ?>\n')
+ output.write('<project basedir="." default="jar" name="'+options.project+'">\n')
+ output.write('<property name="target" value="1.4"/>\n')
+ output.write('<property name="source" value="1.4"/>\n')
+ output.write('<property name="gentoo.classpath" value="" />\n\n')
+ output.write('<target name="init">\n')
+ output.write('<mkdir dir="bin"/>\n')
+ output.write('<copy includeemptydirs="false" todir="bin">\n')
+ try:
+ if properties.config['source..']:
+ for dir in properties.config['source..']:
+ output.write('<fileset dir="'+dir+'" excludes="**/*.java, **/*.launch" />\n')
+ if properties.config['bin.includes']:
+ for item in properties.config['bin.includes']:
+ if item != '.':
+ if item.endswith('/'):
+ item = item.rstrip('/')
+ output.write('<fileset dir="." includes="'+item+'/**" excludes="**/*.java, **/*.launch" />\n')
+ else:
+ output.write('<fileset file="'+item+'" />\n')
+ finally:
+ output.write('</copy>\n')
+ if options.includes:
+ for file in options.includes:
+ output.write('<copy file="'+file+'" todir="bin"/>')
+ output.write('</target>\n')
+ output.write('\n<target name="clean">\n\t<delete dir="bin"/>\n</target>\n\n')
+ output.write('<target depends="init" name="compile">\n')
+ output.write('<javac destdir="bin" source="${source}" target="${target}" classpath="${gentoo.classpath}">\n')
+ try:
+ if properties.config['source..']:
+ for dir in properties.config['source..']:
+ output.write('\t<src path="'+dir+'" />\n')
+ finally:
+ output.write('</javac>\n')
+ output.write('</target>\n\n')
+ output.write('<target depends="compile" name="jar" >\n')
+ output.write('<jar file="${ant.project.name}.jar" basedir="bin"')
+ if options.manifest:
+ output.write('\nmanifest="'+parser.manifest+'">\n')
+ else:
+ output.write('>\n')
+ output.write('</jar>\n')
+ output.write('</target>\n')
+ output.write('</project>\n')
+ #output.write('')
+ #output.write('')
+ #output.write('')
+ #output.write('')
+ #output.write('')
+ #output.write('')
+ #output.write('')
+
+# vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap :
diff --git a/src/py/javatoolkit/java/__init__.py b/src/py/javatoolkit/java/__init__.py
new file mode 100644
index 0000000..20432bd
--- /dev/null
+++ b/src/py/javatoolkit/java/__init__.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+#
+# Copyright(c) 2008, Gentoo Foundation
+#
+# Licensed under the GNU General Public License, v2
+#
+# $Header: $
+
+if __name__ == "__main__":
+ print "This is not an executable module"
diff --git a/src/py/javatoolkit/java/properties.py b/src/py/javatoolkit/java/properties.py
new file mode 100644
index 0000000..adf7a79
--- /dev/null
+++ b/src/py/javatoolkit/java/properties.py
@@ -0,0 +1,62 @@
+# Copyright 2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+import os
+
+class PropertiesParser:
+ """
+ Parse eclipse projects build.properties file.
+ """
+
+ def __init__( self, file ):
+ self.file = file
+ self.config = {}
+ self.parse( file )
+
+ def parse( self, file ):
+ if not os.path.isfile(file):
+ return
+ if not os.access(file, os.R_OK):
+ return
+
+ stream = open( file, 'r' )
+ line = stream.readline()
+ while line != '':
+ line = line.strip('\n')
+ line = line.strip()
+ #print 'line="'+line+'"'
+ if line.isspace() or line == '' or line.startswith('#'):
+ line = stream.readline()
+ continue
+
+ index = line.find('=')
+ name = line[:index]
+ name = name.strip()
+ value = line[index+1:]
+
+ #print 'name="'+name+'"; value="'+value+'"'
+
+ while line.endswith('\\'):
+ #stream.next()
+ line = stream.readline()
+ line = line.strip('\n')
+ line = line.strip()
+ #print 'line="'+line+'"'
+ if line.isspace() or line == '' or line.startswith('#'):
+ line = stream.readline()
+ break
+ value +=line
+
+ value = value.strip('\\')
+
+ if value == '':
+ line = stream.readline()
+ continue
+ value = value.strip('\\\'\"').strip('\\').strip()
+ value = value.replace('\\', '')
+ self.config[name] = value.split(',')
+ line = stream.readline()
+
+
+# vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap :
diff --git a/src/py/xml-rewrite-3.py b/src/py/xml-rewrite-3.py
index 3e95163..096db76 100755
--- a/src/py/xml-rewrite-3.py
+++ b/src/py/xml-rewrite-3.py
@@ -32,30 +32,6 @@ from javatoolkit.xml.SaxRewriter import SaxRewriter
__version__ = "$Revision: 1.7 $"[11:-2]
-#TODO Refactor into javatoolkit.xml if ever used!
-#class ExpatRewriter(StreamRewriterBase):
-# """
-# The only problem with this Expat based implementation is that it does not
-# handle entities doctypes etc properly so for example dev-java/skinlf fails.
-# """
-# def process(self, in_stream):
-# from xml.parsers.expat import ParserCreate
-# parser = ParserCreate()
-#
-# parser.StartElementHandler = self.start_element
-# parser.EndElementHandler = self.end_element
-# parser.CharacterDataHandler = self.char_data
-# parser.ParseFile(in_stream)
-# self.p(u'\n')
-#
-#
-# def start_element(self, name, attrs):
-# StreamRewriterBase(self, name, attrs.iteritems())
-#
-#
-# def end_element(self,name):
-# self.p(u'</%s>' % name)
-
if __name__ == '__main__':
usage = "XML Rewrite Python Module Version " + __version__ + "\n"
usage += "Copyright 2004,2006,2007 Gentoo Foundation\n"