java_gen: change to maven build, remove lib directory
diff --git a/java_gen/codegen.py b/java_gen/codegen.py
index a208c0d..3253eaf 100644
--- a/java_gen/codegen.py
+++ b/java_gen/codegen.py
@@ -42,10 +42,7 @@
 import java_gen.java_model as java_model
 
 def gen_all_java(out, name):
-    target_dir='loxi_output/openflowj'
-    basedir="%s/%s/" % (
-            target_dir,
-            lang_java.file_to_subdir_map['base_java'])
+    basedir='loxi_output/openflowj'
     srcdir = "%s/src/main/java/" % basedir
     print "Outputting to %s" % basedir
     if os.path.exists(basedir):
@@ -137,5 +134,6 @@
     """ Recursively copy the directory structure from ./java_gen/pre-write
        into $basedir"""
     print "Copying pre-written files into %s" % basedir
-#    subprocess.call("cd java_gen/pre-written && tar cpf - . | ( cd ../../%s && tar xvpf - )" % basedir,
-#            shell=True)
+    #subprocess.call("cd java_gen/pre-written && tar cpf - pom.xml | ( cd ../../%s && tar xvpf - )" % basedir,
+    #        shell=True)
+    os.symlink(os.path.abspath("java_gen/pre-written/pom.xml"), "%s/pom.xml" % basedir)
diff --git a/java_gen/pre-written/build.xml b/java_gen/pre-written/build.xml
deleted file mode 100644
index f66d8bc..0000000
--- a/java_gen/pre-written/build.xml
+++ /dev/null
@@ -1,264 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-
- <!--
-   Copyright 2011, Big Switch Networks, Inc.
-
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-
-<!--
-    The build uses pregenerated Thrift code by default to reduce build
-    dependencies. To generate it locally run the gen-thrift target.
-    If you change the Thrift files be sure to also commit the updated
-    generated code.
--->
-
-<project default="dist" name="Floodlight">
-    <property name="target" location="target"/>
-    <property name="build" location="${target}/bin"/>
-    <property name="build-test" location="${target}/bin-test"/>
-    <property name="build-coverage" location="${target}/bin-coverage"/>
-    <property name="test-output" location="${target}/test"/>
-    <property name="coverage-output" location="${target}/coverage"/>
-    <property name="source" location="src/main/java"/>
-    <property name="resources" location="src/main/resources/"/>
-    <property name="source-test" location="src/test/java"/>
-    <property name="python-src" location="src/main/python"/>
-    <property name="docs" location="${target}/docs"/>
-    <property name="main-class" value="net.floodlightcontroller.core.Main"/>
-    <property name="floodlight-jar" location="${target}/floodlight.jar"/>
-    <property name="floodlight-test-jar" location="${target}/floodlight-test.jar"/>
-    <property name="thrift.dir" value="${basedir}/src/main/thrift"/>
-    <property name="thrift.out.dir" value="lib/gen-java"/>
-    <property name="thrift.package" value="net/floodlightcontroller/packetstreamer/thrift"/>
-    <property name="ant.build.javac.source" value="1.6"/>
-    <property name="ant.build.javac.target" value="1.6"/>
-    <property name="lib" location="lib"/>
-
-    <patternset id="lib">
-        <include name="netty-3.2.6.Final.jar"/>
-    </patternset>
-
-    <path id="classpath">
-        <fileset dir="${lib}">
-            <patternset refid="lib"/>
-        </fileset>
-    </path>
-
-    <patternset id="lib-cobertura">
-        <include name="cobertura-1.9.4.1.jar"/>
-        <include name="asm-3.0.jar"/>
-        <include name="asm-tree-3.0.jar"/>
-        <include name="oro/jakarta-oro-2.0.8.jar"/>
-        <include name="log4j-1.2.9.jar"/>
-    </patternset>
-    <path id="classpath-cobertura">
-        <fileset dir="${lib}">
-            <patternset refid="lib-cobertura"/>
-    </fileset>
-    </path>
-
-    <patternset id="lib-test">
-        <include name="junit-4.8.2.jar"/>
-        <include name="org.easymock-3.1.jar"/>
-        <include name="objenesis-1.2.jar"/>  <!-- required by easymock to mock classes -->
-        <include name="cglib-nodep-2.2.2.jar"/>    <!-- required by easymock to mock classes -->
-    </patternset>
-    <path id="classpath-test">
-        <fileset dir="${lib}">
-            <patternset refid="lib-test"/>
-            <patternset refid="lib-cobertura"/>
-            <patternset refid="lib"/>
-        </fileset>
-    </path>
-
-    <target name="init">
-        <mkdir dir="${build}"/>
-        <mkdir dir="${build-test}"/>
-        <mkdir dir="${target}/lib"/>
-        <mkdir dir="${thrift.out.dir}"/>
-        <mkdir dir="${test-output}"/>
-    </target>
-
-    <target name="compile" depends="init">
-        <javac includeAntRuntime="false"
-           classpathref="classpath"
-           debug="true"
-           srcdir="${source}:${thrift.out.dir}"
-           destdir="${build}">
-        </javac>
-    </target>
-
-    <target name="compile-tests" depends="compile-test"/>
-    <target name="compile-test" depends="compile">
-        <fileset dir="${resources}"/>
-        <javac includeAntRuntime="false" debug="true"
-           srcdir="${source-test}"
-           classpath="${build}"
-           classpathref="classpath-test"
-           destdir="${build-test}"/>
-    </target>
-
-    <!-- Thrift build based on http://www.flester.com/blog/2009/04/26/using-thrift-from-ant -->
-    <fileset id="thrift.files" dir="${thrift.dir}">
-        <include name="**/*.thrift"/>
-    </fileset>
-
-    <target name="gen-thrift" depends="init">
-        <pathconvert property="thrift.file.list" refid="thrift.files"
-            pathsep=" " dirsep="/">
-        </pathconvert>
-        <echo message="Running thrift generator on ${thrift.file.list}"/>
-        <exec executable="thrift" dir="${basedir}" failonerror="true">
-            <arg line="--strict -v --gen java -o ${thrift.out.dir}/.. ${thrift.file.list}"/>
-        </exec>
-        <!-- Get rid of annoying warnings in thrift java: at annotations -->
-        <echo message="Adding @SuppressWarning annotations"/>
-        <replaceregexp byline="true">
-            <regexp pattern="^public "/>
-            <substitution expression='@SuppressWarnings("all") public '/>
-            <fileset id="thrift.output.files" dir="${thrift.out.dir}/..">
-                <include name="**/*.java"/>
-            </fileset>
-        </replaceregexp>
-    </target>
-
-    <target name="clean">
-        <delete dir="${target}"/>
-    </target>
-
-    <target name="run" depends="dist">
-        <java fork="true" jar="${floodlight-jar}" classpathref="classpath">
-            <jvmarg value="-server"/>
-            <jvmarg value="-Xms1024M"/>
-            <jvmarg value="-Xmx1024M"/>
-        </java>
-    </target>
-
-    <target name="tests" depends="test"/>
-    <target name="test" depends="compile-test">
-        <junit fork="true" forkmode="once"
-           failureproperty="junit.failure"
-           printsummary="on">
-        <sysproperty key="net.sourceforge.cobertura.datafile"
-             file="${target}/cobertura.ser" />
-            <classpath>
-                <pathelement location="${build-coverage}"/>
-                <pathelement location="${build}"/>
-                <pathelement location="${build-test}"/>
-                <pathelement location="${floodlight-jar}"/>
-                <path refid="classpath-test"/>
-            </classpath>
-            <formatter type="brief" usefile="true" />
-            <batchtest todir="${test-output}">
-                <fileset dir="${source-test}">
-                    <exclude name="**/storage/tests/StorageTest.java"/>
-                    <exclude name="**/test/Mock*"/>
-                    <exclude name="**/core/test/**"/>
-                    <exclude name="**/core/module/**"/>
-                </fileset>
-            </batchtest>
-        </junit>
-        <fail if="junit.failure" message="Unit test(s) failed.  See reports!"/>
-    </target>
-
-    <taskdef classpathref="classpath-cobertura" resource="tasks.properties"/>
-    <target name="clean-instrument">
-        <delete file="${target}/cobertura.ser"/>
-        <delete dir="${build-coverage}"/>
-    </target>
-    <target name="instrument" depends="compile,compile-test,clean-instrument">
-      <cobertura-instrument datafile="${target}/cobertura.ser"
-                todir="${build-coverage}"
-                classpathref="classpath-cobertura">
-    <fileset dir="${build}">
-      <include name="**/*.class"/>
-    </fileset>
-      </cobertura-instrument>
-    </target>
-    <target name="coverage-report">
-        <cobertura-report format="html"
-              datafile="${target}/cobertura.ser"
-              destdir="${coverage-output}"
-              srcdir="${source}"/>
-        <cobertura-report format="xml"
-              datafile="${target}/cobertura.ser"
-              destdir="${coverage-output}"
-              srcdir="${source}"/>
-    </target>
-    <target name="coverage" depends="instrument,test,coverage-report"/>
-
-    <target name="dist" depends="compile,compile-test">
-        <jar destfile="${floodlight-jar}" filesetmanifest="mergewithoutmain">
-            <manifest>
-                <attribute name="Main-Class" value="${main-class}"/>
-                <attribute name="Class-Path" value="."/>
-            </manifest>
-            <fileset dir="${build}"/>
-            <fileset dir="${resources}"/>
-            <fileset dir="${python-src}">
-                <include name="**/*.py"/>
-            </fileset>
-            <zipgroupfileset dir="${lib}">
-                <patternset refid="lib"/>
-            </zipgroupfileset>
-        </jar>
-        <jar destfile="${floodlight-test-jar}" filesetmanifest="mergewithoutmain">
-            <manifest>
-                <attribute name="Class-Path" value="."/>
-            </manifest>
-            <fileset dir="${build-test}"/>
-            <fileset dir="${resources}"/>
-            <zipgroupfileset dir="${lib}">
-                <patternset refid="lib-test"/>
-                <patternset refid="lib-cobertura"/>
-            </zipgroupfileset>
-        </jar>
-    </target>
-
-    <target name="javadoc">
-        <javadoc access="protected"
-            author="true"
-            classpathref="classpath"
-            destdir="${docs}"
-            doctitle="Floodlight"
-            nodeprecated="false"
-            nodeprecatedlist="false"
-            noindex="false"
-            nonavbar="false"
-            notree="false"
-            source="1.6"
-            sourcepath="${source}"
-            splitindex="true"
-            use="true"
-            version="true"/>
-    </target>
-
-    <target name="eclipse" depends="init">
-        <pathconvert property="eclipse-lib">
-            <map from="${basedir}/" to=""/>
-            <fileset dir="${lib}">
-                <patternset refid="lib"/>
-                <patternset refid="lib-test"/>
-            </fileset>
-        </pathconvert>
-        <exec executable="${basedir}/setup-eclipse.sh">
-            <arg value="${main-class}"/>
-            <arg value="${eclipse-lib}"/>
-        </exec>
-    </target>
-
-</project>
diff --git a/java_gen/pre-written/lib/.gitignore b/java_gen/pre-written/lib/.gitignore
deleted file mode 100644
index b4cb1f8..0000000
--- a/java_gen/pre-written/lib/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-netty-3.2.6.Final.jar
diff --git a/java_gen/pre-written/pom.xml b/java_gen/pre-written/pom.xml
new file mode 100644
index 0000000..d01d797
--- /dev/null
+++ b/java_gen/pre-written/pom.xml
@@ -0,0 +1,55 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.openflow</groupId>
+    <artifactId>openflowj</artifactId>
+    <version>2.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>Loxi-Generated OpenFlow/J</name>
+    <url>http://www.projectfloodlight.org/projects/</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.netty</groupId>
+            <artifactId>netty</artifactId>
+            <version>3.2.9.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>14.0.1</version>
+        </dependency>
+    </dependencies>
+    <build>
+    <plugins>
+    <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>1.8</version>
+        <executions>
+            <execution>
+                <phase>generate-sources</phase>
+                <goals><goal>add-source</goal></goals>
+                <configuration>
+                    <sources>
+                        <source>../../java_gen/pre-written/src/main/java/</source>
+                    </sources>
+                </configuration>
+            </execution>
+        </executions>
+    </plugin>
+</plugins>
+</build>
+</project>
diff --git a/lang_java.py b/lang_java.py
index ab711f7..a380fab 100644
--- a/lang_java.py
+++ b/lang_java.py
@@ -68,9 +68,3 @@
 file_gen_map = dict(
     base_java=java_codegen.gen_all_java,
 )
-
-
-# Map from file references to target sub-directories
-file_to_subdir_map = dict(
-    base_java="openflowj/",
-)