Skip to content

Commit

Permalink
Use ant to build the complete jar file for the Java wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhdev committed Jun 10, 2012
1 parent 617b9b7 commit 11985ab
Show file tree
Hide file tree
Showing 13 changed files with 867 additions and 41 deletions.
52 changes: 52 additions & 0 deletions jython/build.xml
@@ -0,0 +1,52 @@
<?xml version="1.0" ?>

<project name="EditorConfigJava" default="all" basedir=".">

<property name="tmp.dir" value="${user.dir}/tmp" />
<property name="editorconfig.py.dir" value="${user.dir}/.." />
<property name="build.dir" value="${user.dir}/build" />

<!-- Build EditorConfig Java wrapper -->
<target name="build-java-wrapper">
<mkdir dir="./classes" />
<javac srcdir="./src" destdir="./classes" />
</target>

<!-- Download jython installer -->
<property name="jython.url" value="http://downloads.sourceforge.net/project/jython/jython/2.2.1/jython_installer-2.2.1.jar?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fjython%2Ffiles%2Fjython%2F2.2.1%2F&amp;ts=1338203268" />
<target name="download-jython">
<mkdir dir="${tmp.dir}" />
<get src="${jython.url}" dest="${tmp.dir}/jython_installer.jar" usetimestamp="true" verbose="true" />
</target>

<!-- Build the Jython engine -->
<target name="build-jython-engine">
<ant dir="./jython-engine/make" inheritall="false" />
</target>

<!-- pack jython EditorConfig -->
<target name="pack-jython-editorconfig" depends="build-java-wrapper,download-jython,build-jython-engine">
<java jar="${tmp.dir}/jython_installer.jar" fork="true">
<arg value="-s" />
<arg value="-v" />
<arg value="-d" />
<arg value="${tmp.dir}/install" />
<arg value="-t" />
<arg value="standalone" />
</java>
<move file="${tmp.dir}/install/jython.jar" todir="${tmp.dir}" />
<symlink link="${tmp.dir}/Lib" resource="${editorconfig.py.dir}" overwrite="true" />
<mkdir dir="${build.dir}" />
<jar destfile="${build.dir}/editorconfig.jar">
<fileset dir="./classes" />
<zipfileset src="${tmp.dir}/jython.jar" />
<zipfileset src="./jython-engine/build/jython-engine.jar" />
<fileset dir="${tmp.dir}">
<include name="Lib/editorconfig/**.py" />
</fileset>
</jar>
</target>

<target name="all" depends="pack-jython-editorconfig">
</target>
</project>
32 changes: 32 additions & 0 deletions jython/jython-engine/LICENSE.TXT
@@ -0,0 +1,32 @@
Copyright (c) 2006, Sun Microsystems, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

- Neither the name of the Sun Microsystems, Inc. nor the names of
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
3 changes: 3 additions & 0 deletions jython/jython-engine/README.TXT
@@ -0,0 +1,3 @@
This is JSR-223 script engine for Jython - Java implementation of Python.
Jython is available for download at http://www.jython.org/. We have built
and tested with Jython version 2.2.1.
144 changes: 144 additions & 0 deletions jython/jython-engine/THIRDPARTYLICENSES.TXT
@@ -0,0 +1,144 @@
HISTORY OF THE SOFTWARE
=======================

JPython was created in late 1997 by Jim Hugunin. Jim was also the
primary developer while he was at CNRI. In February 1999 Barry Warsaw
took over as primary developer and released JPython version 1.1.
In October 2000 Barry helped move the software to SourceForge
where it was renamed to Jython. Jython 2.0 is developed by a group
of volunteers.


The standard library is covered by the BeOpen / CNRI license. See the
Lib/LICENSE file for details.

The oro regular expresion matcher is covered by the apache license.
See the org/apache/LICENSE file for details.

The zxJDBC package was written by Brian Zimmer and originally licensed
under the GNU Public License. The package is now covered by the Jython
Software License.

Jython changes Software License.
================================

Copyright (c) 2000, Jython Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.

- Neither the name of the Jython Developers nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.




JPython Software License.
=========================

______________________________________________________________________

IMPORTANT: PLEASE READ THE FOLLOWING AGREEMENT CAREFULLY.

