| @@ -177,7 +177,7 @@ public class XmlLogger implements BuildLogger { | |||||
| } | } | ||||
| String outFilename = getProperty(event, "XmlLogger.file", "log.xml"); | String outFilename = getProperty(event, "XmlLogger.file", "log.xml"); | ||||
| String xslUri = getProperty(event, "ant.XmlLogger.stylesheet.uri", "log.xsl"); | String xslUri = getProperty(event, "ant.XmlLogger.stylesheet.uri", "log.xsl"); | ||||
| try (OutputStream stream = | try (OutputStream stream = | ||||
| outStream == null ? Files.newOutputStream(Paths.get(outFilename)) : outStream; | outStream == null ? Files.newOutputStream(Paths.get(outFilename)) : outStream; | ||||
| Writer out = new OutputStreamWriter(stream, "UTF8")) { | Writer out = new OutputStreamWriter(stream, "UTF8")) { | ||||
| @@ -62,13 +62,13 @@ public final class ChainReaderHelper { | |||||
| public String readFully() throws IOException { | public String readFully() throws IOException { | ||||
| return ChainReaderHelper.this.readFully(this); | return ChainReaderHelper.this.readFully(this); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void close() throws IOException { | public void close() throws IOException { | ||||
| cleanUpClassLoaders(cleanupLoaders); | cleanUpClassLoaders(cleanupLoaders); | ||||
| super.close(); | super.close(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected void finalize() throws Throwable { | protected void finalize() throws Throwable { | ||||
| try { | try { | ||||
| @@ -236,7 +236,7 @@ public final class ChainReaderHelper { | |||||
| final List<Object> finalFilters = | final List<Object> finalFilters = | ||||
| filterChains.stream().map(FilterChain::getFilterReaders) | filterChains.stream().map(FilterChain::getFilterReaders) | ||||
| .flatMap(Collection::stream).collect(Collectors.toList()); | .flatMap(Collection::stream).collect(Collectors.toList()); | ||||
| if (!finalFilters.isEmpty()) { | if (!finalFilters.isEmpty()) { | ||||
| boolean success = false; | boolean success = false; | ||||
| try { | try { | ||||
| @@ -422,7 +422,7 @@ public class Ant extends Task { | |||||
| "%s task calling its own parent target.", | "%s task calling its own parent target.", | ||||
| getTaskName()); | getTaskName()); | ||||
| } | } | ||||
| final Map<String, Target> targetsMap = getProject().getTargets(); | final Map<String, Target> targetsMap = getProject().getTargets(); | ||||
| if (locals.stream().map(targetsMap::get) | if (locals.stream().map(targetsMap::get) | ||||
| @@ -214,7 +214,7 @@ public class AntStructure extends Task { | |||||
| final Set<String> types) { | final Set<String> types) { | ||||
| out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); | out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); | ||||
| out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">"); | out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">"); | ||||
| out.println(tasks.stream().collect( | out.println(tasks.stream().collect( | ||||
| Collectors.joining(" | ", "<!ENTITY % tasks \"", "\">"))); | Collectors.joining(" | ", "<!ENTITY % tasks \"", "\">"))); | ||||
| @@ -159,7 +159,7 @@ public class Antlib extends Task implements TaskContainer { | |||||
| @Override | @Override | ||||
| public void execute() { | public void execute() { | ||||
| //TODO handle tasks added via #addTask() | //TODO handle tasks added via #addTask() | ||||
| for (Task task : tasks) { | for (Task task : tasks) { | ||||
| UnknownElement ue = (UnknownElement) task; | UnknownElement ue = (UnknownElement) task; | ||||
| setLocation(ue.getLocation()); | setLocation(ue.getLocation()); | ||||
| @@ -85,7 +85,7 @@ public class Delete extends MatchingTask { | |||||
| SymbolicLinkUtils.getSymbolicLinkUtils(); | SymbolicLinkUtils.getSymbolicLinkUtils(); | ||||
| private static class ReverseDirs implements ResourceCollection { | private static class ReverseDirs implements ResourceCollection { | ||||
| private Project project; | private Project project; | ||||
| private File basedir; | private File basedir; | ||||
| private String[] dirs; | private String[] dirs; | ||||
| @@ -61,12 +61,12 @@ import org.apache.tools.zip.ZipFile; | |||||
| */ | */ | ||||
| public class Expand extends Task { | public class Expand extends Task { | ||||
| public static final String NATIVE_ENCODING = "native-encoding"; | public static final String NATIVE_ENCODING = "native-encoding"; | ||||
| /** Error message when more that one mapper is defined */ | /** Error message when more that one mapper is defined */ | ||||
| public static final String ERROR_MULTIPLE_MAPPERS = "Cannot define more than one mapper"; | public static final String ERROR_MULTIPLE_MAPPERS = "Cannot define more than one mapper"; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
| private static final int BUFFER_SIZE = 1024; | private static final int BUFFER_SIZE = 1024; | ||||
| private File dest; //req | private File dest; //req | ||||
| private File source; // req | private File source; // req | ||||
| @@ -185,7 +185,7 @@ public class Expand extends Task { | |||||
| getLocation()); | getLocation()); | ||||
| } | } | ||||
| try ( | try ( | ||||
| ZipFile | |||||
| ZipFile | |||||
| zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)){ | zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)){ | ||||
| boolean empty = true; | boolean empty = true; | ||||
| Enumeration<ZipEntry> e = zf.getEntries(); | Enumeration<ZipEntry> e = zf.getEntries(); | ||||
| @@ -1907,7 +1907,7 @@ public class Javadoc extends Task { | |||||
| if (doclet.getName() == null) { | if (doclet.getName() == null) { | ||||
| throw new BuildException("The doclet name must be specified.", | throw new BuildException("The doclet name must be specified.", | ||||
| getLocation()); | getLocation()); | ||||
| } | |||||
| } | |||||
| toExecute.createArgument().setValue("-doclet"); | toExecute.createArgument().setValue("-doclet"); | ||||
| toExecute.createArgument().setValue(doclet.getName()); | toExecute.createArgument().setValue(doclet.getName()); | ||||
| if (doclet.getPath() != null) { | if (doclet.getPath() != null) { | ||||
| @@ -626,7 +626,7 @@ public class Replace extends MatchingTask { | |||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| try ( | try ( | ||||
| InputStream | |||||
| InputStream | |||||
| in = propertyResource.getInputStream()){ | in = propertyResource.getInputStream()){ | ||||
| props.load(in); | props.load(in); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| @@ -91,7 +91,7 @@ public class Rmic extends MatchingTask { | |||||
| /** rmic failed message */ | /** rmic failed message */ | ||||
| public static final String ERROR_RMIC_FAILED | public static final String ERROR_RMIC_FAILED | ||||
| = "Rmic failed; see the compiler error output for details."; | = "Rmic failed; see the compiler error output for details."; | ||||
| /** unable to verify message */ | /** unable to verify message */ | ||||
| public static final String ERROR_UNABLE_TO_VERIFY_CLASS = "Unable to verify class "; | public static final String ERROR_UNABLE_TO_VERIFY_CLASS = "Unable to verify class "; | ||||
| /** could not be found message */ | /** could not be found message */ | ||||
| @@ -45,7 +45,7 @@ public class Http extends ProjectComponent implements Condition { | |||||
| private boolean followRedirects = true; | private boolean followRedirects = true; | ||||
| private int errorsBeginAt = ERROR_BEGINS; | private int errorsBeginAt = ERROR_BEGINS; | ||||
| /** | /** | ||||
| * Set the url attribute | * Set the url attribute | ||||
| * @param url the url of the request | * @param url the url of the request | ||||
| @@ -532,8 +532,7 @@ public class EmailTask extends Task { | |||||
| // identify which files should be attached | // identify which files should be attached | ||||
| Vector<File> files = new Vector<>(); | Vector<File> files = new Vector<>(); | ||||
| if (attachments != null) { | if (attachments != null) { | ||||
| for (Resource r : attachments) { | for (Resource r : attachments) { | ||||
| files.add(r.as(FileProvider.class).getFile()); | files.add(r.as(FileProvider.class).getFile()); | ||||
| @@ -283,7 +283,7 @@ public class MimeMailer extends Mailer { | |||||
| private static InternetAddress[] internetAddresses(final Vector<EmailAddress> list) | private static InternetAddress[] internetAddresses(final Vector<EmailAddress> list) | ||||
| throws AddressException, UnsupportedEncodingException { | throws AddressException, UnsupportedEncodingException { | ||||
| final int size = list.size(); | final int size = list.size(); | ||||
| final InternetAddress[] addrs = new InternetAddress[size]; | final InternetAddress[] addrs = new InternetAddress[size]; | ||||
| @@ -306,7 +306,7 @@ public class ANTLR extends Task { | |||||
| int err = run(commandline.getCommandline()); | int err = run(commandline.getCommandline()); | ||||
| if (err != 0) { | if (err != 0) { | ||||
| throw new BuildException("ANTLR returned: " + err, getLocation()); | throw new BuildException("ANTLR returned: " + err, getLocation()); | ||||
| } | |||||
| } | |||||
| String output = bos.toString(); | String output = bos.toString(); | ||||
| if (output.indexOf("error:") > -1) { | if (output.indexOf("error:") > -1) { | ||||
| throw new BuildException("ANTLR signaled an error: " | throw new BuildException("ANTLR signaled an error: " | ||||
| @@ -786,7 +786,7 @@ public class NetRexxC extends MatchingTask { | |||||
| String[] compileArgs = | String[] compileArgs = | ||||
| Stream.concat(Stream.of(compileOptionsArray), compileList.stream()) | Stream.concat(Stream.of(compileOptionsArray), compileList.stream()) | ||||
| .toArray(String[]::new); | .toArray(String[]::new); | ||||
| // need to set java.class.path property and restore it later | // need to set java.class.path property and restore it later | ||||
| // since the NetRexx compiler has no option for the classpath | // since the NetRexx compiler has no option for the classpath | ||||
| String currentClassPath = System.getProperty("java.class.path"); | String currentClassPath = System.getProperty("java.class.path"); | ||||
| @@ -32,7 +32,7 @@ public interface ClassFileIterator extends Iterable<ClassFile> { | |||||
| * @return the next class file in the iteration | * @return the next class file in the iteration | ||||
| */ | */ | ||||
| ClassFile getNextClassFile(); | ClassFile getNextClassFile(); | ||||
| @Override | @Override | ||||
| default Iterator<ClassFile> iterator() { | default Iterator<ClassFile> iterator() { | ||||
| @@ -58,7 +58,7 @@ public interface ClassFileIterator extends Iterable<ClassFile> { | |||||
| next = getNextClassFile(); | next = getNextClassFile(); | ||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| } | } | ||||
| } | } | ||||
| @@ -245,7 +245,7 @@ public class Depend extends MatchingTask { | |||||
| Difference diff = new Difference(); | Difference diff = new Difference(); | ||||
| diff.add(destPath); | diff.add(destPath); | ||||
| diff.add(dependClasspath); | diff.add(dependClasspath); | ||||
| Path p; | Path p; | ||||
| if (diff.isEmpty()) { | if (diff.isEmpty()) { | ||||
| p = null; | p = null; | ||||
| @@ -762,10 +762,10 @@ public class Depend extends MatchingTask { | |||||
| if (file.getName().endsWith(".class")) { | if (file.getName().endsWith(".class")) { | ||||
| ClassFileInfo info = new ClassFileInfo(); | ClassFileInfo info = new ClassFileInfo(); | ||||
| info.absoluteFile = file; | info.absoluteFile = file; | ||||
| String relativeName = file.getPath().substring(rootLength + 1, | String relativeName = file.getPath().substring(rootLength + 1, | ||||
| file.getPath().length() - ".class".length()); | file.getPath().length() - ".class".length()); | ||||
| info.className | info.className | ||||
| = ClassFileUtils.convertSlashName(relativeName); | = ClassFileUtils.convertSlashName(relativeName); | ||||
| info.sourceFile = sourceFileKnownToExist = | info.sourceFile = sourceFileKnownToExist = | ||||
| @@ -307,7 +307,7 @@ public class IPlanetEjbcTask extends Task { | |||||
| private Path getClasspath() { | private Path getClasspath() { | ||||
| if (classpath == null) { | if (classpath == null) { | ||||
| return new Path(getProject()).concatSystemClasspath("last"); | return new Path(getProject()).concatSystemClasspath("last"); | ||||
| } | |||||
| } | |||||
| return classpath.concatSystemClasspath("ignore"); | return classpath.concatSystemClasspath("ignore"); | ||||
| } | } | ||||
| } | } | ||||
| @@ -583,13 +583,13 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||||
| String genicClass; // GenIC class (3 are supported for various | String genicClass; // GenIC class (3 are supported for various | ||||
| // versions | // versions | ||||
| // work around a bug of GenIC 2.5 | // work around a bug of GenIC 2.5 | ||||
| // class name (search in the classpath provided for the ejbjar element) | // class name (search in the classpath provided for the ejbjar element) | ||||
| genicClass = getGenicClassName(classpath); | genicClass = getGenicClassName(classpath); | ||||
| if (genicClass == null) { | if (genicClass == null) { | ||||
| log("Cannot find GenIC class in classpath.", Project.MSG_ERR); | log("Cannot find GenIC class in classpath.", Project.MSG_ERR); | ||||
| throw new BuildException("GenIC class not found, please check the classpath."); | throw new BuildException("GenIC class not found, please check the classpath."); | ||||
| } | |||||
| } | |||||
| log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE); | log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE); | ||||
| genicTask.setClassname(genicClass); | genicTask.setClassname(genicClass); | ||||
| @@ -83,7 +83,7 @@ public final class ExtensionUtil { | |||||
| final List<FileSet> libraries) | final List<FileSet> libraries) | ||||
| throws BuildException { | throws BuildException { | ||||
| final List<Extension> extensions = new ArrayList<>(); | final List<Extension> extensions = new ArrayList<>(); | ||||
| for (FileSet fileSet : libraries) { | for (FileSet fileSet : libraries) { | ||||
| boolean includeImpl = true; | boolean includeImpl = true; | ||||
| boolean includeURL = true; | boolean includeURL = true; | ||||
| @@ -364,14 +364,14 @@ public class Translate extends MatchingTask { | |||||
| Locale locale = new Locale(bundleLanguage, | Locale locale = new Locale(bundleLanguage, | ||||
| bundleCountry, | bundleCountry, | ||||
| bundleVariant); | bundleVariant); | ||||
| String language = locale.getLanguage().length() > 0 | String language = locale.getLanguage().length() > 0 | ||||
| ? "_" + locale.getLanguage() : ""; | ? "_" + locale.getLanguage() : ""; | ||||
| String country = locale.getCountry().length() > 0 | String country = locale.getCountry().length() > 0 | ||||
| ? "_" + locale.getCountry() : ""; | ? "_" + locale.getCountry() : ""; | ||||
| String variant = locale.getVariant().length() > 0 | String variant = locale.getVariant().length() > 0 | ||||
| ? "_" + locale.getVariant() : ""; | ? "_" + locale.getVariant() : ""; | ||||
| processBundle(bundle + language + country + variant, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY_VARIANT, false); | processBundle(bundle + language + country + variant, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY_VARIANT, false); | ||||
| processBundle(bundle + language + country, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY, false); | processBundle(bundle + language + country, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY, false); | ||||
| processBundle(bundle + language, BUNDLE_SPECIFIED_LANGUAGE, false); | processBundle(bundle + language, BUNDLE_SPECIFIED_LANGUAGE, false); | ||||
| @@ -584,7 +584,7 @@ public class JDependTask extends Task { | |||||
| getWorkingPath().ifPresent(path -> { | getWorkingPath().ifPresent(path -> { | ||||
| for (String filepath : path.list()) { | for (String filepath : path.list()) { | ||||
| File f = new File(filepath); | File f = new File(filepath); | ||||
| // not necessary as JDepend would fail, but why loose | // not necessary as JDepend would fail, but why loose | ||||
| // some time? | // some time? | ||||
| if (!f.exists() || !f.isDirectory()) { | if (!f.exists() || !f.isDirectory()) { | ||||
| @@ -1672,7 +1672,7 @@ public class JUnitTask extends Task { | |||||
| final int count = batchTests.size(); | final int count = batchTests.size(); | ||||
| @SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
| final Enumeration<JUnitTest>[] enums = new Enumeration[ count + 1]; | final Enumeration<JUnitTest>[] enums = new Enumeration[ count + 1]; | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| final BatchTest batchtest = batchTests.get(i); | final BatchTest batchtest = batchTests.get(i); | ||||
| enums[i] = batchtest.elements(); | enums[i] = batchtest.elements(); | ||||
| @@ -37,7 +37,7 @@ public final class SunNative2Ascii extends DefaultNative2Ascii { | |||||
| public static final String IMPLEMENTATION_NAME = "sun"; | public static final String IMPLEMENTATION_NAME = "sun"; | ||||
| private static final String SUN_TOOLS_NATIVE2ASCII_MAIN = "sun.tools.native2ascii.Main"; | private static final String SUN_TOOLS_NATIVE2ASCII_MAIN = "sun.tools.native2ascii.Main"; | ||||
| /** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
| @Override | @Override | ||||
| protected void setup(Commandline cmd, Native2Ascii args) | protected void setup(Commandline cmd, Native2Ascii args) | ||||
| @@ -949,7 +949,7 @@ public abstract class AbstractFileSet extends DataType | |||||
| if (isReference()) { | if (isReference()) { | ||||
| super.dieOnCircularReference(stk, p); | super.dieOnCircularReference(stk, p); | ||||
| } else { | } else { | ||||
| selectors.stream().filter(DataType.class::isInstance).forEach(fileSelector -> | |||||
| selectors.stream().filter(DataType.class::isInstance).forEach(fileSelector -> | |||||
| pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p) | pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p) | ||||
| ); | ); | ||||
| for (PatternSet ps : additionalPatterns) { | for (PatternSet ps : additionalPatterns) { | ||||
| @@ -60,7 +60,7 @@ public class ZipScanner extends ArchiveScanner { | |||||
| File srcFile = src.asOptional(FileProvider.class) | File srcFile = src.asOptional(FileProvider.class) | ||||
| .map(FileProvider::getFile).orElseThrow(() -> new BuildException( | .map(FileProvider::getFile).orElseThrow(() -> new BuildException( | ||||
| "Only file provider resources are supported")); | "Only file provider resources are supported")); | ||||
| try (ZipFile zf = new ZipFile(srcFile, encoding)) { | try (ZipFile zf = new ZipFile(srcFile, encoding)) { | ||||
| Enumeration<ZipEntry> e = zf.getEntries(); | Enumeration<ZipEntry> e = zf.getEntries(); | ||||
| @@ -87,4 +87,4 @@ public class ZipScanner extends ArchiveScanner { | |||||
| throw new BuildException("Problem opening " + srcFile, ex); | throw new BuildException("Problem opening " + srcFile, ex); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| } | |||||
| @@ -89,7 +89,7 @@ public class ClassfileSet extends FileSet { | |||||
| super(s); | super(s); | ||||
| rootClasses.addAll(s.rootClasses); | rootClasses.addAll(s.rootClasses); | ||||
| } | } | ||||
| /** | /** | ||||
| * Add a fileset to which contains a collection of root classes used to | * Add a fileset to which contains a collection of root classes used to | ||||
| * drive the search from classes. | * drive the search from classes. | ||||
| @@ -125,9 +125,9 @@ public class DependScanner extends DirectoryScanner { | |||||
| Set<String> parentSet = Stream.of(parentScanner.getIncludedFiles()) | Set<String> parentSet = Stream.of(parentScanner.getIncludedFiles()) | ||||
| .collect(Collectors.toSet()); | .collect(Collectors.toSet()); | ||||
| Enumeration<String> e = analyzer.getClassDependencies(); | Enumeration<String> e = analyzer.getClassDependencies(); | ||||
| while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
| String classname = e.nextElement(); | String classname = e.nextElement(); | ||||
| String filename = | String filename = | ||||
| @@ -190,7 +190,7 @@ public class Archives extends DataType | |||||
| setChecked(true); | setChecked(true); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected Archives getCheckedRef() { | protected Archives getCheckedRef() { | ||||
| return (Archives) super.getCheckedRef(); | return (Archives) super.getCheckedRef(); | ||||
| @@ -247,7 +247,7 @@ public abstract class BaseResourceCollectionContainer | |||||
| return coll.stream().map(Object::toString) | return coll.stream().map(Object::toString) | ||||
| .collect(Collectors.joining(File.pathSeparator)); | .collect(Collectors.joining(File.pathSeparator)); | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected BaseResourceCollectionContainer getCheckedRef() { | protected BaseResourceCollectionContainer getCheckedRef() { | ||||
| return (BaseResourceCollectionContainer) super.getCheckedRef(); | return (BaseResourceCollectionContainer) super.getCheckedRef(); | ||||
| @@ -406,7 +406,7 @@ public class FileResource extends Resource implements Touchable, FileProvider, | |||||
| } | } | ||||
| return fileResource; | return fileResource; | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected FileResource getCheckedRef() { | protected FileResource getCheckedRef() { | ||||
| return (FileResource) super.getCheckedRef(); | return (FileResource) super.getCheckedRef(); | ||||
| @@ -232,5 +232,5 @@ public class ResourceList extends DataType implements ResourceCollection { | |||||
| } | } | ||||
| return new FileResource(getProject(), expandedLine); | return new FileResource(getProject(), expandedLine); | ||||
| } | } | ||||
| } | } | ||||
| @@ -155,7 +155,7 @@ public class Restrict | |||||
| setChecked(true); | setChecked(true); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected Restrict getCheckedRef() { | protected Restrict getCheckedRef() { | ||||
| return (Restrict) super.getCheckedRef(); | return (Restrict) super.getCheckedRef(); | ||||
| @@ -118,7 +118,7 @@ s. | |||||
| setChecked(true); | setChecked(true); | ||||
| } | } | ||||
| } | } | ||||
| private static Comparator<Resource> composite(List<? extends Comparator<Resource>> foo) { | private static Comparator<Resource> composite(List<? extends Comparator<Resource>> foo) { | ||||
| Comparator<Resource> result = null; | Comparator<Resource> result = null; | ||||
| if (foo != null) { | if (foo != null) { | ||||
| @@ -45,7 +45,7 @@ public class FileSystem extends ResourceComparator { | |||||
| protected int resourceCompare(Resource foo, Resource bar) { | protected int resourceCompare(Resource foo, Resource bar) { | ||||
| return compare(file(foo), file(bar)); | return compare(file(foo), file(bar)); | ||||
| } | } | ||||
| private File file(Resource r) { | private File file(Resource r) { | ||||
| return r.asOptional(FileProvider.class) | return r.asOptional(FileProvider.class) | ||||
| .orElseThrow(() -> new ClassCastException( | .orElseThrow(() -> new ClassCastException( | ||||
| @@ -132,7 +132,7 @@ public class Name implements ResourceSelector { | |||||
| private boolean matches(String name) { | private boolean matches(String name) { | ||||
| if (pattern != null) { | if (pattern != null) { | ||||
| return SelectorUtils.match(modify(pattern), modify(name), cs); | return SelectorUtils.match(modify(pattern), modify(name), cs); | ||||
| } | |||||
| } | |||||
| if (reg == null) { | if (reg == null) { | ||||
| reg = new RegularExpression(); | reg = new RegularExpression(); | ||||
| reg.setPattern(regex); | reg.setPattern(regex); | ||||
| @@ -359,10 +359,10 @@ public abstract class AbstractSelectorContainer extends DataType | |||||
| throw new BuildException(e); | throw new BuildException(e); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected AbstractSelectorContainer getCheckedRef() { | protected AbstractSelectorContainer getCheckedRef() { | ||||
| return (AbstractSelectorContainer) super.getCheckedRef(); | return (AbstractSelectorContainer) super.getCheckedRef(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -32,7 +32,7 @@ public class TypeSelector extends BaseExtendSelector { | |||||
| /** Key to used for parameterized custom selector */ | /** Key to used for parameterized custom selector */ | ||||
| public static final String TYPE_KEY = "type"; | public static final String TYPE_KEY = "type"; | ||||
| private String type = null; | private String type = null; | ||||
| /** | /** | ||||
| @@ -81,7 +81,7 @@ public class RegexpPatternMapper implements FileNameMapper { | |||||
| public void setFrom(String from) throws BuildException { | public void setFrom(String from) throws BuildException { | ||||
| if (from == null) { | if (from == null) { | ||||
| throw new BuildException("this mapper requires a 'from' attribute"); | throw new BuildException("this mapper requires a 'from' attribute"); | ||||
| } | |||||
| } | |||||
| try { | try { | ||||
| reg.setPattern(from); | reg.setPattern(from); | ||||
| } catch (NoClassDefFoundError e) { | } catch (NoClassDefFoundError e) { | ||||
| @@ -97,7 +97,7 @@ public class SourceFileScanner implements ResourceFactory { | |||||
| public String getName() { | public String getName() { | ||||
| return f; | return f; | ||||
| } | } | ||||
| }).toArray(Resource[]::new); | |||||
| }).toArray(Resource[]::new); | |||||
| // build the list of sources which are out of date with | // build the list of sources which are out of date with | ||||
| // respect to the target | // respect to the target | ||||
| @@ -34,36 +34,36 @@ import static org.junit.Assert.fail; | |||||
| public class LazyResourceCollectionTest { | public class LazyResourceCollectionTest { | ||||
| private class StringResourceCollection implements ResourceCollection { | private class StringResourceCollection implements ResourceCollection { | ||||
| List<StringResourceIterator> createdIterators = new ArrayList<>(); | |||||
| List<StringResourceIterator> createdIterators = new ArrayList<>(); | |||||
| @Override | |||||
| @Override | |||||
| public int size() { | public int size() { | ||||
| return 3; | |||||
| return 3; | |||||
| } | } | ||||
| @Override | |||||
| @Override | |||||
| public Iterator<Resource> iterator() { | public Iterator<Resource> iterator() { | ||||
| StringResourceIterator it = new StringResourceIterator(); | StringResourceIterator it = new StringResourceIterator(); | ||||
| createdIterators.add(it); | createdIterators.add(it); | ||||
| return it; | return it; | ||||
| } | } | ||||
| @Override | |||||
| @Override | |||||
| public boolean isFilesystemOnly() { | public boolean isFilesystemOnly() { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| private class StringResourceIterator implements Iterator<Resource> { | |||||
| private class StringResourceIterator implements Iterator<Resource> { | |||||
| int cursor = 0; | int cursor = 0; | ||||
| @Override | |||||
| @Override | |||||
| public void remove() { | public void remove() { | ||||
| throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
| } | } | ||||
| @Override | |||||
| public StringResource next() { | |||||
| @Override | |||||
| public StringResource next() { | |||||
| if (cursor < 3) { | if (cursor < 3) { | ||||
| cursor++; | cursor++; | ||||
| return new StringResource("r" + cursor); | return new StringResource("r" + cursor); | ||||
| @@ -71,7 +71,7 @@ public class LazyResourceCollectionTest { | |||||
| return null; | return null; | ||||
| } | } | ||||
| @Override | |||||
| @Override | |||||
| public boolean hasNext() { | public boolean hasNext() { | ||||
| return cursor < 3; | return cursor < 3; | ||||
| } | } | ||||
| @@ -85,25 +85,25 @@ public class LazyResourceCollectionTest { | |||||
| Iterator<Resource> it = lazyCollection.iterator(); | Iterator<Resource> it = lazyCollection.iterator(); | ||||
| assertOneCreatedIterator(collectionTest); | assertOneCreatedIterator(collectionTest); | ||||
| StringResourceIterator stringResourceIterator = | |||||
| collectionTest.createdIterators.get(0); | |||||
| StringResourceIterator stringResourceIterator = | |||||
| collectionTest.createdIterators.get(0); | |||||
| assertEquals("A resource was loaded without iterating", 1, | assertEquals("A resource was loaded without iterating", 1, | ||||
| stringResourceIterator.cursor); | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r1", it.next()); | |||||
| assertStringValue("r1", it.next()); | |||||
| assertOneCreatedIterator(collectionTest); | assertOneCreatedIterator(collectionTest); | ||||
| assertEquals("Iterating once load more than 1 resource", 2, | assertEquals("Iterating once load more than 1 resource", 2, | ||||
| stringResourceIterator.cursor); | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r2", it.next()); | |||||
| assertStringValue("r2", it.next()); | |||||
| assertOneCreatedIterator(collectionTest); | assertOneCreatedIterator(collectionTest); | ||||
| assertEquals("Iterating twice load more than 2 resources", 3, | assertEquals("Iterating twice load more than 2 resources", 3, | ||||
| stringResourceIterator.cursor); | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r3", it.next()); | |||||
| assertStringValue("r3", it.next()); | |||||
| assertOneCreatedIterator(collectionTest); | assertOneCreatedIterator(collectionTest); | ||||
| assertEquals("Iterating 3 times load more than 3 resources", 3, | assertEquals("Iterating 3 times load more than 3 resources", 3, | ||||
| stringResourceIterator.cursor); | |||||
| stringResourceIterator.cursor); | |||||
| try { | try { | ||||
| it.next(); | it.next(); | ||||
| @@ -131,37 +131,37 @@ public class LazyResourceCollectionTest { | |||||
| Iterator<Resource> it2 = lazyCollection.iterator(); | Iterator<Resource> it2 = lazyCollection.iterator(); | ||||
| assertOneCreatedIterator(collectionTest); | assertOneCreatedIterator(collectionTest); | ||||
| StringResourceIterator stringResourceIterator = | |||||
| collectionTest.createdIterators.get(0); | |||||
| StringResourceIterator stringResourceIterator = | |||||
| collectionTest.createdIterators.get(0); | |||||
| assertEquals("A resource was loaded without iterating", 1, | assertEquals("A resource was loaded without iterating", 1, | ||||
| stringResourceIterator.cursor); | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r1", it1.next()); | |||||
| assertStringValue("r1", it1.next()); | |||||
| assertEquals("Iterating once load more than 1 resource", 2, | assertEquals("Iterating once load more than 1 resource", 2, | ||||
| stringResourceIterator.cursor); | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r1", it2.next()); | |||||
| assertStringValue("r1", it2.next()); | |||||
| assertEquals( | assertEquals( | ||||
| "The second iterator did not lookup in the cache for a resource", 2, | |||||
| stringResourceIterator.cursor); | |||||
| "The second iterator did not lookup in the cache for a resource", 2, | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r2", it2.next()); | |||||
| assertStringValue("r2", it2.next()); | |||||
| assertEquals("Iterating twice load more than 2 resources", 3, | assertEquals("Iterating twice load more than 2 resources", 3, | ||||
| stringResourceIterator.cursor); | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r2", it1.next()); | |||||
| assertStringValue("r2", it1.next()); | |||||
| assertEquals( | assertEquals( | ||||
| "The first iterator did not lookup in the cache for a resource", 3, | |||||
| stringResourceIterator.cursor); | |||||
| "The first iterator did not lookup in the cache for a resource", 3, | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r3", it2.next()); | |||||
| assertStringValue("r3", it2.next()); | |||||
| assertEquals("Iterating 3 times load more than 3 resources", 3, | assertEquals("Iterating 3 times load more than 3 resources", 3, | ||||
| stringResourceIterator.cursor); | |||||
| stringResourceIterator.cursor); | |||||
| assertStringValue("r3", it1.next()); | |||||
| assertStringValue("r3", it1.next()); | |||||
| assertEquals( | assertEquals( | ||||
| "The first iterator did not lookup in the cache for a resource", 3, | |||||
| stringResourceIterator.cursor); | |||||
| "The first iterator did not lookup in the cache for a resource", 3, | |||||
| stringResourceIterator.cursor); | |||||
| try { | try { | ||||
| it1.next(); | it1.next(); | ||||
| @@ -177,8 +177,8 @@ public class LazyResourceCollectionTest { | |||||
| // ok | // ok | ||||
| } | } | ||||
| } | } | ||||
| private void assertStringValue(String expected, Resource r) { | |||||
| assertEquals(expected, r.as(StringResource.class).getValue()); | |||||
| } | |||||
| private void assertStringValue(String expected, Resource r) { | |||||
| assertEquals(expected, r.as(StringResource.class).getValue()); | |||||
| } | |||||
| } | } | ||||