vgritsenko    02/02/08 19:13:03

  Modified:    .        build.xml
               src/webapp cocoon.xconf
  Added:       legal    LICENSE.pizza
               lib/optional pizza-1.1.jar
               src/java/org/apache/cocoon/components/language/programming/java
                        Pizza.java
  Log:
  Add Pizza Java compiler. To use:
   - Replace .Javac with .Pizza in the cocoon.xconf
   - build webapp
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/legal/LICENSE.pizza
  
  Index: LICENSE.pizza
  ===================================================================
  The Artistic License
  Preamble
  
  The intent of this document is to state the conditions under which a
  Package may be copied, such that the Copyright Holder maintains some
  semblance of artistic control over the development of the package,
  while giving the users of the package the right to use and distribute
  the Package in a more-or-less customary fashion, plus the right to
  make reasonable modifications.
  
  Definitions:
  
  "Package" refers to the collection of files distributed by the
  Copyright Holder, and derivatives of that collection of files created
  through textual modification.
  
  "Standard Version" refers to such a Package if it has not been
  modified, or has been modified in accordance with the wishes of the
  Copyright Holder.
  
  "Copyright Holder" is whoever is named in the copyright or copyrights
  for the package.
  
  "You" is you, if you're thinking about copying or distributing this
  Package.
  
  "Reasonable copying fee" is whatever you can justify on the basis of
  media cost, duplication charges, time of people involved, and so
  on. (You will not be required to justify it to the Copyright Holder,
  but only to the computing community at large as a market that must
  bear the fee.)
  
  "Freely Available" means that no fee is charged for the item itself,
  though there may be fees involved in handling the item. It also means
  that recipients of the item may redistribute it under the same
  conditions they received it.
  
  1. You may make and give away verbatim copies of the source form of
     the Standard Version of this Package without restriction, provided
     that you duplicate all of the original copyright notices and
     associated disclaimers.
  
  2. You may apply bug fixes, portability fixes and other modifications
     derived from the Public Domain or from the Copyright Holder. A
     Package modified in such a way shall still be considered the
     Standard Version.
  
  3. You may otherwise modify your copy of this Package in any way,
     provided that you insert a prominent notice in each changed file
     stating how and when you changed that file, and provided that you
     do at least ONE of the following:
  
  a) place your modifications in the Public Domain or otherwise make
  them Freely Available, such as by posting said modifications to Usenet
  or an equivalent medium, or placing the modifications on a major
  archive site such as ftp.uu.net, or by allowing the Copyright Holder
  to include your modifications in the Standard Version of the Package.
  
  b) use the modified Package only within your corporation or
  organization.
  
  c) rename any non-standard executables so the names do not conflict
  with standard executables, which must also be provided, and provide a
  separate manual page for each non-standard executable that clearly
  documents how it differs from the Standard Version.
  
  d) make other distribution arrangements with the Copyright Holder.
  
  4. You may distribute the programs of this Package in object code or
     executable form, provided that you do at least ONE of the
     following:
  
  a) distribute a Standard Version of the executables and library files,
  together with instructions (in the manual page or equivalent) on where
  to get the Standard Version.
  
  b) accompany the distribution with the machine-readable source of the
  Package with your modifications.
  
  c) accompany any non-standard executables with their corresponding
  Standard Version executables, giving the non-standard executables
  non-standard names, and clearly documenting the differences in manual
  pages (or equivalent), together with instructions on where to get the
  Standard Version.
  
  d) make other distribution arrangements with the Copyright Holder.
  
  5. You may charge a reasonable copying fee for any distribution of
     this Package. You may charge any fee you choose for support of this
     Package. You may not charge a fee for this Package itself. However,
     you may distribute this Package in aggregate with other (possibly
     commercial) programs as part of a larger (possibly commercial)
     software distribution provided that you do not advertise this
     Package as a product of your own.
  
  6. The scripts and library files supplied as input to or produced as
     output from the programs of this Package do not automatically fall
     under the copyright of this Package, but belong to whomever
     generated them, and may be sold commercially, and may be aggregated
     with this Package.
  
  7. C or perl or any other language subroutines supplied by you and
     linked into this Package shall not be considered part of this
     Package.
  
  8. The name of the Copyright Holder may not be used to endorse or
     promote products derived from this software without specific prior
     written permission.
  
  9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
     WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
     OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  
  The End
  
  
  
  1.1                  xml-cocoon2/lib/optional/pizza-1.1.jar
  
        <<Binary file>>
  
  
  1.161     +6 -2      xml-cocoon2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/build.xml,v
  retrieving revision 1.160
  retrieving revision 1.161
  diff -u -r1.160 -r1.161
  --- build.xml 8 Feb 2002 19:07:04 -0000       1.160
  +++ build.xml 9 Feb 2002 03:13:03 -0000       1.161
  @@ -298,6 +298,10 @@
       </available>
   
   
  +    <class-available classpathref="classpath"
  +                    property="pizza.present" 
  +                    classname="net.sf.pizzacompiler.compiler.Main"/>
  +
       <class-available classpathref="classpath" 
                       property="xmldb.present" 
                       classname="org.xmldb.api.DatabaseManager"/>
  @@ -1078,8 +1082,8 @@
     <!-- =================================================================== -->
     <!-- Copies the tools.jar to javac.jar in web-inf/lib                    -->
     <!-- =================================================================== -->
  -  <target name="prepare-tools-lib" depends="package" if="tools.jar.present">
  -    <!-- NOTE: java.home is normally set by the JVM to the /jre directory -->
  +  <target name="prepare-tools-lib" depends="package" if="tools.jar.present" 
