summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2015-03-30 12:26:49 -0230
committerDwayne Boone <dwayne@zeroc.com>2015-03-30 12:26:49 -0230
commitc230cca9774d35ecc341f96a12db98cb2b61a0ce (patch)
treeb25416cd2961fe46148ec33d672b42466194b160 /java/src
parentRemove vsaddin (diff)
downloadice-c230cca9774d35ecc341f96a12db98cb2b61a0ce.tar.bz2
ice-c230cca9774d35ecc341f96a12db98cb2b61a0ce.tar.xz
ice-c230cca9774d35ecc341f96a12db98cb2b61a0ce.zip
Moved ant task to its own repository
Diffstat (limited to 'java/src')
-rw-r--r--java/src/ant-ice/Slice2FreezeJTask.java666
-rw-r--r--java/src/ant-ice/Slice2JavaTask.java422
-rw-r--r--java/src/ant-ice/SliceDefine.java40
-rw-r--r--java/src/ant-ice/SliceMeta.java25
-rw-r--r--java/src/ant-ice/SliceTask.java561
-rw-r--r--java/src/ant-ice/build.gradle28
6 files changed, 0 insertions, 1742 deletions
diff --git a/java/src/ant-ice/Slice2FreezeJTask.java b/java/src/ant-ice/Slice2FreezeJTask.java
deleted file mode 100644
index 9efc3be12f7..00000000000
--- a/java/src/ant-ice/Slice2FreezeJTask.java
+++ /dev/null
@@ -1,666 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-//package Ice.Ant;
-
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.types.Commandline.Argument;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
-
-import java.io.File;
-import java.io.FileOutputStream;
-
-/**
- * An ant task for slice2freezej. This task extends the abstract
- * SliceTask class which takes care of attributes common to all slice
- * translators (see SliceTask.java for details on these attributes).
- *
- * Attributes:
- *
- * Nested elements:
- *
- * define - defines a preprocessor symbol
- * dict - contains the NAME, KEY TYPE, and VALUE TYPE of a Freeze map.
- * index - contains the NAME, CLASS TYPE, MEMBER NAME and optional
- * case sensitivity of a Freeze Evictor index.
- * dictindex - contains the NAME and optional member name and case
- * sensitivity of a Freeze Map index.
- *
- * Example:
- *
- * <project ...>
- * <taskdef name="slice2freezej" classname="Slice2FreezeJTask" />
- * <property name="slice.dir" value="../include/slice"/>
- * <target name="generate">
- * <mkdir dir="tags" />
- * <slice2freezej tagdir="tags" outputdir="out" output="CharIntMap">
- * <define name="SYMBOL" value="VALUE"/>
- * <includepath>
- * <pathelement path="${slice.dir}" />
- * </includepath>
- * <fileset dir="${slice.dir}">
- * <include name="*.ice" />
- * </fileset>
- * <dict name="CharIntMap" key="char" value="int"/>
- * <index name="NameIndex" type="Foo" member="name" casesensitive="false"/>
- * </slice2freezej>
- * </target>
- * </project>
- *
- * The <taskdef> element installs the slice2freezej task.
- */
-public class Slice2FreezeJTask extends SliceTask
-{
- public
- Slice2FreezeJTask()
- {
- }
-
- public void
- setTranslator(File prog)
- {
- _translator = prog;
- }
-
- public Dict
- createDict()
- {
- Dict d = new Dict();
- _dicts.add(d);
- return d;
- }
-
- public Index
- createIndex()
- {
- Index i = new Index();
- _indices.add(i);
- return i;
- }
-
- public Dictindex
- createDictindex()
- {
- Dictindex i = new Dictindex();
- _dictIndices.add(i);
- return i;
- }
-
- public void
- execute()
- throws BuildException
- {
- if(_dicts.isEmpty() && _indices.isEmpty())
- {
- throw new BuildException("No dictionary or index specified");
- }
-
- //
- // Read the set of dependencies for this task.
- //
- java.util.HashMap<String, SliceDependency> dependencies = readDependencies();
-
- //
- // Check if the set of slice files changed. If it changed we
- // need to rebuild all the dictionnaries and indices.
- //
- boolean build = false;
- java.util.List<File> sliceFiles = new java.util.LinkedList<File>();
-
- for(FileSet fileset : _fileSets)
- {
- DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
- String[] files = scanner.getIncludedFiles();
-
- for(String file : files)
- {
- File slice = new File(fileset.getDir(getProject()), file);
- sliceFiles.add(slice);
-
- if(!build)
- {
- //
- // The dictionnaries need to be re-created since
- // on dependency changed.
- //
- SliceDependency depend = dependencies.get(getSliceTargetKey(slice.toString()));
- if(depend == null || !depend.isUpToDate())
- {
- build = true;
- }
- }
- }
- }
-
- if(!build)
- {
- //
- // Check that each dictionary has been built at least
- // once.
- //
- for(Dict p : _dicts)
- {
- SliceDependency depend = dependencies.get(getDictTargetKey(p));
- if(depend == null)
- {
- build = true;
- break;
- }
- }
-
- //
- // Likewise for indices
- //
- for(Index p : _indices)
- {
- SliceDependency depend = dependencies.get(getIndexTargetKey(p));
- if(depend == null)
- {
- build = true;
- break;
- }
- }
- }
-
- //
- // Add the --dict options.
- //
- StringBuilder dictString = new StringBuilder(128);
- for(Dict d : _dicts)
- {
- dictString.append(" --dict ");
- dictString.append(d.getName());
- dictString.append(",");
- dictString.append(d.getKey());
- dictString.append(",");
- dictString.append(d.getValue());
- }
-
- //
- // Add the --dict-index options.
- //
- StringBuilder dictIndexString = new StringBuilder(128);
- for(Dictindex d : _dictIndices)
- {
- dictIndexString.append(" --dict-index ");
- dictIndexString.append(d.getName());
- if(d.getMember() != null)
- {
- dictIndexString.append(",");
- dictIndexString.append(d.getMember());
- }
- if(d.getCasesensitive() == false)
- {
- dictIndexString.append(",case-insensitive");
- }
- }
-
- //
- // Add the --index options.
- //
- StringBuilder indexString = new StringBuilder();
- for(Index i : _indices)
- {
- indexString.append(" --index ");
- indexString.append(i.getName());
- indexString.append(",");
- indexString.append(i.getType());
- indexString.append(",");
- indexString.append(i.getMember());
- if(i.getCasesensitive() == false)
- {
- indexString.append(",case-insensitive");
- }
- }
-
- if(!build)
- {
- log("skipping" + dictString + indexString);
- return;
- }
-
- //
- // Run the translator
- //
- StringBuilder cmd = new StringBuilder(256);
-
- //
- // Add --ice
- //
- if(_ice)
- {
- cmd.append(" --ice");
- }
-
- //
- // Add --underscore
- //
- if(_underscore)
- {
- cmd.append(" --underscore");
- }
-
- //
- // Add --output-dir
- //
- if(_outputDir != null)
- {
- cmd.append(" --output-dir ");
- cmd.append(_outputDirString);
- }
-
- //
- // Add include directives
- //
- if(_includePath != null)
- {
- String[] dirs = _includePath.list();
- for(String dir : dirs)
- {
- cmd.append(" -I");
- if(dir.indexOf(' ') != -1)
- {
- cmd.append('"' + dir + '"');
- }
- else
- {
- cmd.append(dir);
- }
- }
- }
-
- //
- // Add defines
- //
- if(!_defines.isEmpty())
- {
- for(SliceDefine define : _defines)
- {
- cmd.append(" -D");
- cmd.append(define.getName());
- String value = define.getValue();
- if(value != null)
- {
- cmd.append("=");
- cmd.append(value);
- }
- }
- }
-
- //
- // Add the --dict options.
- //
- cmd.append(dictString.toString());
-
- //
- // Add the --dict-index options.
- //
- cmd.append(dictIndexString.toString());
-
- //
- // Add the --index options.
- //
- cmd.append(indexString.toString());
-
- //
- // Add the --meta options.
- //
- if(!_meta.isEmpty())
- {
- for(SliceMeta m : _meta)
- {
- cmd.append(" --meta " + m.getValue());
- }
- }
-
- //
- // Add the slice files.
- //
- for(File f : sliceFiles)
- {
- cmd.append(" ");
- String s = f.toString();
- if(s.indexOf(' ') != -1)
- {
- cmd.append('"' + s + '"');
- }
- else
- {
- cmd.append(s);
- }
- }
-
- String translator;
- if(_translator == null)
- {
- translator = getDefaultTranslator("slice2freezej");
- }
- else
- {
- translator = _translator.toString();
- }
-
- //
- // Execute.
- //
- log(translator + " " + cmd);
- ExecTask task = (ExecTask)getProject().createTask("exec");
- addLdLibraryPath(task);
- task.setFailonerror(true);
- Argument arg = task.createArg();
- arg.setLine(cmd.toString());
- task.setExecutable(translator);
- task.execute();
-
- //
- // Update the dependencies.
- //
- if(!sliceFiles.isEmpty())
- {
- cmd = new StringBuilder(256);
- cmd.append("--depend-xml");
-
- //
- // Add --ice
- //
- if(_ice)
- {
- cmd.append(" --ice");
- }
-
- //
- // Add --underscore
- //
- if(_underscore)
- {
- cmd.append(" --underscore");
- }
-
- //
- // Add include directives
- //
- if(_includePath != null)
- {
- String[] dirs = _includePath.list();
- for(String dir : dirs)
- {
- cmd.append(" -I");
- if(dir.indexOf(' ') != -1)
- {
- cmd.append('"');
- cmd.append(dir);
- cmd.append('"');
- }
- else
- {
- cmd.append(dir);
- }
- }
- }
-
- //
- // Add the --dict options.
- //
- cmd.append(dictString.toString());
-
- //
- // Add the --dict-index options.
- //
- cmd.append(dictIndexString.toString());
-
- //
- // Add the --index options.
- //
- cmd.append(indexString.toString());
-
- //
- // Add the slice files.
- //
- for(File f : sliceFiles)
- {
- cmd.append(" ");
- String s = f.toString();
- if(s.indexOf(' ') != -1)
- {
- cmd.append('"');
- cmd.append(s);
- cmd.append('"');
- }
- else
- {
- cmd.append(s);
- }
- }
-
- //
- // It's not possible anymore to re-use the same output property since Ant 1.5.x. so we use a
- // unique property name here. Perhaps we should output the dependencies to a file instead.
- //
- final String outputProperty = "slice2freezej.depend." + System.currentTimeMillis();
-
- task = (ExecTask)getProject().createTask("exec");
- addLdLibraryPath(task);
- task.setFailonerror(true);
- arg = task.createArg();
- arg.setLine(cmd.toString());
- task.setExecutable(translator);
- task.setOutputproperty(outputProperty);
- task.execute();
-
- //
- // Update dependency file.
- //
- java.util.List<SliceDependency> newDependencies =
- parseDependencies(getProject().getProperty(outputProperty));
- for(SliceDependency dep : newDependencies)
- {
- dependencies.put(getSliceTargetKey(dep._dependencies[0]), dep);
- }
- }
-
- for(Dict d : _dicts)
- {
- dependencies.put(getDictTargetKey(d), new SliceDependency());
- }
-
- for(Index i : _indices)
- {
- dependencies.put(getIndexTargetKey(i), new SliceDependency());
- }
-
- writeDependencies(dependencies);
- }
-
- private String
- getSliceTargetKey(String slice)
- {
- //
- // Since the dependency file can be shared by several slice
- // tasks we need to make sure that each dependency has a
- // unique key. We use the name of the task, the output
- // directory, the first dictionary or index name and the name of the
- // slice file to be compiled.
- //
- String name;
- if(_dicts.size() > 0)
- {
- name = (_dicts.get(0)).getName();
- }
- else
- {
- name = (_indices.get(0)).getName();
- }
- return "slice2freezej " + _outputDir.toString() + name + slice;
- }
-
- private String
- getDictTargetKey(Dict d)
- {
- return "slice2freezej " + _outputDir.toString() + d.getName();
- }
-
- private String
- getIndexTargetKey(Index i)
- {
- return "slice2freezej " + _outputDir.toString() + i.getName();
- }
-
- private File _translator = null;
-
- public class Dict
- {
- private String _name;
- private String _key;
- private String _value;
-
- public void
- setName(String name)
- {
- _name = name;
- }
-
- public String
- getName()
- {
- return _name;
- }
-
- public void
- setKey(String key)
- {
- _key = key;
- }
-
- public String
- getKey()
- {
- return _key;
- }
-
- public void
- setValue(String value)
- {
- _value = value;
- }
-
- public String
- getValue()
- {
- return _value;
- }
- }
-
- public class Dictindex
- {
- private String _name;
- private String _member;
- private boolean _caseSensitive = true;
-
- public void
- setName(String name)
- {
- _name = name;
- }
-
- public String
- getName()
- {
- return _name;
- }
-
- public void
- setMember(String member)
- {
- _member = member;
- }
-
- public String
- getMember()
- {
- return _member;
- }
-
- public void
- setCasesensitive(boolean caseSensitive)
- {
- _caseSensitive = caseSensitive;
- }
-
- public boolean
- getCasesensitive()
- {
- return _caseSensitive;
- }
- }
-
- public class Index
- {
- private String _name;
- private String _type;
- private String _member;
- private boolean _caseSensitive = true;
-
- public void
- setName(String name)
- {
- _name = name;
- }
-
- public String
- getName()
- {
- return _name;
- }
-
- public void
- setType(String type)
- {
- _type = type;
- }
-
- public String
- getType()
- {
- return _type;
- }
-
- public void
- setMember(String member)
- {
- _member = member;
- }
-
- public String
- getMember()
- {
- return _member;
- }
-
- public void
- setCasesensitive(boolean caseSensitive)
- {
- _caseSensitive = caseSensitive;
- }
-
- public boolean
- getCasesensitive()
- {
- return _caseSensitive;
- }
- }
-
- private java.util.List<Dict> _dicts = new java.util.LinkedList<Dict>();
- private java.util.List<Dictindex> _dictIndices = new java.util.LinkedList<Dictindex>();
- private java.util.List<Index> _indices = new java.util.LinkedList<Index>();
-}
diff --git a/java/src/ant-ice/Slice2JavaTask.java b/java/src/ant-ice/Slice2JavaTask.java
deleted file mode 100644
index e2ee6048525..00000000000
--- a/java/src/ant-ice/Slice2JavaTask.java
+++ /dev/null
@@ -1,422 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-//package Ice.Ant;
-
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.taskdefs.Execute;
-import org.apache.tools.ant.taskdefs.PumpStreamHandler;
-import org.apache.tools.ant.types.Commandline;
-import org.apache.tools.ant.types.Commandline.Argument;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.StringReader;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-
-/**
- * An ant task for slice2java. This task extends the abstract
- * SliceTask class which takes care of attributes common to all slice
- * translators (see SliceTask.java for details on these attributes).
- *
- * Attributes specific to slice2java:
- *
- * translator - The pathname of the translator (default: "slice2java").
- * tie - The value for the --tie translator option.
- * checksum - The value for the --checksum translator option.
- * stream - The value for the --stream translator option.
- *
- * Example:
- *
- * <project ...>
- * <taskdef name="slice2java" classname="Slice2JavaTask" />
- * <property name="slice.dir" value="../include/slice"/>
- * <target name="generate">
- * <mkdir dir="tags" />
- * <slice2java tagdir="tags" outputdir="out">
- * <define name="SYMBOL" value="VALUE"/>
- * <includepath>
- * <pathelement path="${slice.dir}" />
- * </includepath>
- * <fileset dir="${slice.dir}">
- * <include name="*.ice" />
- * </fileset>
- * </slice2java>
- * </target>
- * </project>
- *
- * The <taskdef> element installs the slice2java task.
- */
-public class Slice2JavaTask extends SliceTask
-{
- public
- Slice2JavaTask()
- {
- _translator = null;
- _tie = false;
- _checksum = null;
- }
-
- public void
- setTranslator(File prog)
- {
- _translator = prog;
- }
-
- public void
- setTie(boolean tie)
- {
- _tie = tie;
- }
-
- public void
- setChecksum(String checksum)
- {
- _checksum = checksum;
- }
-
- public void
- setStream(boolean stream)
- {
- _stream = stream;
- }
-
- public void
- execute()
- throws BuildException
- {
- if(_fileSets.isEmpty())
- {
- throw new BuildException("No fileset specified");
- }
-
- //
- // Read the set of dependencies for this task.
- //
- java.util.HashMap<String, SliceDependency> dependencies = readDependencies();
-
- //
- // Compose a list of the files that need to be translated. A
- // file needs to translated if we can't find a dependency in
- // the dependency table or if its dependency is not up-to-date
- // anymore (the slice file changed since the dependency was
- // last updated or a slice file it depends on changed).
- //
- java.util.HashSet<File> buildList = new java.util.HashSet<File>();
- java.util.HashSet<File> skipList = new java.util.HashSet<File>();
- for(FileSet fileset : _fileSets)
- {
- DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
- scanner.scan();
- String[] files = scanner.getIncludedFiles();
- for(String file : files)
- {
- File slice = new File(fileset.getDir(getProject()), file);
-
- SliceDependency depend = dependencies.get(getTargetKey(slice.toString()));
- if(depend == null || !depend.isUpToDate())
- {
- buildList.add(slice);
- }
- else
- {
- skipList.add(slice);
- }
- }
- }
-
- if(_checksum != null && _checksum.length() > 0 && !buildList.isEmpty())
- {
- //
- // Recompile all Slice files when checksums are used.
- //
- buildList.addAll(skipList);
- }
- else
- {
- for(File file : skipList)
- {
- log("skipping " + file.getName());
- }
- }
-
- //
- // Run the translator
- //
- if(!buildList.isEmpty())
- {
- String translator;
- if(_translator == null)
- {
- translator = getDefaultTranslator("slice2java");
- }
- else
- {
- translator = _translator.toString();
- }
-
- StringBuilder cmd = new StringBuilder(256);
-
- //
- // Add --output-dir
- //
- if(_outputDir != null)
- {
- cmd.append(" --output-dir ");
- cmd.append(_outputDirString);
- }
-
- //
- // Add include directives
- //
- if(_includePath != null)
- {
- String[] dirs = _includePath.list();
- for(String dir : dirs)
- {
- cmd.append(" -I");
- if(dir.indexOf(' ') != -1)
- {
- cmd.append('"');
- cmd.append(dir);
- cmd.append('"');
- }
- else
- {
- cmd.append(dir);
- }
- }
- }
-
- //
- // Add defines
- //
- if(!_defines.isEmpty())
- {
- for(SliceDefine define : _defines)
- {
- cmd.append(" -D");
- cmd.append(define.getName());
- String value = define.getValue();
- if(value != null)
- {
- cmd.append("=");
- cmd.append(value);
- }
- }
- }
-
- //
- // Add --tie
- //
- if(_tie)
- {
- cmd.append(" --tie");
- }
-
- //
- // Add --checksum
- //
- if(_checksum != null && _checksum.length() > 0)
- {
- cmd.append(" --checksum ");
- cmd.append(_checksum);
- }
-
- //
- // Add --stream
- //
- if(_stream)
- {
- cmd.append(" --stream");
- }
-
- //
- // Add --meta
- //
- if(!_meta.isEmpty())
- {
- for(SliceMeta m : _meta)
- {
- cmd.append(" --meta ");
- cmd.append(m.getValue());
- }
- }
-
- //
- // Add --ice
- //
- if(_ice)
- {
- cmd.append(" --ice");
- }
-
- //
- // Add --underscore
- //
- if(_underscore)
- {
- cmd.append(" --underscore");
- }
-
- //
- // Add files to be translated
- //
- for(File f : buildList)
- {
- cmd.append(" ");
- String s = f.toString();
- if(s.indexOf(' ') != -1)
- {
- cmd.append('"');
- cmd.append(s);
- cmd.append('"');
- }
- else
- {
- cmd.append(s);
- }
- }
-
- //
- // Execute
- //
- log(translator + " " + cmd);
- ExecTask task = (ExecTask)getProject().createTask("exec");
- addLdLibraryPath(task);
- task.setFailonerror(true);
- Argument arg = task.createArg();
- arg.setLine(cmd.toString());
- task.setExecutable(translator);
- task.execute();
-
- //
- // Update the dependencies.
- //
- cmd = new StringBuilder(256);
- cmd.append("--depend-xml");
-
- //
- // Add --ice
- //
- if(_ice)
- {
- cmd.append(" --ice");
- }
-
- //
- // Add --underscore
- //
- if(_underscore)
- {
- cmd.append(" --underscore");
- }
-
- //
- // Add include directives
- //
- if(_includePath != null)
- {
- String[] dirs = _includePath.list();
- for(String dir : dirs)
- {
- cmd.append(" -I");
- if(dir.indexOf(' ') != -1)
- {
- cmd.append('"');
- cmd.append(dir);
- cmd.append('"');
- }
- else
- {
- cmd.append(dir);
- }
- }
- }
-
- //
- // Add files for which we need to check dependencies.
- //
- for(File f : buildList)
- {
- cmd.append(" ");
- String s = f.toString();
- if(s.indexOf(' ') != -1)
- {
- cmd.append('"');
- cmd.append(s);
- cmd.append('"');
- }
- else
- {
- cmd.append(s);
- }
- }
-
- //
- // It's not possible anymore to re-use the same output property since Ant 1.5.x. so we use a
- // unique property name here. Perhaps we should output the dependencies to a file instead.
- //
- final String outputProperty = "slice2java.depend." + System.currentTimeMillis();
- final String errorProperty = "slice2java.error." + System.currentTimeMillis();
-
- task = (ExecTask)getProject().createTask("exec");
- addLdLibraryPath(task);
- task.setFailonerror(true);
- arg = task.createArg();
- arg.setLine(cmd.toString());
- task.setExecutable(translator);
- task.setOutputproperty(outputProperty);
- task.setErrorProperty(errorProperty);
- task.execute();
-
- //
- // Update dependency file.
- //
- java.util.List<SliceDependency> newDependencies =
- parseDependencies(getProject().getProperty(outputProperty));
- for(SliceDependency dep : newDependencies)
- {
- dependencies.put(getTargetKey(dep._dependencies[0]), dep);
- }
-
- writeDependencies(dependencies);
- }
- }
-
- private String
- getTargetKey(String slice)
- {
- //
- // Since the dependency file can be shared by several slice
- // tasks we need to make sure that each dependency has a
- // unique key. We use the name of the task, the output
- // directory and the name of the slice file to be compiled.
- //
- // If there's two slice2java tasks using the same dependency
- // file, with the same output dir and which compiles the same
- // slice file they'll use the same dependency.
- //
- return "slice2java " + _outputDir.toString() + " " + slice;
- }
-
- private File _translator;
- private boolean _tie;
- private String _checksum;
- private boolean _stream;
-}
diff --git a/java/src/ant-ice/SliceDefine.java b/java/src/ant-ice/SliceDefine.java
deleted file mode 100644
index d8863994301..00000000000
--- a/java/src/ant-ice/SliceDefine.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-//package Ice.Ant;
-
-public class SliceDefine
-{
- public void
- setName(String name)
- {
- _name = name;
- }
-
- public String
- getName()
- {
- return _name;
- }
-
- public void
- setValue(String value)
- {
- _value = value;
- }
-
- public String
- getValue()
- {
- return _value;
- }
-
- private String _name;
- private String _value;
-}
diff --git a/java/src/ant-ice/SliceMeta.java b/java/src/ant-ice/SliceMeta.java
deleted file mode 100644
index 665938159aa..00000000000
--- a/java/src/ant-ice/SliceMeta.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-public class SliceMeta
-{
- public void
- setValue(String value)
- {
- _value = value;
- }
-
- public String
- getValue()
- {
- return _value;
- }
-
- private String _value;
-}
diff --git a/java/src/ant-ice/SliceTask.java b/java/src/ant-ice/SliceTask.java
deleted file mode 100644
index 64df914e56c..00000000000
--- a/java/src/ant-ice/SliceTask.java
+++ /dev/null
@@ -1,561 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-//package Ice.Ant;
-
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.taskdefs.Execute;
-import org.apache.tools.ant.taskdefs.PumpStreamHandler;
-import org.apache.tools.ant.types.Commandline;
-import org.apache.tools.ant.types.Environment;
-import org.apache.tools.ant.types.Commandline.Argument;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.StringReader;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.SAXException;
-
-/**
- * An abstract ant task for slice translators. The task minimizes
- * regeneration by checking the dependencies between slice files.
- *
- * Attributes:
- *
- * dependencyfile - The file in which dependencies are stored (default: ".depend").
- * outputdir - The value for the --output-dir translator option.
- * ice - Enables the --ice translator option.
- * underscore - Enables the --underscore translator option.
- *
- * Nested elements:
- *
- * includepath - The directories in which to search for Slice files.
- * These are converted into -I directives for the translator.
- * define - Defines a preprocessor symbol. The "name" attribute
- * specifies the symbol name, and the optional "value" attribute
- * specifies the symbol's value.
- * fileset - The set of Slice files which contain relevent types.
- *
- */
-public class SliceTask extends org.apache.tools.ant.Task
-{
- public
- SliceTask()
- {
- _dependencyFile = null;
- _outputDir = null;
- _outputDirString = null;
- _ice = false;
- _includePath = null;
- }
-
- public void
- setDependencyFile(File file)
- {
- _dependencyFile = file;
- }
-
- public void
- setOutputdir(File dir)
- {
- _outputDir = dir;
- _outputDirString = _outputDir.toString();
- if(_outputDirString.indexOf(' ') != -1)
- {
- _outputDirString = '"' + _outputDirString + '"';
- }
- }
-
- public void
- setIce(boolean ice)
- {
- _ice = ice;
- }
-
- public void
- setUnderscore(boolean underscore)
- {
- _underscore = underscore;
- }
-
- public Path
- createIncludePath()
- {
- if(_includePath == null)
- {
- _includePath = new Path(getProject());
- }
- return _includePath.createPath();
- }
-
- public void
- setIncludePathRef(Reference ref)
- {
- createIncludePath().setRefid(ref);
- }
-
- public void
- setIncludePath(Path includePath)
- {
- if(_includePath == null)
- {
- _includePath = includePath;
- }
- else
- {
- _includePath.append(includePath);
- }
- }
-
- public FileSet
- createFileset()
- {
- FileSet fileset = new FileSet();
- _fileSets.add(fileset);
-
- return fileset;
- }
-
- public void
- addConfiguredDefine(SliceDefine define)
- throws BuildException
- {
- if(define.getName() == null)
- {
- throw new BuildException("The name attribute must be supplied in a <define> element");
- }
-
- _defines.add(define);
- }
-
- public void
- addConfiguredMeta(SliceMeta meta)
- {
- if(meta.getValue().length() > 0)
- {
- _meta.add(meta);
- }
- }
-
- //
- // Read the dependency file.
- //
- @SuppressWarnings("unchecked")
- protected java.util.HashMap<String, SliceDependency>
- readDependencies()
- {
- if(_dependencyFile == null)
- {
- if(_outputDir != null)
- {
- _dependencyFile = new File(_outputDir, ".depend");
- }
- else
- {
- _dependencyFile = new File(".depend");
- }
- }
-
- try
- {
- java.io.ObjectInputStream in = new java.io.ObjectInputStream(new java.io.FileInputStream(_dependencyFile));
- java.util.HashMap<String, SliceDependency> dependencies =
- (java.util.HashMap<String, SliceDependency>)in.readObject();
- in.close();
- return dependencies;
- }
- catch(java.io.IOException ex)
- {
- }
- catch(java.lang.ClassNotFoundException ex)
- {
- }
-
- return new java.util.HashMap<String, SliceDependency>();
- }
-
- protected void
- writeDependencies(java.util.HashMap<String, SliceDependency> dependencies)
- {
- try
- {
- java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(new FileOutputStream(_dependencyFile));
- out.writeObject(dependencies);
- out.close();
- }
- catch(java.io.IOException ex)
- {
- throw new BuildException("Unable to write dependencies in file " + _dependencyFile.getPath() + ": " + ex);
- }
- }
-
- //
- // Parse dependencies returned by the slice translator (Makefile
- // dependencies).
- //
- protected java.util.List<SliceDependency>
- parseDependencies(String allDependencies)
- {
- Slice2JavaDependenciesParser parser = new Slice2JavaDependenciesParser();
- try
- {
- InputStream in = new ByteArrayInputStream(allDependencies.getBytes());
- Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new BufferedInputStream(in));
- parser.visit(doc);
- }
- catch(SAXException ex)
- {
- throw new BuildException("Unable to read dependencies from slice translator: " + ex);
- }
- catch(ParserConfigurationException ex)
- {
- throw new BuildException("Unable to read dependencies from slice translator: " + ex);
- }
- catch(java.io.IOException ex)
- {
- throw new BuildException("Unable to read dependencies from slice translator: " + ex);
- }
-
- return parser.dependencies;
- }
-
- protected String
- getDefaultTranslator(String name)
- {
- String iceInstall = getIceHome();
- if(iceInstall != null)
- {
- return new File(iceInstall + File.separator + "bin" + File.separator + name).toString();
- }
- else
- {
- //
- // If the location of the Ice install is not known, we
- // rely on a path search to find the translator.
- //
- return name;
- }
- }
-
- protected void
- addLdLibraryPath(ExecTask task)
- {
- String iceInstall = getIceHome();
- boolean srcdist = getProject().getProperties().containsKey("ice.src.dist");
- if(iceInstall != null)
- {
- String ldLibPathEnv = null;
- String ldLib64PathEnv = null;
- String libPath = new File(iceInstall + File.separator + "lib").toString();
- String lib64Path = null;
-
- String os = System.getProperty("os.name");
- if(os.equals("Mac OS X"))
- {
- ldLibPathEnv = "DYLD_LIBRARY_PATH";
- }
- else if(os.equals("AIX"))
- {
- ldLibPathEnv = "LIBPATH";
- }
- else if(os.equals("HP-UX"))
- {
- ldLibPathEnv = "SHLIB_PATH";
- ldLib64PathEnv = "LD_LIBRARY_PATH";
- if(srcdist)
- {
- lib64Path = libPath;
- }
- else
- {
- lib64Path = new File(iceInstall + File.separator + "lib" + File.separator + "pa20_64").toString();
- }
- }
- else if(os.startsWith("Windows"))
- {
- //
- // No need to change the PATH environment variable on Windows, the DLLs should be found
- // in the translator local directory.
- //
- //ldLibPathEnv = "PATH";
- }
- else if(os.equals("SunOS"))
- {
- ldLibPathEnv = "LD_LIBRARY_PATH";
- ldLib64PathEnv = "LD_LIBRARY_PATH_64";
- String arch = System.getProperty("os.arch");
- if(srcdist)
- {
- lib64Path = libPath;
- }
- else if(arch.equals("x86"))
- {
- lib64Path = new File(iceInstall + File.separator + "lib" + File.separator + "amd64").toString();
- }
- else // Sparc
- {
- lib64Path = new File(iceInstall + File.separator + "lib" + File.separator + "sparcv9").toString();
- }
- }
- else
- {
- ldLibPathEnv = "LD_LIBRARY_PATH";
- ldLib64PathEnv = "LD_LIBRARY_PATH";
- if(srcdist)
- {
- lib64Path = libPath;
- }
- else
- {
- lib64Path = new File(iceInstall + File.separator + "lib64").toString();
- }
- }
-
- if(ldLibPathEnv != null)
- {
- if(ldLibPathEnv.equals(ldLib64PathEnv))
- {
- libPath = libPath + File.pathSeparator + lib64Path;
- }
-
- String envLibPath = getEnvironment(ldLibPathEnv);
- if(envLibPath != null)
- {
- libPath = libPath + File.pathSeparator + envLibPath;
- }
-
- Environment.Variable v = new Environment.Variable();
- v.setKey(ldLibPathEnv);
- v.setValue(libPath);
- task.addEnv(v);
- }
-
- if(ldLib64PathEnv != null && !ldLib64PathEnv.equals(ldLibPathEnv))
- {
- String envLib64Path = getEnvironment(ldLib64PathEnv);
- if(envLib64Path != null)
- {
- lib64Path = lib64Path + File.pathSeparator + envLib64Path;
- }
-
- Environment.Variable v = new Environment.Variable();
- v.setKey(ldLib64PathEnv);
- v.setValue(lib64Path);
- task.addEnv(v);
- }
- }
- }
-
- //
- // Query for the location of the Ice install. The Ice install
- // location may be indicated in one of two ways:
- //
- // 1. Through the ice.home property
- // 2. Through the ICE_HOME environment variable.
- //
- // If both the property and environment variable is specified, the
- // property takes precedence. If neither is available, getIceHome()
- // returns null.
- //
- protected String
- getIceHome()
- {
- if(_iceHome == null)
- {
- if(getProject().getProperties().containsKey("ice.home"))
- {
- _iceHome = (String)getProject().getProperties().get("ice.home");
- }
- else
- {
- _iceHome = getEnvironment("ICE_HOME");
- }
- }
- return _iceHome;
- }
-
- //
- // A slice dependency.
- //
- // * the _timeStamp attribute contains the last time the slice
- // file was compiled.
- //
- // * the _dependencies attribute contains an array with all the
- // files this slice file depends on.
- //
- // This dependency represents the dependencies for the slice file
- // _dependencies[0].
- //
- protected class SliceDependency implements java.io.Serializable
- {
- private void writeObject(java.io.ObjectOutputStream out)
- throws java.io.IOException
- {
- out.writeObject(_dependencies);
- out.writeLong(_timeStamp);
- }
-
- private void readObject(java.io.ObjectInputStream in)
- throws java.io.IOException, java.lang.ClassNotFoundException
- {
- _dependencies = (String[])in.readObject();
- _timeStamp = in.readLong();
- }
-
- public boolean
- isUpToDate()
- {
- for(String d : _dependencies)
- {
- File dep = new File(d);
- if(!dep.exists() || _timeStamp < dep.lastModified())
- {
- return false;
- }
- }
-
- return true;
- }
-
- public String[] _dependencies;
- public long _timeStamp;
- public static final long serialVersionUID = 0L;
- }
-
- @SuppressWarnings("deprecation")
- private String
- getEnvironment(String key)
- {
- java.util.Vector env = Execute.getProcEnvironment();
- java.util.Enumeration e = env.elements();
- while(e.hasMoreElements())
- {
- String entry = (String)e.nextElement();
- if(entry.startsWith(key + "="))
- {
- return entry.substring(entry.indexOf('=') + 1);
- }
- }
- return null;
- }
-
- private class Slice2JavaDependenciesParser
- {
- java.util.List<SliceDependency> dependencies = new java.util.LinkedList<SliceDependency>();
-
- private Node findNode(Node n, String qName)
- throws SAXException
- {
- NodeList children = n.getChildNodes();
- for(int i = 0; i < children.getLength(); ++i)
- {
- Node child = children.item(i);
- if(child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(qName))
- {
- return child;
- }
- }
- throw new SAXException("no such node: " + qName);
- }
-
- private void visitDependencies(Node n) throws SAXException
- {
- NodeList children = n.getChildNodes();
- for(int i = 0; i < children.getLength(); ++i)
- {
- if(children.item(i).getNodeType() == Node.ELEMENT_NODE && children.item(i).getNodeName().equals("source"))
- {
- String source = ((Element)children.item(i)).getAttribute("name");
- if(source.length() == 0)
- {
- throw new SAXException("empty name attribute");
- }
- List<String> dependsOn = visitDependsOn(children.item(i));
- SliceDependency depend = new SliceDependency();
- depend._timeStamp = new java.util.Date().getTime();
- depend._dependencies = new String[dependsOn.size() + 1];
- depend._dependencies[0] = source;
- for(int j = 0; j < dependsOn.size(); j++)
- {
- depend._dependencies[j + 1] = dependsOn.get(j);
- }
- dependencies.add(depend);
- }
- }
- }
-
- private List<String> visitDependsOn(Node source) throws SAXException
- {
- List<String> depends = new ArrayList<String>();
- NodeList dependencies = source.getChildNodes();
- for(int j = 0; j < dependencies.getLength(); ++j)
- {
- if(dependencies.item(j).getNodeType() == Node.ELEMENT_NODE && dependencies.item(j).getNodeName().equals("dependsOn"))
- {
- Element dependsOn = (Element)dependencies.item(j);
- String name = dependsOn.getAttribute("name");
- if(name.length() == 0)
- {
- throw new SAXException("empty name attribute");
- }
- depends.add(name);
- }
- }
- return depends;
- }
-
- public void visit(Node doc) throws SAXException
- {
- Node n = findNode(doc, "dependencies");
- visitDependencies(n);
- }
- }
-
- protected File _dependencyFile;
- protected File _outputDir;
- protected String _outputDirString;
- protected boolean _ice;
- protected boolean _underscore;
- protected Path _includePath;
- protected java.util.List<FileSet> _fileSets = new java.util.LinkedList<FileSet>();
- protected java.util.List<SliceDefine> _defines = new java.util.LinkedList<SliceDefine>();
- protected java.util.List<SliceMeta> _meta = new java.util.LinkedList<SliceMeta>();
- private String _iceHome;
-}
diff --git a/java/src/ant-ice/build.gradle b/java/src/ant-ice/build.gradle
deleted file mode 100644
index 257c183b3b6..00000000000
--- a/java/src/ant-ice/build.gradle
+++ /dev/null
@@ -1,28 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-sourceCompatibility = iceSourceCompatibility
-targetCompatibility = iceTargetCompatibility
-
-repositories {
- mavenCentral()
-}
-sourceSets {
- main {
- java {
- srcDir '.'
- }
- }
-}
-
-dependencies {
- compile 'org.apache.ant:ant:1.9.4'
-}
-
-apply from: "$rootProject.projectDir/gradle/library.gradle"