java_gen: reorganized / optimized mvn+eclipse class structure
diff --git a/.gitignore b/.gitignore
index 8206747..9712e8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@
.*.swp
.*.swo
*.cache
+openflowj-loxi
diff --git a/Makefile b/Makefile
index 57fdec5..6f0fbaa 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,7 @@
\! \( -name '*.cache' -o -name '.*' \))
INPUT_FILES = $(wildcard openflow_input/*)
TEST_DATA = $(shell find test_data -name '*.data')
+OPENFLOWJ_WORKSPACE = openflowj-loxi
all: c python
@@ -68,14 +69,19 @@
@echo "HTML documentation output to ${LOXI_OUTPUT_DIR}/pyloxi-doc"
java: .loxi_ts.java
+ mkdir -p ${OPENFLOWJ_WORKSPACE}
+ ln -sf ../java_gen/pre-written/pom.xml ${OPENFLOWJ_WORKSPACE}/pom.xml
+ ln -sf ../java_gen/pre-written/src ${OPENFLOWJ_WORKSPACE}/src
+ rsync --checksum --delete -rv ${LOXI_OUTPUT_DIR}/openflowj/src/ ${OPENFLOWJ_WORKSPACE}/gen-src
.loxi_ts.java: ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES} ${TEST_DATA}
./loxigen.py --install-dir=${LOXI_OUTPUT_DIR} --lang=java
touch $@
java-eclipse: java
- mkdir -p java-eclipse
- rsync --checksum --delete -rv loxi_output/openflowj/ java_eclipse/
+ cd ${OPENFLOWJ_WORKSPACE} && mvn eclipse:eclipse
+ # Unfortunately, mvn eclipse:eclipse resolves the symlink, which doesn't work with eclipse
+ cd ${OPENFLOWJ_WORKSPACE} && perl -pi -e 's{<classpathentry kind="src" path="[^"]*/java_gen/pre-written/src/}{<classpathentry kind="src" path="src/}' .classpath
clean:
rm -rf loxi_output # only delete generated files in the default directory
@@ -108,13 +114,17 @@
${LOXI_OUTPUT_DIR}/locitest/locitest
check-java: java
- cd ${LOXI_OUTPUT_DIR}/openflowj/ && mvn compile test-compile test
+ cd ${OPENFLOWJ_WORKSPACE} && mvn compile test-compile test
package-java: java
- cd ${LOXI_OUTPUT_DIR}/openflowj/ && mvn package
+ cd ${OPENFLOWJ_WORKSPACE} && mvn package
deploy-java: java
- cd ${LOXI_OUTPUT_DIR}/openflowj/ && mvn deploy
+ cd ${OPENFLOWJ_WORKSPACE} && mvn deploy
+
+install-java: java
+ cd ${OPENFLOWJ_WORKSPACE} && mvn install
+
pylint:
pylint -E ${LOXI_PY_FILES}
diff --git a/java_gen/codegen.py b/java_gen/codegen.py
index 8606682..1b9f445 100644
--- a/java_gen/codegen.py
+++ b/java_gen/codegen.py
@@ -57,8 +57,6 @@
gen.create_of_const_enums()
gen.create_of_factories()
- with open('%s/README.java-lang' % os.path.dirname(__file__)) as readme_src:
- out.writelines(readme_src.readlines())
out.close()
@@ -157,6 +155,3 @@
""" 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 - pom.xml | ( cd ../../%s && tar xvpf - )" % basedir,
- # shell=True)
- os.symlink(os.path.abspath("%s/pre-written/pom.xml" % os.path.dirname(__file__)), "%s/pom.xml" % basedir)
diff --git a/java_gen/pre-written/.classpath b/java_gen/pre-written/.classpath
deleted file mode 100644
index b6bc6ad..0000000
--- a/java_gen/pre-written/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="lib" path="lib/netty-3.2.6.Final.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/java_gen/pre-written/.project b/java_gen/pre-written/.project
deleted file mode 100644
index b347bd6..0000000
--- a/java_gen/pre-written/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>openflowj-loxi</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/java_gen/pre-written/pom.xml b/java_gen/pre-written/pom.xml
index e893b87..2461cfe 100644
--- a/java_gen/pre-written/pom.xml
+++ b/java_gen/pre-written/pom.xml
@@ -40,16 +40,65 @@
<version>1.8</version>
<executions>
<execution>
+ <id>gen-src-add-source</id>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
- <source>../../java_gen/pre-written/src/main/java/</source>
+ <source>gen-src/main/java</source>
+ </sources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>add-gen-src-test-source</id>
+ <!-- note: purposefully not using phase generate-test-sources,
+ because that is not picked up by eclipse:eclipse -->
+ <phase>validate</phase>
+ <goals><goal>add-test-source</goal></goals>
+ <configuration>
+ <sources>
+ <source>gen-src/test/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
+ <!-- attach sources -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- attach javadoc -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.9.1</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <downloadJavadocs>true</downloadJavadocs>
+ </configuration>
+ </plugin>
</plugins>
</build>
<distributionManagement>