commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1084263 - in /commons/sandbox/runtime/trunk: ./ src/build/ src/build/org/ src/build/org/apache/ src/build/org/apache/commons/ src/build/org/apache/commons/runtime/ src/build/org/apache/commons/runtime/ant/ src/main/java/org/apache/commons/...
Date Tue, 22 Mar 2011 17:38:29 GMT
Author: mturk
Date: Tue Mar 22 17:38:29 2011
New Revision: 1084263

URL: http://svn.apache.org/viewvc?rev=1084263&view=rev
Log:
Add old build tasks but with a different scope

Added:
    commons/sandbox/runtime/trunk/src/build/
    commons/sandbox/runtime/trunk/src/build/org/
    commons/sandbox/runtime/trunk/src/build/org/apache/
    commons/sandbox/runtime/trunk/src/build/org/apache/commons/
    commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/
    commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/
    commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java
  (with props)
    commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/UuidTask.java 
 (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OsType.java   (with
props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Local.java
  (with props)
Modified:
    commons/sandbox/runtime/trunk/build.xml
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java

Modified: commons/sandbox/runtime/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.xml?rev=1084263&r1=1084262&r2=1084263&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.xml (original)
+++ commons/sandbox/runtime/trunk/build.xml Tue Mar 22 17:38:29 2011
@@ -25,7 +25,7 @@
     <property name="build.dir" value="${basedir}/dist"/>
     <property name="build.src" value="${build.dir}/src"/>
     <property name="build.dest" value="${build.dir}/bin"/>
-    <property name="src.java" value="${basedir}/src"/>
+    <property name="src.base" value="${basedir}/src"/>
     <property name="src.docs" value="${basedir}/xdocs"/>
     <property name="src.native" value="${basedir}/src/main/native"/>
     <property name="final.name" value="${project}-${version}${version.suffix}"/>
@@ -121,7 +121,7 @@
             destdir="${docs.dest}/api"
             author="true"
             version="true"
-            overview="${src.java}/main/java/overview.html"
+            overview="${src.base}/main/java/overview.html"
             packagenames="${build.package.name}.*"
             windowtitle="${title} (Version ${version})"
             doctitle="&lt;h2&gt;${title}&lt;/h2&gt;"
@@ -148,7 +148,7 @@ The Apache Software Foundation (http://w
         <mkdir dir="${build.dest}/build"/>
         <mkdir dir="${build.src}/build"/>
         <copy todir="${build.src}/build" filtering="yes">
-            <fileset dir="${src.native}/build">
+            <fileset dir="${src.base}/build">
                 <include name="**/*.java"/>
                 <include name="**/*.xml"/>
                 <include name="**/*.properties"/>
@@ -160,7 +160,8 @@ The Apache Software Foundation (http://w
             source="${compile.source}"
             target="${compile.target}"
             deprecation="${compile.deprecation}"
-            optimize="${compile.optimize}">
+            optimize="${compile.optimize}"
+            includeantruntime="true">
             <classpath refid="task.classpath"/>
         </javac>
         <taskdef name="systemid"
@@ -171,8 +172,8 @@ The Apache Software Foundation (http://w
             classname="${build.package.name}.ant.UuidTask">
             <classpath refid="task.classpath"/>
         </taskdef>
-        <uuid property="build.uuid" />
-        <systemid property="systemid" />
+        <uuid/>
+        <systemid/>
     </target>
 
     <!-- =================================================================== -->
@@ -197,7 +198,7 @@ The Apache Software Foundation (http://w
         <filter token="VERSION_BUILT"  value="${TODAY} ${TSTAMP}"/>
         <filter token="VERSION_UUID"   value="${build.uuid}"/>
         <copy todir="${build.src}/java" filtering="yes">
-            <fileset dir="${src.java}/main/java">
+            <fileset dir="${src.base}/main/java">
                 <include name="**/*.java"/>
                 <include name="**/*.xml"/>
                 <include name="**/*.properties"/>
@@ -211,7 +212,8 @@ The Apache Software Foundation (http://w
             source="${compile.source}"
             target="${compile.target}"
             failonerror="false"
-            optimize="${compile.optimize}">
+            optimize="${compile.optimize}"
+            includeantruntime="false">
             <classpath refid="classpath"/>
             <compilerarg line="-Xmaxerrs 1000"/>
         </javac>
@@ -244,7 +246,7 @@ The Apache Software Foundation (http://w
         <filter token="VERSION_PNAME" value="${final.name}"/>
         <filter token="VERSION_BUILT" value="${TODAY} ${TSTAMP}"/>
         <copy todir="${build.src}/examples" filtering="yes">
-            <fileset dir="${src.java}/examples">
+            <fileset dir="${src.base}/examples">
                 <include name="**/*.java"/>
                 <include name="**/*.xml"/>
                 <include name="**/*.properties"/>
@@ -257,7 +259,8 @@ The Apache Software Foundation (http://w
             source="${compile.source}"
             target="${compile.target}"
             deprecation="${compile.deprecation}"
-            optimize="${compile.optimize}">
+            optimize="${compile.optimize}"
+            includeantruntime="false">
             <classpath refid="examples.classpath"/>
         </javac>
         <copy todir="${build.dest}/examples" filtering="yes">
@@ -341,7 +344,7 @@ The Apache Software Foundation (http://w
         <mkdir dir="${build.dest}/test"/>
         <mkdir dir="${build.src}/test"/>
         <copy todir="${build.src}/test" filtering="yes">
-            <fileset dir="${src.java}/test">
+            <fileset dir="${src.base}/test">
                 <include name="**/*.java"/>
                 <include name="**/*.xml"/>
                 <include name="**/*.properties"/>
@@ -353,7 +356,8 @@ The Apache Software Foundation (http://w
             source="${compile.source}"
             target="${compile.target}"
             deprecation="${compile.deprecation}"
-            optimize="${compile.optimize}">
+            optimize="${compile.optimize}"
+            includeantruntime="false">
             <classpath refid="test.classpath"/>
         </javac>
     </target>

Added: commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java?rev=1084263&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java
(added)
+++ commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java
Tue Mar 22 17:38:29 2011
@@ -0,0 +1,231 @@
+/* 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.
+ */
+package org.apache.commons.runtime.ant;
+
+import java.util.Properties;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import org.apache.tools.ant.taskdefs.condition.ConditionBase;
+
+/**
+ * Apache Ant task for setting the {@code SystemId} properties.
+ * <p>
+ * The task is used in {@code build.xml} for setting the same
+ * names later used for extracting the native libraries.
+ * </p>
+ */
+public class SystemIdTask extends Task implements Condition
+{
+    private String            prefix = "systemid";
+    private String            equals;
+    private String            arch;
+    private String            cpu;
+    private static Properties props;
+
+    static {
+        props = System.getProperties();
+    }
+
+    /* Copy of the {@code SystemId.getSysname} method.
+     * Make sure those methods are in sync!
+     */
+    private static String getSysname()
+    {
+        String name = props.getProperty("os.name");
+        String platform = "unknown";
+
+        if (name.startsWith("Windows"))
+            platform = "windows";
+        else if (name.startsWith("Mac OS"))
+            platform = "darwin";
+        else if (name.endsWith("BSD"))
+            platform = "bsd";
+        else if (name.equals("Linux"))
+            platform = "linux";
+        else if (name.equals("Solaris"))
+            platform = "solaris";
+        else if (name.equals("SunOS"))
+            platform = "solaris";
+        else if (name.equals("HP-UX"))
+            platform = "hpux";
+        else if (name.equals("AIX"))
+            platform = "aix";
+
+        return platform;
+    }
+
+    /* Copy of the {@code SystemId.getDataModel} method.
+     * Make sure those methods are in sync!
+     */
+    private static String getDataModel()
+    {
+        String data = props.getProperty("sun.arch.data.model");
+
+        if (data == null) {
+            data = props.getProperty("com.ibm.vm.bitmode");
+        }
+        if (data == null) {
+            String arch = props.getProperty("os.arch");
+            if (arch.indexOf("64") < 0) {
+                /* TODO: Investigate other JVM's property for
+                 * figuring the data model (32 or 64)
+                 */
+                data = "32";
+            }
+            else {
+                data = "64";
+            }
+        }
+        return data;
+    }
+
+    /* Copy of the {@code SystemId.getProcessor} method.
+     * Make sure those methods are in sync!
+     */
+    private static String getProcessor()
+    {
+        String cpu;
+        String name = props.getProperty("os.name");
+        String arch = props.getProperty("os.arch");
+        String data = getDataModel();
+
+        if (arch.endsWith("86")) {
+            cpu = "x86";
+            if (name.startsWith("Mac OS")) {
+                if (data.equals("64"))
+                    cpu = "x86_64";
+            }
+        }
+        else if (arch.startsWith("PA_RISC")) {
+            if (data.equals("64"))
+                cpu = "parisc64";
+            else
+                cpu = "parisc";
+        }
+        else if (arch.startsWith("IA64"))
+            cpu = "ia64";
+        else if (arch.startsWith("sparc")) {
+            if (data.equals("64"))
+                cpu = "sparc64";
+            else
+                cpu = "sparc";
+        }
+        else if (arch.startsWith("ppc")) {
+            if (data.equals("64"))
+                cpu = "ppc64";
+            else
+                cpu = "ppc";
+        }
+        else if (arch.equals("amd64"))
+            cpu = "x86_64";
+        else
+            cpu = arch;
+        return cpu;
+    }
+
+    /* Copy of the {@code SystemId.getSoExtension} method.
+     * Make sure those methods are in sync!
+     */
+    private static String getSoExtension()
+    {
+        String sys = getSysname();
+        String ext;
+
+        if (sys.equals("windows")) {
+            ext = "dll";
+        }
+        else if (sys.equals("darwin")) {
+            ext = "jnilib";
+        }
+        else if (sys.equals("hpux")) {
+            if (getProcessor().startsWith("parisc"))
+                ext = "sl";
+            else
+                ext = "so";
+        }
+        else {
+            ext = "so";
+        }
+        /* TODO: Check if this matches the System.mapLibraryName()
+         */
+        return ext;
+    }
+
+    public void setPrefix(String prefix)
+    {
+        this.prefix = prefix;
+    }
+
+    public void setEquals(String equals)
+    {
+        this.equals = equals;
+    }
+
+    public void setArch(String arch)
+    {
+        this.arch = arch;
+    }
+
+    public void setCpu(String cpu)
+    {
+        this.cpu = cpu;
+    }
+
+    public void execute()
+        throws BuildException
+    {
+        if (prefix == null)
+            throw new BuildException("Missing prefix attribute");
+        getProject().setNewProperty(prefix + ".so",  getSoExtension());
+        getProject().setNewProperty(prefix + ".cpu", getProcessor());
+        getProject().setNewProperty(prefix + ".os",  getSysname());
+        getProject().setNewProperty(prefix + ".data.model", getDataModel());
+        getProject().setNewProperty(prefix + ".OS",  getSysname().toUpperCase());
+        getProject().setNewProperty(prefix + ".CPU", getProcessor().toUpperCase());
+    }
+
+    public boolean eval()
+        throws BuildException
+    {
+        int cnt = 0;
+        if (equals != null)
+            cnt++;
+        if (arch   != null)
+            cnt++;
+        if (cpu    != null)
+            cnt++;
+
+        if (cnt == 0)
+            throw new BuildException("Missing condition attribute");
+        else if (cnt > 1)
+            throw new BuildException("Multiple condition attributes not allowed");
+
+        boolean matches = false;
+        if (equals != null) {
+            if (arch != null || cpu != null)
+                throw new BuildException("Single condition is allowed only");
+            matches = equals.equalsIgnoreCase(getSysname());
+        }
+        if (arch != null)
+            matches = arch.equalsIgnoreCase(getDataModel());
+        if (cpu != null)
+            matches = cpu.equalsIgnoreCase(getProcessor());
+
+        return matches;
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/UuidTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/UuidTask.java?rev=1084263&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/UuidTask.java (added)
+++ commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/UuidTask.java Tue
Mar 22 17:38:29 2011
@@ -0,0 +1,85 @@
+/* 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.
+ */
+package org.apache.commons.runtime.ant;
+
+import java.util.Random;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * Apache Ant task for setting the {@code UUID} property.
+ */
+public class UuidTask extends Task
+{
+    private String prefix   = "build";
+    private String property;
+
+    public void setPrefix(String prefix)
+    {
+        this.prefix = prefix;
+    }
+
+    public void setProperty(String property)
+    {
+        this.property = property;
+    }
+
+    private String hex(byte val)
+    {
+        String h = Integer.toHexString(val);
+        if (h.length() == 1)
+            h = "0" + h;
+        return h.substring(h.length() - 2);
+    }
+
+    public void execute()
+        throws BuildException
+    {
+        if (property == null) {
+            property = prefix + ".uuid";
+        }
+        byte [] uuid  = new byte[16];
+        Random random = new Random(System.currentTimeMillis());
+        random.nextBytes(uuid);
+
+        // "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
+        StringBuffer sb = new StringBuffer();
+        sb.append(hex(uuid[0]));
+        sb.append(hex(uuid[1]));
+        sb.append(hex(uuid[2]));
+        sb.append(hex(uuid[3]));
+        sb.append('-');
+        sb.append(hex(uuid[4]));
+        sb.append(hex(uuid[5]));
+        sb.append('-');
+        sb.append(hex(uuid[6]));
+        sb.append(hex(uuid[7]));
+        sb.append('-');
+        sb.append(hex(uuid[8]));
+        sb.append(hex(uuid[9]));
+        sb.append('-');
+        sb.append(hex(uuid[10]));
+        sb.append(hex(uuid[11]));
+        sb.append(hex(uuid[12]));
+        sb.append(hex(uuid[13]));
+        sb.append(hex(uuid[14]));
+        sb.append(hex(uuid[15]));
+
+        getProject().setNewProperty(property,  sb.toString());
+    }
+
+}

Propchange: commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/UuidTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OsType.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OsType.java?rev=1084263&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OsType.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OsType.java Tue
Mar 22 17:38:29 2011
@@ -0,0 +1,125 @@
+/* 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.
+ */
+
+package org.apache.commons.runtime;
+
+import java.util.EnumSet;
+
+/**
+ * Operating system type Enum.
+ */
+public enum OsType
+{
+    /**
+     * Operating system is Microsoft Windows family
+     * operating system..
+     * <br/>Defined integer value is: {@code 0x10000}
+     */
+    WINDOWS(    0x10000),
+
+    /**
+     * Operating system is Microsoft Windows 64.
+     * <br/>Defined integer value is: {@code 0x10010}
+     */
+    WIN64(      0x10010),
+
+    /**
+     * Operating system is Microsoft Windows 64 running 32-bit JVM.
+     * <br/>Defined integer value is: {@code 0x10020}
+     */
+    WOW64(      0x10020),
+
+    /**
+     * Operating system is unix family operating system.
+     * <br/>Defined integer value is: {@code 0x20000}
+     */
+    UNIX(       0x20000),
+
+    /**
+     * Operating system is Linux.
+     * <br/>Defined integer value is: {@code 0x20100}
+     */
+    LINUX(      0x20100),
+
+    /**
+     * Operating system is Sun Solaris.
+     * <br/>Defined integer value is: {@code 0x20200}
+     */
+    SOLARIS(    0x20200),
+
+    /**
+     * Operating system is Apple Mac OS X.
+     * <br/>Defined integer value is: {@code 0x20400}
+     */
+    DARWIN(     0x20400),
+
+    /**
+     * Operating system is Hewlett Packard HP-UX.
+     * <br/>Defined integer value is: {@code 0x20800}
+     */
+    HPUX(       0x20800),
+
+    /**
+     * Operating system is IBM AIX.
+     * <br/>Defined integer value is: {@code 0x21000}
+     */
+    AIX(        0x21000);
+
+    private int value;
+    private OsType(int v)
+    {
+        value = v;
+    }
+
+    /**
+     * Integer representing the value of this Enum.
+     */
+    public int valueOf()
+    {
+        return value;
+    }
+
+    /**
+     * Integer representing the sum of the integer values
+     * of the {@code OsType} enums.
+     * @param set The {@code EnumSet} which values to get.
+     */
+    public static int bitmapOf(EnumSet<OsType> set)
+    {
+        int bitmap = 0;
+        if (set != null) {
+            for (OsType t : set)
+                bitmap += t.valueOf();
+        }
+        return bitmap;
+    }
+
+    /**
+     * Returns {@code EnumSet} of {@code OsType} enums
+     * from the integer bitmap value.
+     * @param value Integer used to construct the {@code EnumSet}
+     * with {@code OsType} values mathching the value flags.
+     */
+    public static EnumSet<OsType> valueOf(int value)
+    {
+        EnumSet<OsType> set = EnumSet.noneOf(OsType.class);
+        for (OsType e : values()) {
+            if ((e.value & value) == e.value)
+                set.add(e);
+        }
+        return set;
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OsType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java?rev=1084263&r1=1084262&r2=1084263&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java Tue
Mar 22 17:38:29 2011
@@ -195,6 +195,12 @@ public final class SystemId
             else
                 pid = 0x20812;
         }
+        else if (sys.equals("aix")) {
+            if (cpu.equals("ppc"))
+                pid = 0x21000;
+            else
+                pid = 0x21010;
+        }
         return pid;
     }
 

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Local.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Local.java?rev=1084263&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Local.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Local.java
Tue Mar 22 17:38:29 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.commons.runtime.util;
+
+/** Util package private constants
+ */
+class Local
+{
+
+    public static final String Package = "org.apache.commons.runtime.util";
+    public static final StringManager sm;
+
+    static {
+        sm = StringManager.getManager(Package);
+    }
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Local.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message