unless="pizza.present">
  +    <!-- NOTE: java.home is normally set by the JVM to the /jre directory  -->
       <copy file="${tools.jar}" tofile="${build.war}/WEB-INF/lib/javac.jar"/>
     </target>
   
  
  
  
  1.1                  
xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java/Pizza.java
  
  Index: Pizza.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. 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.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache Cocoon" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
   * ITS 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.cocoon.components.language.programming.java;
  
  import org.apache.cocoon.components.language.programming.CompilerError;
  import org.apache.cocoon.util.ClassUtils;
  
  import net.sf.pizzacompiler.compiler.ClassReader;
  import net.sf.pizzacompiler.compiler.FileCompilerOutput;
  import net.sf.pizzacompiler.compiler.FileSourceReader;
  import net.sf.pizzacompiler.compiler.Main;
  import org.apache.log.Hierarchy;
  
  import java.io.BufferedReader;
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.File;
  import java.io.IOException;
  import java.io.PrintStream;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.NoSuchElementException;
  import java.util.StringTokenizer;
  
  /**
   * This class wraps the Pizza Java Compiler.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Vadim Gritsenko</a>
   * @version CVS $Id: Pizza.java,v 1.1 2002/02/09 03:13:03 vgritsenko Exp $
   */
  public class Pizza extends Javac {
  
      public final static String PIZZA_CLASS = "net.sf.pizzacompiler.compiler.Main";
  
      public Pizza() {
          super(true);
  
          try {
              ClassUtils.loadClass(PIZZA_CLASS);
          } catch (ClassNotFoundException e) {
              Hierarchy.getDefaultHierarchy().getLoggerFor("cocoon").error("No Pizza 
Java compiler found in your classpath. Make sure you added 'pizza.jar'", e);
              throw new RuntimeException("No Pizza Java compiler found in your 
classpath. Make sure you added 'pizza.jar'");
          }
  
          net.sf.pizzacompiler.compiler.Main.init();
      }
  
      /**
       * Compile a source file yielding a loadable class file.
       *
       * @param filename The object program base file name
       * @param baseDirectory The directory containing the object program file
       * @param encoding The encoding expected in the source file or
       * <code>null</code> if it is the platform's default encoding
       * @exception LanguageException If an error occurs during compilation
       */
      public boolean compile() throws IOException {
  
          ByteArrayOutputStream err = new ByteArrayOutputStream();
  
          Main.init();
          Main.setClassReader(new ClassReader(this.classpath, null));
          Main.argument("-java");
          Main.argument("-O");
          Main.argument("-nowarn");
          Main.compile(new String[]{file},
                  new FileSourceReader(),
                  new FileCompilerOutput(new File(destDir)),
                  new PrintStream(err));
  
          this.errors = new ByteArrayInputStream(err.toByteArray());
          return err.size() == 0;
      }
  
      public String toString() {
          return "Pizza Java Compiler";
      }
  }
  
  
  
  1.24      +5 -4      xml-cocoon2/src/webapp/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/cocoon.xconf,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- cocoon.xconf      5 Feb 2002 14:47:35 -0000       1.23
  +++ cocoon.xconf      9 Feb 2002 03:13:03 -0000       1.24
  @@ -192,10 +192,11 @@
     -->
     <programming-languages>
       <java-language name="java" logger="core.language.java">
  -      <!-- compiler parameter specifies which class to use to compile Java.
  -           Possible variants are Javac and Jikes compilers.
  -           Javac requires javac.jar (included with Cocoon distribution).
  -           Jikes requires IBM jikes compiler to be present in the PATH  -->
  +      <!-- Compiler parameter specifies which class to use to compile Java.
  +           Possible variants are:
  +             Javac. Requires javac.jar (included with Cocoon distribution).
  +             Pizza. Requires pizza.jar (included with Cocoon distribution).
  +             Jikes. Requires IBM jikes compiler to be present in the PATH  -->
         <parameter name="compiler" 
value="org.apache.cocoon.components.language.programming.java.Javac"/>
         <!-- Specifies which formatter to use to format source code.
              This parameter is optional. 
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to