Revision: 236 http://mindtreeinsight.svn.sourceforge.net/mindtreeinsight/?rev=236&view=rev Author: bindul Date: 2009-03-28 02:14:41 +0000 (Sat, 28 Mar 2009)
Log Message: ----------- BUG-2014244: [Maven-NSIS-Plugin] Resources subdirectories Modified Paths: -------------- releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/changes/changes.xml releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolveTool.java releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/resources/velocity/sections.vm Added Paths: ----------- releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolvedFileSet.java Modified: releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/changes/changes.xml =================================================================== --- releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/changes/changes.xml 2009-03-27 21:00:18 UTC (rev 235) +++ releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/changes/changes.xml 2009-03-28 02:14:41 UTC (rev 236) @@ -41,6 +41,9 @@ <action type="add" date="2009-03-27" dev="bindul" issue="2685076" system="featureRequests"> Added support to use a installer language other than English </action> + <action type="fix" date="2009-03-27" dev="bindul" issue="2014244" system="bugs"> + Fixed nested fileset support when rendering files in installer + </action> </release> <release version="0.1.0" date="2008-01-13" description="Initial release to support Insight"> </release> Modified: releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolveTool.java =================================================================== --- releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolveTool.java 2009-03-27 21:00:18 UTC (rev 235) +++ releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolveTool.java 2009-03-28 02:14:41 UTC (rev 236) @@ -20,11 +20,14 @@ */ package com.mindtree.techworks.insight.releng.mvn.nsis.velocityutil; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -92,14 +95,61 @@ resolvedDependencies = Collections.EMPTY_LIST; } + Collections.sort(resolvedDependencies); return resolvedDependencies; } + public List resolveForInstall (SetBase setBase ) throws NsisActionExecutionException { + List fileList = resolve(setBase); + + // Group the files together + Map groupedFiles = new HashMap(); + Iterator filesItr = fileList.iterator(); + while (filesItr.hasNext()) { + String file = (String) filesItr.next(); + String workingFile = file.replaceAll("/", "\\"); + if (workingFile.indexOf("\\") > 0) { + addFileToMap(workingFile.substring(0, workingFile.lastIndexOf("\\")), file, groupedFiles); + } else { + addFileToMap("", file, groupedFiles); + } + } + + // The CopyResourcesAction will already have created the structure + // for us + List resolvedFiles = new ArrayList(); + Set keySet = groupedFiles.keySet(); + Iterator dirItr = keySet.iterator(); + while (dirItr.hasNext()) { + String dir = (String) dirItr.next(); + ResolvedFileSet resolvedFileSet = new ResolvedFileSet(); + + if (null != dir && dir.length() > 0) { + resolvedFileSet.setDirectory(dir); + } + resolvedFileSet.setFiles((List) groupedFiles.get(dir)); + resolvedFiles.add(resolvedFileSet); + } + + return resolvedFiles; + } + + private void addFileToMap(String dir, String file, Map groupedFiles) { + if (groupedFiles.containsKey(dir)) { + ((List)groupedFiles.get(dir)).add(file); + } else { + List files = new ArrayList(); + files.add(file); + groupedFiles.put(dir, files); + } + } + /** * Identifies all the unique directories that have been created during * installation for deletion + * @throws NsisActionExecutionException */ - public Set resolveUniqueInstallDirs (List sections, String base) { + public Set resolveUniqueInstallDirs (List sections, String base) throws NsisActionExecutionException { if (null == sections) { return Collections.EMPTY_SET; } @@ -130,13 +180,29 @@ * @param fileSets * @param uniqueInstallDirs * @param base + * @throws NsisActionExecutionException */ private void addInstallDirsToSet(List setBases, Set uniqueInstallDirs, - String base) { + String base) throws NsisActionExecutionException { for (Iterator setBaseItr = setBases.iterator(); setBaseItr.hasNext(); ) { SetBase setbase = (SetBase) setBaseItr.next(); - String installDir = base + ((null != setbase.getOutputDirectory()) ? ("\\" + setbase.getOutputDirectory()) : ""); - uniqueInstallDirs.add(installDir); + if (setbase instanceof FileSet) { + List fileList = fileSetResolver.getRelativeFilePath(setbase, mojoInfo); + Iterator filesItr = fileList.iterator(); + while (filesItr.hasNext()) { + String file = (String) filesItr.next(); + file = file.replaceAll("/", "\\"); + String dir = ""; + if (file.indexOf("\\") > 0) { + dir = file.substring(0, file.lastIndexOf("\\")); + } + String installDir = base + ((dir.trim().length() > 0) ? ("\\" + dir) : ""); + uniqueInstallDirs.add(installDir); + } + } else { + String installDir = base + ((null != setbase.getOutputDirectory()) ? ("\\" + setbase.getOutputDirectory()) : ""); + uniqueInstallDirs.add(installDir); + } } } } Added: releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolvedFileSet.java =================================================================== --- releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolvedFileSet.java (rev 0) +++ releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolvedFileSet.java 2009-03-28 02:14:41 UTC (rev 236) @@ -0,0 +1,70 @@ +/* + * $HeadURL$ + * + * Copyright (c) 2008 MindTree Consulting Ltd. + * + * This file is part of Insight Release Engineering Tools. + * + * Insight Release Engineering Tools is free software: you can redistribute it + * and/or modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * Insight Release Engineering Tools is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Insight Release Engineering Tools. If not, see <http://www.gnu.org/licenses/>. + */ +package com.mindtree.techworks.insight.releng.mvn.nsis.velocityutil; + +import java.util.List; + +/** + * Holds resolved filesets grouped by a directory + * + * @author <a href="mailto:bindul_bhow...@mindtree.com">Bindul Bhowmik</a> + * @version $Revision$ $Date$ + */ +public class ResolvedFileSet { + + /** + * The directory + */ + private String directory; + + /** + * Files in the directory + */ + private List files; + + /** + * @return the directory + */ + public String getDirectory() { + return directory; + } + + /** + * @param directory the directory to set + */ + public void setDirectory(String directory) { + this.directory = directory; + } + + /** + * @return the files + */ + public List getFiles() { + return files; + } + + /** + * @param files the files to set + */ + public void setFiles(List files) { + this.files = files; + } +} Property changes on: releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/java/com/mindtree/techworks/insight/releng/mvn/nsis/velocityutil/ResolvedFileSet.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native Modified: releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/resources/velocity/sections.vm =================================================================== --- releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/resources/velocity/sections.vm 2009-03-27 21:00:18 UTC (rev 235) +++ releng/maven-nsis-plugin/branches/maven-nsis-plugin-0.2.0/src/main/resources/velocity/sections.vm 2009-03-28 02:14:41 UTC (rev 236) @@ -55,6 +55,20 @@ #end ## #foreach($setBase in ${setBases}) #end ## #macro ( renderfiles $setBase $installer ) +#macro( renderInstallFiles $setBases $instruction) +#foreach($setBase in ${setBases}) +#foreach($fileSet in $resolveTool.resolveForInstall(${setBase})) +SetOutPath "$nsisInstDir#if($null.isNotNull(${fileSet.directory}))\\${fileSet.directory}#end" +#if($null.isNotNull(${setBase.overWritePolicy})) + SetOverwrite ${setBase.overWritePolicy} +#end## #if($null.isNotNull(${setBase.overWritePolicy})) +#foreach($file in ${fileSet.files}) + $instruction "$file" +#end ## #foreach($file in $resolveTool.resolve(${setBase})) +#end +#end +#end + #if($null.isNotNull(${installerSections.installTypes})) ; Install Types #foreach($instType in ${installerSections.installTypes}) @@ -71,13 +85,13 @@ ## FileSets -#renderfiles(${section.fileSets} true "File" $nothing) +#renderInstallFiles(${section.fileSets} "File") ## Files -#renderfiles(${section.files} true "File" $nothing) +#renderInstallFiles(${section.files} "File") ## Dependencies -#renderfiles(${section.dependencySets} true "File" $nothing) +#renderInstallFiles(${section.dependencySets} "File") ## Shortcuts This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ MindTreeInsight-commits mailing list MindTreeInsight-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mindtreeinsight-commits