Details
Description
Hi
the element <parsable> is working on a single file while it would be adviseable to make it running over a set of files defined for example by an embedded <fileset> element. A usage of this extension would be to allow cross references of separate javadocs by updating the "href" URL in each javadoc.html of the referee.
Rgds
-
- IZPACK-394.diff
- 01/Nov/09 3:21 PM
- 15 kB
- Julien Ponge
Activity
Hide
Laurian Vostinar
added a comment -
I improved the patch a bit:
"patch.txt"
### Eclipse Workspace Patch 1.0
#P IzPack
Index: src/lib/com/izforge/izpack/compiler/CompilerConfig.java
===================================================================
--- src/lib/com/izforge/izpack/compiler/CompilerConfig.java (revision 2826)
+++ src/lib/com/izforge/izpack/compiler/CompilerConfig.java (working copy)
@@ -710,14 +710,48 @@
while (iter.hasNext())
{
IXMLElement p = iter.next();
- String target = requireAttribute(p, "targetfile");
+ String target = p.getAttribute("targetfile", null);
String type = p.getAttribute("type", "plain");
String encoding = p.getAttribute("encoding", null);
List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified
String condition = p.getAttribute("condition");
- ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
- parsable.setCondition(condition);
- pack.addParsable(parsable);
+ if (target != null)
+ {
+ ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
+ parsable.setCondition(condition);
+ pack.addParsable(parsable);
+ }
+ Iterator<IXMLElement> iterSet = p.getChildrenNamed("fileset").iterator();
+ while (iterSet.hasNext())
+ {
+ IXMLElement f = iterSet.next();
+ String targetdir = requireAttribute(f, "targetdir");
+ String dir_attr = requireAttribute(f, "dir");
+ File dir = new File(dir_attr);
+ if (!dir.isAbsolute())
+ {
+ dir = new File(basedir, dir_attr);
+ }
+ if (!dir.isDirectory()) // also tests '.exists()'
+ {
+ parseError(f, "Invalid directory 'dir': " + dir_attr);
+ }
+ String []includedFiles = getFilesetIncludedFiles(f);
+ if (includedFiles != null)
+ {
+ for (String filePath:includedFiles)
+ {
+ File file = new File(dir,filePath);
+ if (file.exists() && file.isFile())
+ {
+ String targetFile = new File(targetdir, filePath).getPath().replace(File.separatorChar, '/');
+ ParsableFile parsable = new ParsableFile(targetFile, type, encoding, osList);
+ parsable.setCondition(condition);
+ pack.addParsable(parsable);
+ }
+ }
+ }
+ }
}
// We get the executables list
@@ -872,8 +906,8 @@
while (iter.hasNext())
{
IXMLElement f = iter.next();
+ String targetdir = requireAttribute(f, "targetdir");
String dir_attr = requireAttribute(f, "dir");
-
File dir = new File(dir_attr);
if (!dir.isAbsolute())
{
@@ -883,127 +917,28 @@
{
parseError(f, "Invalid directory 'dir': " + dir_attr);
}
-
- boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES);
- boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes", YES);
- String targetdir = requireAttribute(f, "targetdir");
+ String []includedFiles = getFilesetIncludedFiles(f);
List<OsConstraint> osList = OsConstraint.getOsList(f); // TODO: unverified
int override = getOverrideValue(f);
Map additionals = getAdditionals(f);
String condition = f.getAttribute("condition");
-
- // get includes and excludes
- Vector<IXMLElement> xcludesList = null;
- String[] includes = null;
- xcludesList = f.getChildrenNamed("include");
- if (!xcludesList.isEmpty())
+ if (includedFiles != null)
{
- includes = new String[xcludesList.size()];
- for (int j = 0; j < xcludesList.size(); j++)
+ for (String filePath:includedFiles)
{
- IXMLElement xclude = xcludesList.get(j);
- includes[j] = requireAttribute(xclude, "name");
- }
- }
- String[] excludes = null;
- xcludesList = f.getChildrenNamed("exclude");
- if (!xcludesList.isEmpty())
- {
- excludes = new String[xcludesList.size()];
- for (int j = 0; j < xcludesList.size(); j++)
- {
- IXMLElement xclude = xcludesList.get(j);
- excludes[j] = requireAttribute(xclude, "name");
- }
- }
-
- // parse additional fileset attributes "includes" and "excludes"
- String[] toDo = new String[]{"includes", "excludes"};
- // use the existing containers filled from include and exclude
- // and add the includes and excludes to it
- String[][] containers = new String[][]{includes, excludes};
- for (int j = 0; j < toDo.length; ++j)
- {
- String inex = f.getAttribute(toDo[j]);
- if (inex != null && inex.length() > 0)
- { // This is the same "splitting" as ant PatternSet do ...
- StringTokenizer tok = new StringTokenizer(inex, ", ", false);
- int newSize = tok.countTokens();
- int k = 0;
- String[] nCont = null;
- if (containers[j] != null && containers[j].length > 0)
- { // old container exist; create a new which can hold
- // all values
- // and copy the old stuff to the front
- newSize += containers[j].length;
- nCont = new String[newSize];
- for (; k < containers[j].length; ++k)
- {
- nCont[k] = containers[j][k];
- }
- }
- if (nCont == null) // No container for old values
- // created,
- // create a new one.
+ try
{
- nCont = new String[newSize];
+ File file = new File(dir,filePath);
+ String target = new File(targetdir, filePath).getPath();
+ pack.addFile(baseDir, file, target, osList, override,
+ additionals, condition);
}
- for (; k < newSize; ++k)
- // Fill the new one or expand the existent container
+ catch (FileNotFoundException x)
{
- nCont[k] = tok.nextToken();
+ parseError(f, x.getMessage(), x);
}
- containers[j] = nCont;
}
}
- includes = containers[0]; // push the new includes to the
- // local var
- excludes = containers[1]; // push the new excludes to the
- // local var
-
- // scan and add fileset
- DirectoryScanner ds = new DirectoryScanner();
- ds.setIncludes(includes);
- ds.setExcludes(excludes);
- if (defexcludes)
- {
- ds.addDefaultExcludes();
- }
- ds.setBasedir(dir);
- ds.setCaseSensitive(casesensitive);
- ds.scan();
-
- String[] files = ds.getIncludedFiles();
- String[] dirs = ds.getIncludedDirectories();
-
- // Directory scanner has done recursion, add files and
- // directories
- for (String file : files)
- {
- try
- {
- String target = new File(targetdir, file).getPath();
- pack.addFile(baseDir, new File(dir, file), target, osList, override,
- additionals, condition);
- }
- catch (FileNotFoundException x)
- {
- parseError(f, x.getMessage(), x);
- }
- }
- for (String dir1 : dirs)
- {
- try
- {
- String target = new File(targetdir, dir1).getPath();
- pack.addFile(baseDir, new File(dir, dir1), target, osList, override,
- additionals, condition);
- }
- catch (FileNotFoundException x)
- {
- parseError(f, x.getMessage(), x);
- }
- }
}
// get the updatechecks list
@@ -1119,7 +1054,120 @@
notifyCompilerListener("addPacksSingle", CompilerListener.END, data);
}
+ private String[] getFilesetIncludedFiles(IXMLElement f) throws CompilerException
+ {
+ List<String> includedFiles = new ArrayList<String>();
+ String dir_attr = requireAttribute(f, "dir");
+ File dir = new File(dir_attr);
+ if (!dir.isAbsolute())
+ {
+ dir = new File(basedir, dir_attr);
+ }
+ if (!dir.isDirectory()) // also tests '.exists()'
+ {
+ parseError(f, "Invalid directory 'dir': " + dir_attr);
+ }
+
+ boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES);
+ boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes", YES);
+
+ // get includes and excludes
+ Vector<IXMLElement> xcludesList = null;
+ String[] includes = null;
+ xcludesList = f.getChildrenNamed("include");
+ if (!xcludesList.isEmpty())
+ {
+ includes = new String[xcludesList.size()];
+ for (int j = 0; j < xcludesList.size(); j++)
+ {
+ IXMLElement xclude = xcludesList.get(j);
+ includes[j] = requireAttribute(xclude, "name");
+ }
+ }
+ String[] excludes = null;
+ xcludesList = f.getChildrenNamed("exclude");
+ if (!xcludesList.isEmpty())
+ {
+ excludes = new String[xcludesList.size()];
+ for (int j = 0; j < xcludesList.size(); j++)
+ {
+ IXMLElement xclude = xcludesList.get(j);
+ excludes[j] = requireAttribute(xclude, "name");
+ }
+ }
+
+ // parse additional fileset attributes "includes" and "excludes"
+ String[] toDo = new String[]{"includes", "excludes"};
+ // use the existing containers filled from include and exclude
+ // and add the includes and excludes to it
+ String[][] containers = new String[][]{includes, excludes};
+ for (int j = 0; j < toDo.length; ++j)
+ {
+ String inex = f.getAttribute(toDo[j]);
+ if (inex != null && inex.length() > 0)
+ { // This is the same "splitting" as ant PatternSet do ...
+ StringTokenizer tok = new StringTokenizer(inex, ", ", false);
+ int newSize = tok.countTokens();
+ int k = 0;
+ String[] nCont = null;
+ if (containers[j] != null && containers[j].length > 0)
+ { // old container exist; create a new which can hold
+ // all values
+ // and copy the old stuff to the front
+ newSize += containers[j].length;
+ nCont = new String[newSize];
+ for (; k < containers[j].length; ++k)
+ {
+ nCont[k] = containers[j][k];
+ }
+ }
+ if (nCont == null) // No container for old values
+ // created,
+ // create a new one.
+ {
+ nCont = new String[newSize];
+ }
+ for (; k < newSize; ++k)
+ // Fill the new one or expand the existent container
+ {
+ nCont[k] = tok.nextToken();
+ }
+ containers[j] = nCont;
+ }
+ }
+ includes = containers[0]; // push the new includes to the
+ // local var
+ excludes = containers[1]; // push the new excludes to the
+ // local var
+
+ // scan and add fileset
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(includes);
+ ds.setExcludes(excludes);
+ if (defexcludes)
+ {
+ ds.addDefaultExcludes();
+ }
+ ds.setBasedir(dir);
+ ds.setCaseSensitive(casesensitive);
+ ds.scan();
+
+ String[] files = ds.getIncludedFiles();
+ String[] dirs = ds.getIncludedDirectories();
+
+ // Directory scanner has done recursion, add files and
+ // directories
+ for (String file : files)
+ {
+ includedFiles.add( file);
+ }
+ for (String dir1 : dirs)
+ {
+ includedFiles.add( dir1);
+ }
+ return includedFiles.toArray(new String[]{});
+ }
private IXMLElement readRefPackData(String refFileName, boolean isselfcontained)
throws CompilerException {
File refXMLFile = new File(refFileName);
Index: src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java
===================================================================
--- src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (revision 2811)
+++ src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (working copy)
@@ -357,12 +357,14 @@
while (iter.hasNext())
{
IXMLElement p = iter.next();
- String target = requireAttribute(p, "targetfile");
+ String target = p.getAttribute("targetfile", null);
String type = p.getAttribute("type", "plain");
String encoding = p.getAttribute("encoding", null);
List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified
-
- pack.addParsable(new ParsableFile(target, type, encoding, osList));
+ if (target != null)
+ {
+ pack.addParsable(new ParsableFile(target, type, encoding, osList));
+ }
}
// We get the executables list
Show
Laurian Vostinar
added a comment - I improved the patch a bit:
"patch.txt"
### Eclipse Workspace Patch 1.0
#P IzPack
Index: src/lib/com/izforge/izpack/compiler/CompilerConfig.java
===================================================================
--- src/lib/com/izforge/izpack/compiler/CompilerConfig.java (revision 2826)
+++ src/lib/com/izforge/izpack/compiler/CompilerConfig.java (working copy)
@@ -710,14 +710,48 @@
while (iter.hasNext())
{
IXMLElement p = iter.next();
- String target = requireAttribute(p, "targetfile" );
+ String target = p.getAttribute( "targetfile" , null );
String type = p.getAttribute( "type" , "plain" );
String encoding = p.getAttribute( "encoding" , null );
List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified
String condition = p.getAttribute( "condition" );
- ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
- parsable.setCondition(condition);
- pack.addParsable(parsable);
+ if (target != null )
+ {
+ ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
+ parsable.setCondition(condition);
+ pack.addParsable(parsable);
+ }
+ Iterator<IXMLElement> iterSet = p.getChildrenNamed( "fileset" ).iterator();
+ while (iterSet.hasNext())
+ {
+ IXMLElement f = iterSet.next();
+ String targetdir = requireAttribute(f, "targetdir" );
+ String dir_attr = requireAttribute(f, "dir" );
+ File dir = new File(dir_attr);
+ if (!dir.isAbsolute())
+ {
+ dir = new File(basedir, dir_attr);
+ }
+ if (!dir.isDirectory()) // also tests '.exists()'
+ {
+ parseError(f, "Invalid directory 'dir': " + dir_attr);
+ }
+ String []includedFiles = getFilesetIncludedFiles(f);
+ if (includedFiles != null )
+ {
+ for ( String filePath:includedFiles)
+ {
+ File file = new File(dir,filePath);
+ if (file.exists() && file.isFile())
+ {
+ String targetFile = new File(targetdir, filePath).getPath().replace(File.separatorChar, '/');
+ ParsableFile parsable = new ParsableFile(targetFile, type, encoding, osList);
+ parsable.setCondition(condition);
+ pack.addParsable(parsable);
+ }
+ }
+ }
+ }
}
// We get the executables list
@@ -872,8 +906,8 @@
while (iter.hasNext())
{
IXMLElement f = iter.next();
+ String targetdir = requireAttribute(f, "targetdir" );
String dir_attr = requireAttribute(f, "dir" );
-
File dir = new File(dir_attr);
if (!dir.isAbsolute())
{
@@ -883,127 +917,28 @@
{
parseError(f, "Invalid directory 'dir': " + dir_attr);
}
-
- boolean casesensitive = validateYesNoAttribute(f, "casesensitive" , YES);
- boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes" , YES);
- String targetdir = requireAttribute(f, "targetdir" );
+ String []includedFiles = getFilesetIncludedFiles(f);
List<OsConstraint> osList = OsConstraint.getOsList(f); // TODO: unverified
int override = getOverrideValue(f);
Map additionals = getAdditionals(f);
String condition = f.getAttribute( "condition" );
-
- // get includes and excludes
- Vector<IXMLElement> xcludesList = null ;
- String [] includes = null ;
- xcludesList = f.getChildrenNamed( "include" );
- if (!xcludesList.isEmpty())
+ if (includedFiles != null )
{
- includes = new String [xcludesList.size()];
- for ( int j = 0; j < xcludesList.size(); j++)
+ for ( String filePath:includedFiles)
{
- IXMLElement xclude = xcludesList.get(j);
- includes[j] = requireAttribute(xclude, "name" );
- }
- }
- String [] excludes = null ;
- xcludesList = f.getChildrenNamed( "exclude" );
- if (!xcludesList.isEmpty())
- {
- excludes = new String [xcludesList.size()];
- for ( int j = 0; j < xcludesList.size(); j++)
- {
- IXMLElement xclude = xcludesList.get(j);
- excludes[j] = requireAttribute(xclude, "name" );
- }
- }
-
- // parse additional fileset attributes "includes" and "excludes"
- String [] toDo = new String []{ "includes" , "excludes" };
- // use the existing containers filled from include and exclude
- // and add the includes and excludes to it
- String [][] containers = new String [][]{includes, excludes};
- for ( int j = 0; j < toDo.length; ++j)
- {
- String inex = f.getAttribute(toDo[j]);
- if (inex != null && inex.length() > 0)
- { // This is the same "splitting" as ant PatternSet do ...
- StringTokenizer tok = new StringTokenizer(inex, ", " , false );
- int newSize = tok.countTokens();
- int k = 0;
- String [] nCont = null ;
- if (containers[j] != null && containers[j].length > 0)
- { // old container exist; create a new which can hold
- // all values
- // and copy the old stuff to the front
- newSize += containers[j].length;
- nCont = new String [newSize];
- for (; k < containers[j].length; ++k)
- {
- nCont[k] = containers[j][k];
- }
- }
- if (nCont == null ) // No container for old values
- // created,
- // create a new one.
+ try
{
- nCont = new String [newSize];
+ File file = new File(dir,filePath);
+ String target = new File(targetdir, filePath).getPath();
+ pack.addFile(baseDir, file, target, osList, override,
+ additionals, condition);
}
- for (; k < newSize; ++k)
- // Fill the new one or expand the existent container
+ catch (FileNotFoundException x)
{
- nCont[k] = tok.nextToken();
+ parseError(f, x.getMessage(), x);
}
- containers[j] = nCont;
}
}
- includes = containers[0]; // push the new includes to the
- // local var
- excludes = containers[1]; // push the new excludes to the
- // local var
-
- // scan and add fileset
- DirectoryScanner ds = new DirectoryScanner();
- ds.setIncludes(includes);
- ds.setExcludes(excludes);
- if (defexcludes)
- {
- ds.addDefaultExcludes();
- }
- ds.setBasedir(dir);
- ds.setCaseSensitive(casesensitive);
- ds.scan();
-
- String [] files = ds.getIncludedFiles();
- String [] dirs = ds.getIncludedDirectories();
-
- // Directory scanner has done recursion, add files and
- // directories
- for ( String file : files)
- {
- try
- {
- String target = new File(targetdir, file).getPath();
- pack.addFile(baseDir, new File(dir, file), target, osList, override,
- additionals, condition);
- }
- catch (FileNotFoundException x)
- {
- parseError(f, x.getMessage(), x);
- }
- }
- for ( String dir1 : dirs)
- {
- try
- {
- String target = new File(targetdir, dir1).getPath();
- pack.addFile(baseDir, new File(dir, dir1), target, osList, override,
- additionals, condition);
- }
- catch (FileNotFoundException x)
- {
- parseError(f, x.getMessage(), x);
- }
- }
}
// get the updatechecks list
@@ -1119,7 +1054,120 @@
notifyCompilerListener( "addPacksSingle" , CompilerListener.END, data);
}
+ private String [] getFilesetIncludedFiles(IXMLElement f) throws CompilerException
+ {
+ List< String > includedFiles = new ArrayList< String >();
+ String dir_attr = requireAttribute(f, "dir" );
+ File dir = new File(dir_attr);
+ if (!dir.isAbsolute())
+ {
+ dir = new File(basedir, dir_attr);
+ }
+ if (!dir.isDirectory()) // also tests '.exists()'
+ {
+ parseError(f, "Invalid directory 'dir': " + dir_attr);
+ }
+
+ boolean casesensitive = validateYesNoAttribute(f, "casesensitive" , YES);
+ boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes" , YES);
+
+ // get includes and excludes
+ Vector<IXMLElement> xcludesList = null ;
+ String [] includes = null ;
+ xcludesList = f.getChildrenNamed( "include" );
+ if (!xcludesList.isEmpty())
+ {
+ includes = new String [xcludesList.size()];
+ for ( int j = 0; j < xcludesList.size(); j++)
+ {
+ IXMLElement xclude = xcludesList.get(j);
+ includes[j] = requireAttribute(xclude, "name" );
+ }
+ }
+ String [] excludes = null ;
+ xcludesList = f.getChildrenNamed( "exclude" );
+ if (!xcludesList.isEmpty())
+ {
+ excludes = new String [xcludesList.size()];
+ for ( int j = 0; j < xcludesList.size(); j++)
+ {
+ IXMLElement xclude = xcludesList.get(j);
+ excludes[j] = requireAttribute(xclude, "name" );
+ }
+ }
+
+ // parse additional fileset attributes "includes" and "excludes"
+ String [] toDo = new String []{ "includes" , "excludes" };
+ // use the existing containers filled from include and exclude
+ // and add the includes and excludes to it
+ String [][] containers = new String [][]{includes, excludes};
+ for ( int j = 0; j < toDo.length; ++j)
+ {
+ String inex = f.getAttribute(toDo[j]);
+ if (inex != null && inex.length() > 0)
+ { // This is the same "splitting" as ant PatternSet do ...
+ StringTokenizer tok = new StringTokenizer(inex, ", " , false );
+ int newSize = tok.countTokens();
+ int k = 0;
+ String [] nCont = null ;
+ if (containers[j] != null && containers[j].length > 0)
+ { // old container exist; create a new which can hold
+ // all values
+ // and copy the old stuff to the front
+ newSize += containers[j].length;
+ nCont = new String [newSize];
+ for (; k < containers[j].length; ++k)
+ {
+ nCont[k] = containers[j][k];
+ }
+ }
+ if (nCont == null ) // No container for old values
+ // created,
+ // create a new one.
+ {
+ nCont = new String [newSize];
+ }
+ for (; k < newSize; ++k)
+ // Fill the new one or expand the existent container
+ {
+ nCont[k] = tok.nextToken();
+ }
+ containers[j] = nCont;
+ }
+ }
+ includes = containers[0]; // push the new includes to the
+ // local var
+ excludes = containers[1]; // push the new excludes to the
+ // local var
+
+ // scan and add fileset
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(includes);
+ ds.setExcludes(excludes);
+ if (defexcludes)
+ {
+ ds.addDefaultExcludes();
+ }
+ ds.setBasedir(dir);
+ ds.setCaseSensitive(casesensitive);
+ ds.scan();
+
+ String [] files = ds.getIncludedFiles();
+ String [] dirs = ds.getIncludedDirectories();
+
+ // Directory scanner has done recursion, add files and
+ // directories
+ for ( String file : files)
+ {
+ includedFiles.add( file);
+ }
+ for ( String dir1 : dirs)
+ {
+ includedFiles.add( dir1);
+ }
+ return includedFiles.toArray( new String []{});
+ }
private IXMLElement readRefPackData( String refFileName, boolean isselfcontained)
throws CompilerException {
File refXMLFile = new File(refFileName);
Index: src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java
===================================================================
--- src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (revision 2811)
+++ src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (working copy)
@@ -357,12 +357,14 @@
while (iter.hasNext())
{
IXMLElement p = iter.next();
- String target = requireAttribute(p, "targetfile" );
+ String target = p.getAttribute( "targetfile" , null );
String type = p.getAttribute( "type" , "plain" );
String encoding = p.getAttribute( "encoding" , null );
List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified
-
- pack.addParsable( new ParsableFile(target, type, encoding, osList));
+ if (target != null )
+ {
+ pack.addParsable( new ParsableFile(target, type, encoding, osList));
+ }
}
// We get the executables list
Show
Julien Ponge
added a comment - The patch does not apply.
Hide
Laurian Vostinar
added a comment -
There were some changes to CompilerConfig.java, I merged it. Here is the updated patch:
patch.txt
### Eclipse Workspace Patch 1.0
#P IzPack
Index: src/lib/com/izforge/izpack/compiler/CompilerConfig.java
===================================================================
--- src/lib/com/izforge/izpack/compiler/CompilerConfig.java (revision 2875)
+++ src/lib/com/izforge/izpack/compiler/CompilerConfig.java (working copy)
@@ -710,14 +710,48 @@
while (iter.hasNext())
{
IXMLElement p = iter.next();
- String target = requireAttribute(p, "targetfile");
+ String target = p.getAttribute("targetfile", null);
String type = p.getAttribute("type", "plain");
String encoding = p.getAttribute("encoding", null);
List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified
String condition = p.getAttribute("condition");
- ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
- parsable.setCondition(condition);
- pack.addParsable(parsable);
+ if (target != null)
+ {
+ ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
+ parsable.setCondition(condition);
+ pack.addParsable(parsable);
+ }
+ Iterator<IXMLElement> iterSet = p.getChildrenNamed("fileset").iterator();
+ while (iterSet.hasNext())
+ {
+ IXMLElement f = iterSet.next();
+ String targetdir = requireAttribute(f, "targetdir");
+ String dir_attr = requireAttribute(f, "dir");
+ File dir = new File(dir_attr);
+ if (!dir.isAbsolute())
+ {
+ dir = new File(basedir, dir_attr);
+ }
+ if (!dir.isDirectory()) // also tests '.exists()'
+ {
+ parseError(f, "Invalid directory 'dir': " + dir_attr);
+ }
+ String []includedFiles = getFilesetIncludedFiles(f);
+ if (includedFiles != null)
+ {
+ for (String filePath:includedFiles)
+ {
+ File file = new File(dir,filePath);
+ if (file.exists() && file.isFile())
+ {
+ String targetFile = new File(targetdir, filePath).getPath().replace(File.separatorChar, '/');
+ ParsableFile parsable = new ParsableFile(targetFile, type, encoding, osList);
+ parsable.setCondition(condition);
+ pack.addParsable(parsable);
+ }
+ }
+ }
+ }
}
// We get the executables list
@@ -876,7 +910,8 @@
{
IXMLElement f = iter.next();
String dir_attr = requireAttribute(f, "dir");
-
+ String targetdir = requireAttribute(f, "targetdir");
+
File dir = new File(dir_attr);
if (!dir.isAbsolute())
{
@@ -887,127 +922,30 @@
parseError(f, "Invalid directory 'dir': " + dir_attr);
}
- boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES);
- boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes", YES);
- String targetdir = requireAttribute(f, "targetdir");
+ String []includedFiles = getFilesetIncludedFiles(f);
List<OsConstraint> osList = OsConstraint.getOsList(f); // TODO: unverified
int override = getOverrideValue(f);
int blockable = getBlockableValue(f, osList);
Map additionals = getAdditionals(f);
String condition = f.getAttribute("condition");
- // get includes and excludes
- Vector<IXMLElement> xcludesList = null;
- String[] includes = null;
- xcludesList = f.getChildrenNamed("include");
- if (!xcludesList.isEmpty())
+ if (includedFiles != null)
{
- includes = new String[xcludesList.size()];
- for (int j = 0; j < xcludesList.size(); j++)
+ for (String filePath:includedFiles)
{
- IXMLElement xclude = xcludesList.get(j);
- includes[j] = requireAttribute(xclude, "name");
- }
- }
- String[] excludes = null;
- xcludesList = f.getChildrenNamed("exclude");
- if (!xcludesList.isEmpty())
- {
- excludes = new String[xcludesList.size()];
- for (int j = 0; j < xcludesList.size(); j++)
- {
- IXMLElement xclude = xcludesList.get(j);
- excludes[j] = requireAttribute(xclude, "name");
- }
- }
-
- // parse additional fileset attributes "includes" and "excludes"
- String[] toDo = new String[]{"includes", "excludes"};
- // use the existing containers filled from include and exclude
- // and add the includes and excludes to it
- String[][] containers = new String[][]{includes, excludes};
- for (int j = 0; j < toDo.length; ++j)
- {
- String inex = f.getAttribute(toDo[j]);
- if (inex != null && inex.length() > 0)
- { // This is the same "splitting" as ant PatternSet do ...
- StringTokenizer tok = new StringTokenizer(inex, ", ", false);
- int newSize = tok.countTokens();
- int k = 0;
- String[] nCont = null;
- if (containers[j] != null && containers[j].length > 0)
- { // old container exist; create a new which can hold
- // all values
- // and copy the old stuff to the front
- newSize += containers[j].length;
- nCont = new String[newSize];
- for (; k < containers[j].length; ++k)
- {
- nCont[k] = containers[j][k];
- }
- }
- if (nCont == null) // No container for old values
- // created,
- // create a new one.
+ try
{
- nCont = new String[newSize];
+ File file = new File(dir,filePath);
+ String target = new File(targetdir, filePath).getPath();
+ pack.addFile(baseDir, file, target, osList, override,blockable,
+ additionals, condition);
}
- for (; k < newSize; ++k)
- // Fill the new one or expand the existent container
+ catch (FileNotFoundException x)
{
- nCont[k] = tok.nextToken();
+ parseError(f, x.getMessage(), x);
}
- containers[j] = nCont;
}
}
- includes = containers[0]; // push the new includes to the
- // local var
- excludes = containers[1]; // push the new excludes to the
- // local var
-
- // scan and add fileset
- DirectoryScanner ds = new DirectoryScanner();
- ds.setIncludes(includes);
- ds.setExcludes(excludes);
- if (defexcludes)
- {
- ds.addDefaultExcludes();
- }
- ds.setBasedir(dir);
- ds.setCaseSensitive(casesensitive);
- ds.scan();
-
- String[] files = ds.getIncludedFiles();
- String[] dirs = ds.getIncludedDirectories();
-
- // Directory scanner has done recursion, add files and
- // directories
- for (String file : files)
- {
- try
- {
- String target = new File(targetdir, file).getPath();
- pack.addFile(baseDir, new File(dir, file), target, osList, override,
- blockable, additionals, condition);
- }
- catch (FileNotFoundException x)
- {
- parseError(f, x.getMessage(), x);
- }
- }
- for (String dir1 : dirs)
- {
- try
- {
- String target = new File(targetdir, dir1).getPath();
- pack.addFile(baseDir, new File(dir, dir1), target, osList, override,
- blockable, additionals, condition);
- }
- catch (FileNotFoundException x)
- {
- parseError(f, x.getMessage(), x);
- }
- }
}
// get the updatechecks list
@@ -1124,6 +1062,121 @@
notifyCompilerListener("addPacksSingle", CompilerListener.END, data);
}
+ private String[] getFilesetIncludedFiles(IXMLElement f) throws CompilerException
+ {
+ List<String> includedFiles = new ArrayList<String>();
+ String dir_attr = requireAttribute(f, "dir");
+
+ File dir = new File(dir_attr);
+ if (!dir.isAbsolute())
+ {
+ dir = new File(basedir, dir_attr);
+ }
+ if (!dir.isDirectory()) // also tests '.exists()'
+ {
+ parseError(f, "Invalid directory 'dir': " + dir_attr);
+ }
+
+ boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES);
+ boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes", YES);
+
+ // get includes and excludes
+ Vector<IXMLElement> xcludesList = null;
+ String[] includes = null;
+ xcludesList = f.getChildrenNamed("include");
+ if (!xcludesList.isEmpty())
+ {
+ includes = new String[xcludesList.size()];
+ for (int j = 0; j < xcludesList.size(); j++)
+ {
+ IXMLElement xclude = xcludesList.get(j);
+ includes[j] = requireAttribute(xclude, "name");
+ }
+ }
+ String[] excludes = null;
+ xcludesList = f.getChildrenNamed("exclude");
+ if (!xcludesList.isEmpty())
+ {
+ excludes = new String[xcludesList.size()];
+ for (int j = 0; j < xcludesList.size(); j++)
+ {
+ IXMLElement xclude = xcludesList.get(j);
+ excludes[j] = requireAttribute(xclude, "name");
+ }
+ }
+
+ // parse additional fileset attributes "includes" and "excludes"
+ String[] toDo = new String[]{"includes", "excludes"};
+ // use the existing containers filled from include and exclude
+ // and add the includes and excludes to it
+ String[][] containers = new String[][]{includes, excludes};
+ for (int j = 0; j < toDo.length; ++j)
+ {
+ String inex = f.getAttribute(toDo[j]);
+ if (inex != null && inex.length() > 0)
+ { // This is the same "splitting" as ant PatternSet do ...
+ StringTokenizer tok = new StringTokenizer(inex, ", ", false);
+ int newSize = tok.countTokens();
+ int k = 0;
+ String[] nCont = null;
+ if (containers[j] != null && containers[j].length > 0)
+ { // old container exist; create a new which can hold
+ // all values
+ // and copy the old stuff to the front
+ newSize += containers[j].length;
+ nCont = new String[newSize];
+ for (; k < containers[j].length; ++k)
+ {
+ nCont[k] = containers[j][k];
+ }
+ }
+ if (nCont == null) // No container for old values
+ // created,
+ // create a new one.
+ {
+ nCont = new String[newSize];
+ }
+ for (; k < newSize; ++k)
+ // Fill the new one or expand the existent container
+ {
+ nCont[k] = tok.nextToken();
+ }
+ containers[j] = nCont;
+ }
+ }
+ includes = containers[0]; // push the new includes to the
+ // local var
+ excludes = containers[1]; // push the new excludes to the
+ // local var
+
+ // scan and add fileset
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(includes);
+ ds.setExcludes(excludes);
+ if (defexcludes)
+ {
+ ds.addDefaultExcludes();
+ }
+ ds.setBasedir(dir);
+ ds.setCaseSensitive(casesensitive);
+ ds.scan();
+
+ String[] files = ds.getIncludedFiles();
+ String[] dirs = ds.getIncludedDirectories();
+
+ // Directory scanner has done recursion, add files and
+ // directories
+ for (String file : files)
+ {
+ includedFiles.add( file);
+ }
+ for (String dir1 : dirs)
+ {
+ includedFiles.add( dir1);
+ }
+ return includedFiles.toArray(new String[]{});
+ }
+
private IXMLElement readRefPackData(String refFileName, boolean isselfcontained)
throws CompilerException {
File refXMLFile = new File(refFileName);
Index: src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java
===================================================================
--- src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (revision 2811)
+++ src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (working copy)
@@ -357,12 +357,14 @@
while (iter.hasNext())
{
IXMLElement p = iter.next();
- String target = requireAttribute(p, "targetfile");
+ String target = p.getAttribute("targetfile", null);
String type = p.getAttribute("type", "plain");
String encoding = p.getAttribute("encoding", null);
List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified
-
- pack.addParsable(new ParsableFile(target, type, encoding, osList));
+ if (target != null)
+ {
+ pack.addParsable(new ParsableFile(target, type, encoding, osList));
+ }
}
// We get the executables list
Show
Laurian Vostinar
added a comment - There were some changes to CompilerConfig.java, I merged it. Here is the updated patch:
patch.txt
### Eclipse Workspace Patch 1.0
#P IzPack
Index: src/lib/com/izforge/izpack/compiler/CompilerConfig.java
===================================================================
--- src/lib/com/izforge/izpack/compiler/CompilerConfig.java (revision 2875)
+++ src/lib/com/izforge/izpack/compiler/CompilerConfig.java (working copy)
@@ -710,14 +710,48 @@
while (iter.hasNext())
{
IXMLElement p = iter.next();
- String target = requireAttribute(p, "targetfile" );
+ String target = p.getAttribute( "targetfile" , null );
String type = p.getAttribute( "type" , "plain" );
String encoding = p.getAttribute( "encoding" , null );
List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified
String condition = p.getAttribute( "condition" );
- ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
- parsable.setCondition(condition);
- pack.addParsable(parsable);
+ if (target != null )
+ {
+ ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
+ parsable.setCondition(condition);
+ pack.addParsable(parsable);
+ }
+ Iterator<IXMLElement> iterSet = p.getChildrenNamed( "fileset" ).iterator();
+ while (iterSet.hasNext())
+ {
+ IXMLElement f = iterSet.next();
+ String targetdir = requireAttribute(f, "targetdir" );
+ String dir_attr = requireAttribute(f, "dir" );
+ File dir = new File(dir_attr);
+ if (!dir.isAbsolute())
+ {
+ dir = new File(basedir, dir_attr);
+ }
+ if (!dir.isDirectory()) // also tests '.exists()'
+ {
+ parseError(f, "Invalid directory 'dir': " + dir_attr);
+ }
+ String []includedFiles = getFilesetIncludedFiles(f);
+ if (includedFiles != null )
+ {
+ for ( String filePath:includedFiles)
+ {
+ File file = new File(dir,filePath);
+ if (file.exists() && file.isFile())
+ {
+ String targetFile = new File(targetdir, filePath).getPath().replace(File.separatorChar, '/');
+ ParsableFile parsable = new ParsableFile(targetFile, type, encoding, osList);
+ parsable.setCondition(condition);
+ pack.addParsable(parsable);
+ }
+ }
+ }
+ }
}
// We get the executables list
@@ -876,7 +910,8 @@
{
IXMLElement f = iter.next();
String dir_attr = requireAttribute(f, "dir" );
-
+ String targetdir = requireAttribute(f, "targetdir" );
+
File dir = new File(dir_attr);
if (!dir.isAbsolute())
{
@@ -887,127 +922,30 @@
parseError(f, "Invalid directory 'dir': " + dir_attr);
}
- boolean casesensitive = validateYesNoAttribute(f, "casesensitive" , YES);
- boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes" , YES);
- String targetdir = requireAttribute(f, "targetdir" );
+ String []includedFiles = getFilesetIncludedFiles(f);
List<OsConstraint> osList = OsConstraint.getOsList(f); // TODO: unverified
int override = getOverrideValue(f);
int blockable = getBlockableValue(f, osList);
Map additionals = getAdditionals(f);
String condition = f.getAttribute( "condition" );
- // get includes and excludes
- Vector<IXMLElement> xcludesList = null ;
- String [] includes = null ;
- xcludesList = f.getChildrenNamed( "include" );
- if (!xcludesList.isEmpty())
+ if (includedFiles != null )
{
- includes = new String [xcludesList.size()];
- for ( int j = 0; j < xcludesList.size(); j++)
+ for ( String filePath:includedFiles)
{
- IXMLElement xclude = xcludesList.get(j);
- includes[j] = requireAttribute(xclude, "name" );
- }
- }
- String [] excludes = null ;
- xcludesList = f.getChildrenNamed( "exclude" );
- if (!xcludesList.isEmpty())
- {
- excludes = new String [xcludesList.size()];
- for ( int j = 0; j < xcludesList.size(); j++)
- {
- IXMLElement xclude = xcludesList.get(j);
- excludes[j] = requireAttribute(xclude, "name" );
- }
- }
-
- // parse additional fileset attributes "includes" and "excludes"
- String [] toDo = new String []{ "includes" , "excludes" };
- // use the existing containers filled from include and exclude
- // and add the includes and excludes to it
- String [][] containers = new String [][]{includes, excludes};
- for ( int j = 0; j < toDo.length; ++j)
- {
- String inex = f.getAttribute(toDo[j]);
- if (inex != null && inex.length() > 0)
- { // This is the same "splitting" as ant PatternSet do ...
- StringTokenizer tok = new StringTokenizer(inex, ", " , false );
- int newSize = tok.countTokens();
- int k = 0;
- String [] nCont = null ;
- if (containers[j] != null && containers[j].length > 0)
- { // old container exist; create a new which can hold
- // all values
- // and copy the old stuff to the front
- newSize += containers[j].length;
- nCont = new String [newSize];
- for (; k < containers[j].length; ++k)
- {
- nCont[k] = containers[j][k];
- }
- }
- if (nCont == null ) // No container for old values
- // created,
- // create a new one.
+ try
{
- nCont = new String [newSize];
+ File file = new File(dir,filePath);
+ String target = new File(targetdir, filePath).getPath();
+ pack.addFile(baseDir, file, target, osList, override,blockable,
+ additionals, condition);
}
- for (; k < newSize; ++k)
- // Fill the new one or expand the existent container
+ catch (FileNotFoundException x)
{
- nCont[k] = tok.nextToken();
+ parseError(f, x.getMessage(), x);
}
- containers[j] = nCont;
}
}
- includes = containers[0]; // push the new includes to the
- // local var
- excludes = containers[1]; // push the new excludes to the
- // local var
-
- // scan and add fileset
- DirectoryScanner ds = new DirectoryScanner();
- ds.setIncludes(includes);
- ds.setExcludes(excludes);
- if (defexcludes)
- {
- ds.addDefaultExcludes();
- }
- ds.setBasedir(dir);
- ds.setCaseSensitive(casesensitive);
- ds.scan();
-
- String [] files = ds.getIncludedFiles();
- String [] dirs = ds.getIncludedDirectories();
-
- // Directory scanner has done recursion, add files and
- // directories
- for ( String file : files)
- {
- try
- {
- String target = new File(targetdir, file).getPath();
- pack.addFile(baseDir, new File(dir, file), target, osList, override,
- blockable, additionals, condition);
- }
- catch (FileNotFoundException x)
- {
- parseError(f, x.getMessage(), x);
- }
- }
- for ( String dir1 : dirs)
- {
- try
- {
- String target = new File(targetdir, dir1).getPath();
- pack.addFile(baseDir, new File(dir, dir1), target, osList, override,
- blockable, additionals, condition);
- }
- catch (FileNotFoundException x)
- {
- parseError(f, x.getMessage(), x);
- }
- }
}
// get the updatechecks list
@@ -1124,6 +1062,121 @@
notifyCompilerListener( "addPacksSingle" , CompilerListener.END, data);
}
+ private String [] getFilesetIncludedFiles(IXMLElement f) throws CompilerException
+ {
+ List< String > includedFiles = new ArrayList< String >();
+ String dir_attr = requireAttribute(f, "dir" );
+
+ File dir = new File(dir_attr);
+ if (!dir.isAbsolute())
+ {
+ dir = new File(basedir, dir_attr);
+ }
+ if (!dir.isDirectory()) // also tests '.exists()'
+ {
+ parseError(f, "Invalid directory 'dir': " + dir_attr);
+ }
+
+ boolean casesensitive = validateYesNoAttribute(f, "casesensitive" , YES);
+ boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes" , YES);
+
+ // get includes and excludes
+ Vector<IXMLElement> xcludesList = null ;
+ String [] includes = null ;
+ xcludesList = f.getChildrenNamed( "include" );
+ if (!xcludesList.isEmpty())
+ {
+ includes = new String [xcludesList.size()];
+ for ( int j = 0; j < xcludesList.size(); j++)
+ {
+ IXMLElement xclude = xcludesList.get(j);
+ includes[j] = requireAttribute(xclude, "name" );
+ }
+ }
+ String [] excludes = null ;
+ xcludesList = f.getChildrenNamed( "exclude" );
+ if (!xcludesList.isEmpty())
+ {
+ excludes = new String [xcludesList.size()];
+ for ( int j = 0; j < xcludesList.size(); j++)
+ {
+ IXMLElement xclude = xcludesList.get(j);
+ excludes[j] = requireAttribute(xclude, "name" );
+ }
+ }
+
+ // parse additional fileset attributes "includes" and "excludes"
+ String [] toDo = new String []{ "includes" , "excludes" };
+ // use the existing containers filled from include and exclude
+ // and add the includes and excludes to it
+ String [][] containers = new String [][]{includes, excludes};
+ for ( int j = 0; j < toDo.length; ++j)
+ {
+ String inex = f.getAttribute(toDo[j]);
+ if (inex != null && inex.length() > 0)
+ { // This is the same "splitting" as ant PatternSet do ...
+ StringTokenizer tok = new StringTokenizer(inex, ", " , false );
+ int newSize = tok.countTokens();
+ int k = 0;
+ String [] nCont = null ;
+ if (containers[j] != null && containers[j].length > 0)
+ { // old container exist; create a new which can hold
+ // all values
+ // and copy the old stuff to the front
+ newSize += containers[j].length;
+ nCont = new String [newSize];
+ for (; k < containers[j].length; ++k)
+ {
+ nCont[k] = containers[j][k];
+ }
+ }
+ if (nCont == null ) // No container for old values
+ // created,
+ // create a new one.
+ {
+ nCont = new String [newSize];
+ }
+ for (; k < newSize; ++k)
+ // Fill the new one or expand the existent container
+ {
+ nCont[k] = tok.nextToken();
+ }
+ containers[j] = nCont;
+ }
+ }
+ includes = containers[0]; // push the new includes to the
+ // local var
+ excludes = containers[1]; // push the new excludes to the
+ // local var
+
+ // scan and add fileset
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(includes);
+ ds.setExcludes(excludes);
+ if (defexcludes)
+ {
+ ds.addDefaultExcludes();
+ }
+ ds.setBasedir(dir);
+ ds.setCaseSensitive(casesensitive);
+ ds.scan();
+
+ String [] files = ds.getIncludedFiles();
+ String [] dirs = ds.getIncludedDirectories();
+
+ // Directory scanner has done recursion, add files and
+ // directories
+ for ( String file : files)
+ {
+ includedFiles.add( file);
+ }
+ for ( String dir1 : dirs)
+ {
+ includedFiles.add( dir1);
+ }
+ return includedFiles.toArray( new String []{});
+ }
+
private IXMLElement readRefPackData( String refFileName, boolean isselfcontained)
throws CompilerException {
File refXMLFile = new File(refFileName);
Index: src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java
===================================================================
--- src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (revision 2811)
+++ src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (working copy)
@@ -357,12 +357,14 @@
while (iter.hasNext())
{
IXMLElement p = iter.next();
- String target = requireAttribute(p, "targetfile" );
+ String target = p.getAttribute( "targetfile" , null );
String type = p.getAttribute( "type" , "plain" );
String encoding = p.getAttribute( "encoding" , null );
List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified
-
- pack.addParsable( new ParsableFile(target, type, encoding, osList));
+ if (target != null )
+ {
+ pack.addParsable( new ParsableFile(target, type, encoding, osList));
+ }
}
// We get the executables list
Julien Ponge
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Julien Ponge [ jponge ] |
Hide
Julien Ponge
added a comment -
The patch applies, and the feature makes sense.
Would you be able to provide a documentation update/patch as well?
Thanks
Show
Julien Ponge
added a comment - The patch applies, and the feature makes sense.
Would you be able to provide a documentation update/patch as well?
Thanks
Julien Ponge
made changes -
| Attachment | IZPACK-394.diff [ 45579 ] |
Julien Ponge
made changes -
| Summary | Make parsable works on a embedded fileset element instead of on a sigle file | Make parsable works on a embedded fileset element instead of on a single file |
Hide
Laurian Vostinar
added a comment -
Here is the documentation patch:
Doc Patch
### Eclipse Workspace Patch 1.0 #P IzPack Index: src/doc-reST/installation-files.txt =================================================================== --- src/doc-reST/installation-files.txt (revision 2923) +++ src/doc-reST/installation-files.txt (working copy) @@ -1219,7 +1219,7 @@ A ``<additionaldata>`` tag can also be specified for customizing. -``<parsable>`` - parse a file after installation +``<parsable>`` - parse file(s) after installation '''''''''''''''''''''''''''''''''''''''''''''''''' Files specified by ``<parsable>`` are parsed after installation and may have @@ -1228,13 +1228,14 @@ - ``targetfile`` : the file to parse, could be something like ``$INSTALL_PATH/bin/launch-script.sh`` A slash will be changed to the system dependant path separator (e.g. to a - backslash on Windows) only if no backslash masks the slash. + backslash on Windows) only if no backslash masks the slash. No longer mandatory as a fileset of files can be used. - ``type`` : specifies the type (same as for the resources) - the default is ``plain`` - ``encoding`` : specifies the file encoding - ``os``: specifies the operating system, works like for ``<file>`` - ``condition``: an id of a condition which has to be fullfilled to parse this file +One or more fileset tags can be used inside parsable to specify multiple files at once. ``<executable>`` - mark file executable or execute it '''''''''''''''''''''''''''''''''''''''''''''''''''''''
Show
Laurian Vostinar
added a comment - Here is the documentation patch:
Doc Patch
### Eclipse Workspace Patch 1.0
#P IzPack
Index: src/doc-reST/installation-files.txt
===================================================================
--- src/doc-reST/installation-files.txt (revision 2923)
+++ src/doc-reST/installation-files.txt (working copy)
@@ -1219,7 +1219,7 @@
A ``<additionaldata>`` tag can also be specified for customizing.
-``<parsable>`` - parse a file after installation
+``<parsable>`` - parse file(s) after installation
''''''''''''''''''''''''''''''''''''''''''''''''''
Files specified by ``<parsable>`` are parsed after installation and may have
@@ -1228,13 +1228,14 @@
- ``targetfile`` : the file to parse, could be something like
``$INSTALL_PATH/bin/launch-script.sh``
A slash will be changed to the system dependant path separator (e.g. to a
- backslash on Windows) only if no backslash masks the slash.
+ backslash on Windows) only if no backslash masks the slash. No longer mandatory as a fileset of files can be used.
- ``type`` : specifies the type (same as for the resources) - the
default is ``plain``
- ``encoding`` : specifies the file encoding
- ``os``: specifies the operating system, works like for ``<file>``
- ``condition``: an id of a condition which has to be fullfilled to parse this file
+One or more fileset tags can be used inside parsable to specify multiple files at once.
``<executable>`` - mark file executable or execute it
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Show
Julien Ponge
added a comment - Thanks, I will handle this soon.
Show
Julien Ponge
added a comment - Thanks for the patches.
Julien Ponge
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] | |
| Fix Version/s | 4.4.0 [ 15138 ] |
I have a patch for this, as a result targetfile attribute will be no longer mandatory (you can just have a fileset inside a parsable tag). If targetfile is present file will be added, also will look for all filesets inside parsable; all existing files from fileset(s) will be added as parsables.
### Eclipse Workspace Patch 1.0 #P IzPack Index: src/lib/com/izforge/izpack/compiler/CompilerConfig.java =================================================================== --- src/lib/com/izforge/izpack/compiler/CompilerConfig.java (revision 2826) +++ src/lib/com/izforge/izpack/compiler/CompilerConfig.java (working copy) @@ -710,14 +710,48 @@ while (iter.hasNext()) { IXMLElement p = iter.next(); - String target = requireAttribute(p, "targetfile"); + String target = p.getAttribute("targetfile", null); String type = p.getAttribute("type", "plain"); String encoding = p.getAttribute("encoding", null); List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified String condition = p.getAttribute("condition"); - ParsableFile parsable = new ParsableFile(target, type, encoding, osList); - parsable.setCondition(condition); - pack.addParsable(parsable); + if (target != null) + { + ParsableFile parsable = new ParsableFile(target, type, encoding, osList); + parsable.setCondition(condition); + pack.addParsable(parsable); + } + Iterator<IXMLElement> iterSet = p.getChildrenNamed("fileset").iterator(); + while (iterSet.hasNext()) + { + IXMLElement f = iterSet.next(); + String targetdir = requireAttribute(f, "targetdir"); + String dir_attr = requireAttribute(f, "dir"); + File dir = new File(dir_attr); + if (!dir.isAbsolute()) + { + dir = new File(basedir, dir_attr); + } + if (!dir.isDirectory()) // also tests '.exists()' + { + parseError(f, "Invalid directory 'dir': " + dir_attr); + } + String []includedFiles = getFilesetIncludedFiles(f); + if (includedFiles != null) + { + for (String filePath:includedFiles) + { + File file = new File(dir,filePath); + if (file.exists() && file.isFile()) + { + String targetFile = new File(targetdir, filePath).getPath(); + ParsableFile parsable = new ParsableFile(targetFile, type, encoding, osList); + parsable.setCondition(condition); + pack.addParsable(parsable); + } + } + } + } } // We get the executables list @@ -872,8 +906,8 @@ while (iter.hasNext()) { IXMLElement f = iter.next(); + String targetdir = requireAttribute(f, "targetdir"); String dir_attr = requireAttribute(f, "dir"); - File dir = new File(dir_attr); if (!dir.isAbsolute()) { @@ -883,127 +917,28 @@ { parseError(f, "Invalid directory 'dir': " + dir_attr); } - - boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); - boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes", YES); - String targetdir = requireAttribute(f, "targetdir"); + String []includedFiles = getFilesetIncludedFiles(f); List<OsConstraint> osList = OsConstraint.getOsList(f); // TODO: unverified int override = getOverrideValue(f); Map additionals = getAdditionals(f); String condition = f.getAttribute("condition"); - - // get includes and excludes - Vector<IXMLElement> xcludesList = null; - String[] includes = null; - xcludesList = f.getChildrenNamed("include"); - if (!xcludesList.isEmpty()) + if (includedFiles != null) { - includes = new String[xcludesList.size()]; - for (int j = 0; j < xcludesList.size(); j++) + for (String filePath:includedFiles) { - IXMLElement xclude = xcludesList.get(j); - includes[j] = requireAttribute(xclude, "name"); - } - } - String[] excludes = null; - xcludesList = f.getChildrenNamed("exclude"); - if (!xcludesList.isEmpty()) - { - excludes = new String[xcludesList.size()]; - for (int j = 0; j < xcludesList.size(); j++) - { - IXMLElement xclude = xcludesList.get(j); - excludes[j] = requireAttribute(xclude, "name"); - } - } - - // parse additional fileset attributes "includes" and "excludes" - String[] toDo = new String[]{"includes", "excludes"}; - // use the existing containers filled from include and exclude - // and add the includes and excludes to it - String[][] containers = new String[][]{includes, excludes}; - for (int j = 0; j < toDo.length; ++j) - { - String inex = f.getAttribute(toDo[j]); - if (inex != null && inex.length() > 0) - { // This is the same "splitting" as ant PatternSet do ... - StringTokenizer tok = new StringTokenizer(inex, ", ", false); - int newSize = tok.countTokens(); - int k = 0; - String[] nCont = null; - if (containers[j] != null && containers[j].length > 0) - { // old container exist; create a new which can hold - // all values - // and copy the old stuff to the front - newSize += containers[j].length; - nCont = new String[newSize]; - for (; k < containers[j].length; ++k) - { - nCont[k] = containers[j][k]; - } - } - if (nCont == null) // No container for old values - // created, - // create a new one. + try { - nCont = new String[newSize]; + File file = new File(dir,filePath); + String target = new File(targetdir, filePath).getPath(); + pack.addFile(baseDir, file, target, osList, override, + additionals, condition); } - for (; k < newSize; ++k) - // Fill the new one or expand the existent container + catch (FileNotFoundException x) { - nCont[k] = tok.nextToken(); + parseError(f, x.getMessage(), x); } - containers[j] = nCont; } } - includes = containers[0]; // push the new includes to the - // local var - excludes = containers[1]; // push the new excludes to the - // local var - - // scan and add fileset - DirectoryScanner ds = new DirectoryScanner(); - ds.setIncludes(includes); - ds.setExcludes(excludes); - if (defexcludes) - { - ds.addDefaultExcludes(); - } - ds.setBasedir(dir); - ds.setCaseSensitive(casesensitive); - ds.scan(); - - String[] files = ds.getIncludedFiles(); - String[] dirs = ds.getIncludedDirectories(); - - // Directory scanner has done recursion, add files and - // directories - for (String file : files) - { - try - { - String target = new File(targetdir, file).getPath(); - pack.addFile(baseDir, new File(dir, file), target, osList, override, - additionals, condition); - } - catch (FileNotFoundException x) - { - parseError(f, x.getMessage(), x); - } - } - for (String dir1 : dirs) - { - try - { - String target = new File(targetdir, dir1).getPath(); - pack.addFile(baseDir, new File(dir, dir1), target, osList, override, - additionals, condition); - } - catch (FileNotFoundException x) - { - parseError(f, x.getMessage(), x); - } - } } // get the updatechecks list @@ -1119,7 +1054,120 @@ notifyCompilerListener("addPacksSingle", CompilerListener.END, data); } + private String[] getFilesetIncludedFiles(IXMLElement f) throws CompilerException + { + List<String> includedFiles = new ArrayList<String>(); + String dir_attr = requireAttribute(f, "dir"); + File dir = new File(dir_attr); + if (!dir.isAbsolute()) + { + dir = new File(basedir, dir_attr); + } + if (!dir.isDirectory()) // also tests '.exists()' + { + parseError(f, "Invalid directory 'dir': " + dir_attr); + } + + boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); + boolean defexcludes = validateYesNoAttribute(f, "defaultexcludes", YES); + + // get includes and excludes + Vector<IXMLElement> xcludesList = null; + String[] includes = null; + xcludesList = f.getChildrenNamed("include"); + if (!xcludesList.isEmpty()) + { + includes = new String[xcludesList.size()]; + for (int j = 0; j < xcludesList.size(); j++) + { + IXMLElement xclude = xcludesList.get(j); + includes[j] = requireAttribute(xclude, "name"); + } + } + String[] excludes = null; + xcludesList = f.getChildrenNamed("exclude"); + if (!xcludesList.isEmpty()) + { + excludes = new String[xcludesList.size()]; + for (int j = 0; j < xcludesList.size(); j++) + { + IXMLElement xclude = xcludesList.get(j); + excludes[j] = requireAttribute(xclude, "name"); + } + } + + // parse additional fileset attributes "includes" and "excludes" + String[] toDo = new String[]{"includes", "excludes"}; + // use the existing containers filled from include and exclude + // and add the includes and excludes to it + String[][] containers = new String[][]{includes, excludes}; + for (int j = 0; j < toDo.length; ++j) + { + String inex = f.getAttribute(toDo[j]); + if (inex != null && inex.length() > 0) + { // This is the same "splitting" as ant PatternSet do ... + StringTokenizer tok = new StringTokenizer(inex, ", ", false); + int newSize = tok.countTokens(); + int k = 0; + String[] nCont = null; + if (containers[j] != null && containers[j].length > 0) + { // old container exist; create a new which can hold + // all values + // and copy the old stuff to the front + newSize += containers[j].length; + nCont = new String[newSize]; + for (; k < containers[j].length; ++k) + { + nCont[k] = containers[j][k]; + } + } + if (nCont == null) // No container for old values + // created, + // create a new one. + { + nCont = new String[newSize]; + } + for (; k < newSize; ++k) + // Fill the new one or expand the existent container + { + nCont[k] = tok.nextToken(); + } + containers[j] = nCont; + } + } + includes = containers[0]; // push the new includes to the + // local var + excludes = containers[1]; // push the new excludes to the + // local var + + // scan and add fileset + DirectoryScanner ds = new DirectoryScanner(); + ds.setIncludes(includes); + ds.setExcludes(excludes); + if (defexcludes) + { + ds.addDefaultExcludes(); + } + ds.setBasedir(dir); + ds.setCaseSensitive(casesensitive); + ds.scan(); + + String[] files = ds.getIncludedFiles(); + String[] dirs = ds.getIncludedDirectories(); + + // Directory scanner has done recursion, add files and + // directories + for (String file : files) + { + includedFiles.add( file); + } + for (String dir1 : dirs) + { + includedFiles.add( dir1); + } + return includedFiles.toArray(new String[]{}); + } private IXMLElement readRefPackData(String refFileName, boolean isselfcontained) throws CompilerException { File refXMLFile = new File(refFileName); Index: src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java =================================================================== --- src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (revision 2811) +++ src/lib/com/izforge/izpack/installer/WebRepositoryAccessor.java (working copy) @@ -357,12 +357,14 @@ while (iter.hasNext()) { IXMLElement p = iter.next(); - String target = requireAttribute(p, "targetfile"); + String target = p.getAttribute("targetfile", null); String type = p.getAttribute("type", "plain"); String encoding = p.getAttribute("encoding", null); List<OsConstraint> osList = OsConstraint.getOsList(p); // TODO: unverified - - pack.addParsable(new ParsableFile(target, type, encoding, osList)); + if (target != null) + { + pack.addParsable(new ParsableFile(target, type, encoding, osList)); + } } // We get the executables list