BY CLICKING ON THE "ACCEPT" BUTTON WHERE INDICATED, OR BY INSTALLING,
COPYING OR OTHERWISE USING THE SOFTWARE, YOU ARE DEEMED TO HAVE AGREED TO
THE TERMS AND CONDITIONS OF THIS AGREEMENT.

______________________________________________________________________

JPython version 1.1.x

1. This LICENSE AGREEMENT is between the Corporation for National Research
Initiatives, having an office at 1895 Preston White Drive, Reston, VA
20191 ("CNRI"), and the Individual or Organization ("Licensee")
accessing and using JPython version 1.1.x in source or binary form and
its associated documentation as provided herein ("Software").

2. Subject to the terms and conditions of this License Agreement, CNRI
hereby grants Licensee a non-exclusive, non-transferable, royalty-free,
world-wide license to reproduce, analyze, test, perform and/or display
publicly, prepare derivative works, distribute, and otherwise use the
Software alone or in any derivative version, provided, however, that
CNRI's License Agreement and CNRI's notice of copyright, i.e.,
"Copyright �1996-1999 Corporation for National Research Initiatives;
All Rights Reserved" are both retained in the Software, alone or in any
derivative version prepared by Licensee.

Alternatively, in lieu of CNRI's License Agreement, Licensee may
substitute the following text (omitting the quotes), provided, however,
that such text is displayed prominently in the Software alone or in any
derivative version prepared by Licensee: "JPython (Version 1.1.x) is
made available subject to the terms and conditions in CNRI's License
Agreement. This Agreement may be located on the Internet using the
following unique, persistent identifier (known as a handle):
1895.22/1006. The License may also be obtained from a proxy server on
the Web using the following URL: http://hdl.handle.net/1895.22/1006."

3. In the event Licensee prepares a derivative work that is based on or
incorporates the Software or any part thereof, and wants to make the
derivative work available to the public as provided herein, then
Licensee hereby agrees to indicate in any such work, in a prominently
visible way, the nature of the modifications made to CNRI's Software.

4. Licensee may not use CNRI trademarks or trade name, including JPython
or CNRI, in a trademark sense to endorse or promote products or
services of Licensee, or any third party. Licensee may use the mark
JPython in connection with Licensee's derivative versions that are
based on or incorporate the Software, but only in the form
"JPython-based ___________________," or equivalent.

5. CNRI is making the Software available to Licensee on an "AS IS" basis.
CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY
OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND DISCLAIMS ANY
REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY
PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE
ANY THIRD PARTY RIGHTS.

6. CNRI SHALL NOT BE LIABLE TO LICENSEE OR OTHER USERS OF THE SOFTWARE FOR
ANY INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY DERIVATIVE
THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. SOME STATES DO NOT
ALLOW THE LIMITATION OR EXCLUSION OF LIABILITY SO THE ABOVE DISCLAIMER
MAY NOT APPLY TO LICENSEE.

7. This License Agreement may be terminated by CNRI (i) immediately upon
written notice from CNRI of any material breach by the Licensee, if the
nature of the breach is such that it cannot be promptly remedied; or
(ii) sixty (60) days following notice from CNRI to Licensee of a
material remediable breach, if Licensee has not remedied such breach
within that sixty-day period.

8. This License Agreement shall be governed by and interpreted in all
respects by the law of the State of Virginia, excluding conflict of law
provisions. Nothing in this Agreement shall be deemed to create any
relationship of agency, partnership, or joint venture between CNRI and
Licensee.

9. By clicking on the "ACCEPT" button where indicated, or by installing,
copying or otherwise using the Software, Licensee agrees to be bound by
the terms and conditions of this License Agreement.

[ACCEPT BUTTON]

2 changes: 2 additions & 0 deletions jython/jython-engine/bin/jython.bat
@@ -0,0 +1,2 @@
jrunscript -Dpython.path=../lib/jython.jar -cp ../build/jython-engine.jar;../lib/jython.jar -l jython %*

2 changes: 2 additions & 0 deletions jython/jython-engine/bin/jython.sh
@@ -0,0 +1,2 @@
jrunscript -Dpython.path=../lib/jython.jar -cp ../build/jython-engine.jar:../lib/jython.jar -l jython $*

Binary file added jython/jython-engine/lib/jython.jar
Binary file not shown.
46 changes: 46 additions & 0 deletions jython/jython-engine/make/build.xml
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>

