Author: tchemit Date: 2011-09-21 20:02:48 +0200 (Wed, 21 Sep 2011) New Revision: 1095 Url: http://nuiton.org/repositories/revision/eugene/1095 Log: Anomalie #1438: Classpath model resolution fails on windows (use String inputPath instead of File inputDirectory in ChainedFileWriterEntry) Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriter.java trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterEntry.java trunk/eugene/src/main/java/org/nuiton/eugene/writer/DefaultChainedWriterEngine.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriter.java Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriter.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriter.java 2011-09-21 11:01:18 UTC (rev 1094) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriter.java 2011-09-21 18:02:48 UTC (rev 1095) @@ -146,16 +146,16 @@ * Obtain for a given {@code inputDirectory}, all files to treate. * * @param configuration the shared configuration - * @param inputDirectory the input directory + * @param inputPath the input path (can be a directory or a classpath path) * @param includePattern the include pattern separated by comma - * @param inClassPath a flag to say if we should search in classp-ath + * @param inClassPath a flag to say if we should search in classpath * @return the list of resources detected * @throws IOException if any IO pb while searching resources * @throws IllegalArgumentException if no include pattern given * @since 2.1.3 */ List<URL> getFiles(ChainedFileWriterConfiguration configuration, - File inputDirectory, + String inputPath, List<String> includePattern, boolean inClassPath) throws IOException, IllegalArgumentException; Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterEntry.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterEntry.java 2011-09-21 11:01:18 UTC (rev 1094) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterEntry.java 2011-09-21 18:02:48 UTC (rev 1095) @@ -25,7 +25,7 @@ package org.nuiton.eugene.writer; -import java.io.File; +import org.apache.commons.lang.builder.ToStringBuilder; /** * Definition of of the chained writer entry. @@ -38,8 +38,8 @@ */ public class ChainedFileWriterEntry { - /** input directory of entry */ - protected File inputDirectory; + /** input path of entry (can be a directory or a classpath entry) */ + protected String inputPath; /** include pattern of entry */ protected String includePattern; @@ -47,22 +47,22 @@ /** * Flag to knwon if resources should be searched in classpath. * <p/> - * If sets to {@code true}, then the {@link #inputDirectory} is the + * If sets to {@code true}, then the {@link #inputPath} is the * absolute path where to seek resources in classpath. * * @since 2.1.3 */ protected boolean useClassPath; - public ChainedFileWriterEntry(File inputDirectory, + public ChainedFileWriterEntry(String inputPath, String includePattern, boolean useClassPath) { - this(inputDirectory, includePattern); + this(inputPath, includePattern); this.useClassPath = useClassPath; } - public ChainedFileWriterEntry(File inputDirectory, String includePattern) { - this.inputDirectory = inputDirectory; + public ChainedFileWriterEntry(String inputPath, String includePattern) { + this.inputPath = inputPath; this.includePattern = includePattern; } @@ -70,11 +70,17 @@ return includePattern; } - public File getInputDirectory() { - return inputDirectory; + public String getInputPath() { + return inputPath; } public boolean isUseClassPath() { return useClassPath; } + + @Override + public String toString() { + String s = ToStringBuilder.reflectionToString(this); + return s; + } } Modified: trunk/eugene/src/main/java/org/nuiton/eugene/writer/DefaultChainedWriterEngine.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/writer/DefaultChainedWriterEngine.java 2011-09-21 11:01:18 UTC (rev 1094) +++ trunk/eugene/src/main/java/org/nuiton/eugene/writer/DefaultChainedWriterEngine.java 2011-09-21 18:02:48 UTC (rev 1095) @@ -302,11 +302,11 @@ } // first thing is to merge entries (normal ones and classpath ones) - Map<File, List<String>> normalEntries = new HashMap<File, List<String>>(); - Map<File, List<String>> classpathEntries = new HashMap<File, List<String>>(); + Map<String, List<String>> normalEntries = new HashMap<String, List<String>>(); + Map<String, List<String>> classpathEntries = new HashMap<String, List<String>>(); for (ChainedFileWriterEntry e : writer.getEntries()) { - Map<File, List<String>> currentMap; + Map<String, List<String>> currentMap; if (e.isUseClassPath()) { @@ -315,7 +315,7 @@ currentMap = normalEntries; } - File input = e.getInputDirectory(); + String input = e.getInputPath(); List<String> includes = currentMap.get(input); if (includes == null) { includes = new ArrayList<String>(); @@ -339,7 +339,7 @@ } protected void addFilesToTreate(ChainedFileWriter writer, - Map<File, List<String>> entries, + Map<String, List<String>> entries, ChainedFileWriterData result, boolean useClassPath) throws IOException { @@ -351,21 +351,21 @@ Map<File, List<File>> filesByRoot = result.getFilesByRoot(); Map<File, List<File>> resourcesByFile = result.getResourcesByFile(); - for (Map.Entry<File, List<String>> entry : entries.entrySet()) { - File inputDirectory = entry.getKey(); + for (Map.Entry<String, List<String>> entry : entries.entrySet()) { + String inputDirectory = entry.getKey(); // final input directory to use (for class-path entries, we will // replace the class-path path by the extracted path - File realInputDirectory = inputDirectory; + File realInputDirectory = new File(inputDirectory); if (useClassPath) { // use the extracted path as input directory, otherwise there - // will have a problem : the incoming inputDirectory will not be + // will have a problem : the incoming inputPath will not be // an ancestor of his resources, so prefer to use the extracted // path which fix this problem. - String inputPath = inputDirectory.getAbsolutePath(); + String inputPath = inputDirectory; if (inputPath.equals("/")) { realInputDirectory = extractDirectory; } else { @@ -532,7 +532,7 @@ configuration.isTestPhase() ? writer.getDefaultTestInputDirectory() : writer.getDefaultInputDirectory() - ), + ).getAbsolutePath(), writer.getDefaultIncludes() ); return writerEntry; @@ -584,7 +584,7 @@ String includes = matcher.group(2); ChainedFileWriterEntry writerEntry = new ChainedFileWriterEntry( - new File(inputPath), + inputPath, includes, true ); @@ -638,7 +638,7 @@ String includes = matcher.group(2); ChainedFileWriterEntry writerEntry = new ChainedFileWriterEntry( - new File(configuration.getBasedir(), inputPath), + new File(configuration.getBasedir(), inputPath).getAbsolutePath(), includes ); return writerEntry; @@ -689,7 +689,7 @@ //TODO tchemit 2010-09-22 Should be able to do a pattern research ChainedFileWriterEntry writerEntry = new ChainedFileWriterEntry( - new File(inputPath), + inputPath, includes, true ); @@ -740,7 +740,7 @@ String inputPath = matcher.group(2); String includes = matcher.group(3); ChainedFileWriterEntry writerEntry = new ChainedFileWriterEntry( - new File(configuration.getBasedir(), inputPath), + new File(configuration.getBasedir(), inputPath).getAbsolutePath(), includes ); return writerEntry; Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java 2011-09-21 11:01:18 UTC (rev 1094) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java 2011-09-21 18:02:48 UTC (rev 1095) @@ -495,8 +495,7 @@ } if (dryRun || isVerbose()) { for (ChainedFileWriterEntry entry : writer.getEntries()) { - getLog().info(" entry : " + entry.getInputDirectory() + - " - " + entry.getIncludePattern()); + getLog().info(" entry : " + entry); } if (dryRun) { continue; Modified: trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriter.java =================================================================== --- trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriter.java 2011-09-21 11:01:18 UTC (rev 1094) +++ trunk/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriter.java 2011-09-21 18:02:48 UTC (rev 1095) @@ -80,7 +80,7 @@ @Override public final List<URL> getFiles(ChainedFileWriterConfiguration configuration, - File inputDirectory, + String inputPath, List<String> includePattern, boolean inClassPath) throws MalformedURLException, IllegalArgumentException { @@ -92,7 +92,7 @@ if (!inClassPath) { DirectoryScanner ds = new DirectoryScanner(); - + File inputDirectory = new File(inputPath); ds.setBasedir(inputDirectory); ds.setIncludes(includePattern.toArray(new String[includePattern.size()])); ds.setExcludes(null); @@ -111,7 +111,7 @@ for (String pattern : includePattern) { - String path = inputDirectory.getAbsolutePath(); + String path = inputPath; //FIXME must change the file.separator to / if (!path.endsWith("/")) {