<project name="Jython Engine" default="all" basedir=".">

<!-- Property Definitions -->

<property name="app.name" value="jython-engine"/>
<property name="src.dir" value="../src"/>
<property name="lib.dir" value="../lib"/>
<property name="build.dir" value="../build"/>
<property name="dist.jar" value="${build.dir}/${app.name}.jar"/>
<property name="classes.dir" value="${build.dir}/classes"/>

<target name="prepare">
<mkdir dir="${classes.dir}"/>
</target>


<target name="clean">
<delete dir="${build.dir}"/>
</target>

<path id="javac.classpath">
<pathelement path="${jsr223.jar}" />
<pathelement path="${lib.dir}/jython.jar" />
</path>

<target name="compile" depends="prepare" description="Compiles the sources">
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
debug="on" deprecation="on">
<classpath refid="javac.classpath" />
</javac>
<copy todir="${classes.dir}/META-INF/services">
<fileset dir="${src.dir}/META-INF/services"/>
</copy>
</target>

<target name="deploy" depends="compile" description="Creates a deployment bundle">
<jar jarfile="${dist.jar}"
basedir="${classes.dir}"/>
</target>

<target name="all" depends="deploy" description="Builds sources and deployment jar"/>

</project>
@@ -0,0 +1,2 @@
com.sun.script.jython.JythonScriptEngineFactory

13 comments on commit 11985ab

@xuhdev
Copy link
Member Author

@xuhdev xuhdev commented on 11985ab Jun 10, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@treyhunner
The Java wrapper should be completed. To show the usage, write the following to TestJython.java:

import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.List;
import org.editorconfig.core.*;

public class TestJython {
    public static void main(String[] args) throws ScriptException {
        EditorConfig ec = new EditorConfig();
        List<EditorConfig.OutPair> l = ec.getProperties("/home/your/src/editorconfig-core-py/a.py");

        for(int i = 0; i < l.size(); ++i) {
            System.out.println(l.get(i).getKey() + "=" + l.get(i).getVal());
        }
    }
}

Then

cd jython
ant
javac -cp build/editorconfig.jar TestJython.java
java -cp "build/editorconfig.jar:." TestJython

Document still need to be completed.

@treyhunner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add documentation for the Jython/Java library in the Python Core documentation?

@xuhdev
Copy link
Member Author

@xuhdev xuhdev commented on 11985ab Jun 10, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the API, we could have a standard javadoc for java developers. But I'm not sure yet whether the usage should be put in the python doc. Maybe we could also include the usage in the javadoc and put a link to that place on the website?

@treyhunner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could include all instructions in the Java doc and link to it from the Python Core README and/or documentation.

Can we include an EditorConfig compiled jar file on the downloads page so developers do not have to compile their own from Jython?

@xuhdev
Copy link
Member Author

@xuhdev xuhdev commented on 11985ab Jun 11, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe so. But since the C# wrapper is going to be born according to the mailing list, things would become a bit complicated. How do you think we should deal with these wrappers?

@treyhunner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just upload them to the downloads sections of their respective EditorConfig core repositories and mention them in the README and/or documentation.

@xuhdev
Copy link
Member Author

@xuhdev xuhdev commented on 11985ab Jun 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The java binding is almost finished now, except the license. Shall we use PSF license?

@treyhunner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless the Java binding uses code under another license we should probably use the Simplified BSD license (or similar). I chose PSF for the main editorconfig module because ini.py and fnmatch.py are both based on PSF licensed modules.

@xuhdev
Copy link
Member Author

@xuhdev xuhdev commented on 11985ab Jun 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The java binding should be based on the Python core.

@treyhunner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses the Python code as a library but does not actually copy the code itself, correct? If that is the case then it does not need to use the PSFL.

@xuhdev
Copy link
Member Author

@xuhdev xuhdev commented on 11985ab Jun 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I didn't explain it clearly. We finally will upload a jar file, which contains the python files and jython, which are both PSFL. Should we release under PSFL?

@treyhunner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. At least the jython and editorconfig code needs to be under PSFL. All other code that connects the two can also be under PSFL if you think that is most logical.

@xuhdev
Copy link
Member Author

@xuhdev xuhdev commented on 11985ab Jun 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid our user to be in trouble with what license they should use, let's use PSFL.

Please sign in to comment.