org.gradle.api.file.DuplicatesStrategy Java Examples
The following examples show how to use
org.gradle.api.file.DuplicatesStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrepareWebjars.java From gradle-plugins with MIT License | 6 votes |
@TaskAction public void extractWebjars() { getProject().sync(sync -> { sync.into(outputDirectory); sync.setDuplicatesStrategy(DuplicatesStrategy.WARN); webjars.filter(File::isFile).getFiles().forEach(file -> sync.from(getProject().zipTree(file), jarSpec -> { jarSpec.include("META-INF/resources/webjars/**"); jarSpec.setIncludeEmptyDirs(false); jarSpec.eachFile(fcd -> fcd.setPath(fcd.getPath().replaceFirst("META-INF/resources/webjars/(.*?)/(.*?)/", "$1/"))); }) ); }); }
Example #2
Source File: PrepareWebjars.java From gradle-plugins with MIT License | 6 votes |
@TaskAction public void extractWebjars() { getProject().sync(sync -> { sync.into(outputDirectory); sync.setDuplicatesStrategy(DuplicatesStrategy.WARN); webjars.filter(File::isFile).getFiles().forEach(file -> sync.from(getProject().zipTree(file), jarSpec -> { jarSpec.include("META-INF/resources/webjars/**"); jarSpec.setIncludeEmptyDirs(false); jarSpec.eachFile(fcd -> fcd.setPath(fcd.getPath().replaceFirst("META-INF/resources/webjars/(.*?)/(.*?)/", "$1/"))); }) ); }); }
Example #3
Source File: DuplicateHandlingCopyActionDecorator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult execute(final CopyActionProcessingStream stream) { final Set<RelativePath> visitedFiles = new HashSet<RelativePath>(); return delegate.execute(new CopyActionProcessingStream() { public void process(final CopyActionProcessingStreamAction action) { stream.process(new CopyActionProcessingStreamAction() { public void processFile(FileCopyDetailsInternal details) { if (!details.isDirectory()) { DuplicatesStrategy strategy = details.getDuplicatesStrategy(); if (!visitedFiles.add(details.getRelativePath())) { if (strategy == DuplicatesStrategy.EXCLUDE) { return; } else if (strategy == DuplicatesStrategy.FAIL) { throw new DuplicateFileCopyingException(String.format("Encountered duplicate path \"%s\" during copy operation configured with DuplicatesStrategy.FAIL", details.getRelativePath())); } else if (strategy == DuplicatesStrategy.WARN) { LOGGER.warn("Encountered duplicate path \"{}\" during copy operation configured with DuplicatesStrategy.WARN", details.getRelativePath()); } } } action.processFile(details); } }); } }); }
Example #4
Source File: DuplicateHandlingCopyActionDecorator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult execute(final CopyActionProcessingStream stream) { final Set<RelativePath> visitedFiles = new HashSet<RelativePath>(); return delegate.execute(new CopyActionProcessingStream() { public void process(final CopyActionProcessingStreamAction action) { stream.process(new CopyActionProcessingStreamAction() { public void processFile(FileCopyDetailsInternal details) { if (!details.isDirectory()) { DuplicatesStrategy strategy = details.getDuplicatesStrategy(); if (!visitedFiles.add(details.getRelativePath())) { if (strategy == DuplicatesStrategy.EXCLUDE) { return; } else if (strategy == DuplicatesStrategy.FAIL) { throw new DuplicateFileCopyingException(String.format("Encountered duplicate path \"%s\" during copy operation configured with DuplicatesStrategy.FAIL", details.getRelativePath())); } else if (strategy == DuplicatesStrategy.WARN) { LOGGER.warn("Encountered duplicate path \"{}\" during copy operation configured with DuplicatesStrategy.WARN", details.getRelativePath()); } } } action.processFile(details); } }); } }); }
Example #5
Source File: WarOverlay.java From gradle-plugins with MIT License | 5 votes |
public WarOverlay(String name, War warTask) { this.name = name; this.warTask = warTask; this.warCopySpec = warTask.getRootSpec().addChild(); warCopySpec.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE); exclude("META-INF/maven/**"); exclude("META-INF/MANIFEST.MF"); }
Example #6
Source File: WarOverlay.java From gradle-plugins with MIT License | 5 votes |
public WarOverlay(String name, War warTask) { this.name = name; this.warTask = warTask; this.warCopySpec = warTask.getRootSpec().addChild(); warCopySpec.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE); exclude("META-INF/maven/**"); exclude("META-INF/MANIFEST.MF"); }
Example #7
Source File: DuplicateHandlingCopyActionDecorator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult execute(final CopyActionProcessingStream stream) { final Set<RelativePath> visitedFiles = new HashSet<RelativePath>(); return delegate.execute(new CopyActionProcessingStream() { public void process(final CopyActionProcessingStreamAction action) { stream.process(new CopyActionProcessingStreamAction() { public void processFile(FileCopyDetailsInternal details) { if (!details.isDirectory()) { DuplicatesStrategy strategy = details.getDuplicatesStrategy(); if (!visitedFiles.add(details.getRelativePath())) { if (strategy == DuplicatesStrategy.EXCLUDE) { return; } else if (strategy == DuplicatesStrategy.FAIL) { throw new DuplicateFileCopyingException(String.format("Encountered duplicate path \"%s\" during copy operation configured with DuplicatesStrategy.FAIL", details.getRelativePath())); } else if (strategy == DuplicatesStrategy.WARN) { LOGGER.warn("Encountered duplicate path \"{}\" during copy operation configured with DuplicatesStrategy.WARN", details.getRelativePath()); } } } action.processFile(details); } }); } }); }
Example #8
Source File: CloudServicesPackagingPlugin.java From commerce-gradle-plugin with Apache License 2.0 | 5 votes |
private void setupSolrPackaging(Project p, PackagingExtension extension, Path packageFolder, Zip zipPackage, Task cleanTargetFolder) { // FIXME This is only POC for Solr configuration only. Set<String> environments = extension.getEnvironments().get(); Path configurationFolder = extension.getConfigurationFolder().getAsFile().get().toPath(); for (String environment : environments) { Path sourceFolder = configurationFolder.resolve(environment).resolve("solr"); Path commonFolder = configurationFolder.resolve(COMMON_CONFIG).resolve("solr"); Path targetFolder = packageFolder.resolve("solr/config/" + environment); Copy copySolrCommonConfig = p.getTasks().create("copySolrCommonEnv_" + environment, Copy.class, t -> { t.from(commonFolder); t.into(targetFolder); t.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); t.exclude(SOLR_CONFIG_EXCLUDE); }); copySolrCommonConfig.dependsOn(cleanTargetFolder); Copy copySolrConfig = p.getTasks().create("copySolrEnv_" + environment, Copy.class, t -> { t.from(sourceFolder); t.into(targetFolder); t.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); t.exclude(SOLR_CONFIG_EXCLUDE); }); copySolrConfig.dependsOn(copySolrCommonConfig); zipPackage.dependsOn(copySolrConfig); } }
Example #9
Source File: DuplicateHandlingCopyActionDecorator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult execute(final CopyActionProcessingStream stream) { final Set<RelativePath> visitedFiles = new HashSet<RelativePath>(); return delegate.execute(new CopyActionProcessingStream() { public void process(final CopyActionProcessingStreamAction action) { stream.process(new CopyActionProcessingStreamAction() { public void processFile(FileCopyDetailsInternal details) { if (!details.isDirectory()) { DuplicatesStrategy strategy = details.getDuplicatesStrategy(); if (!visitedFiles.add(details.getRelativePath())) { if (strategy == DuplicatesStrategy.EXCLUDE) { return; } else if (strategy == DuplicatesStrategy.FAIL) { throw new DuplicateFileCopyingException(String.format("Encountered duplicate path \"%s\" during copy operation configured with DuplicatesStrategy.FAIL", details.getRelativePath())); } else if (strategy == DuplicatesStrategy.WARN) { LOGGER.warn("Encountered duplicate path \"{}\" during copy operation configured with DuplicatesStrategy.WARN", details.getRelativePath()); } } } action.processFile(details); } }); } }); }
Example #10
Source File: NormalizingCopyActionDecorator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void setDuplicatesStrategy(DuplicatesStrategy strategy) { throw new UnsupportedOperationException(); }
Example #11
Source File: DefaultFileCopyDetails.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void setDuplicatesStrategy(DuplicatesStrategy strategy) { this.duplicatesStrategy = strategy; }
Example #12
Source File: DefaultFileCopyDetails.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { return this.duplicatesStrategy; }
Example #13
Source File: NormalizingCopyActionDecorator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { throw new UnsupportedOperationException(); }
Example #14
Source File: NormalizingCopyActionDecorator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { throw new UnsupportedOperationException(); }
Example #15
Source File: DefaultFileCopyDetails.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void setDuplicatesStrategy(DuplicatesStrategy strategy) { this.duplicatesStrategy = strategy; }
Example #16
Source File: DefaultFileCopyDetails.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { return this.duplicatesStrategy; }
Example #17
Source File: NormalizingCopyActionDecorator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void setDuplicatesStrategy(DuplicatesStrategy strategy) { throw new UnsupportedOperationException(); }
Example #18
Source File: SingleParentCopySpec.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { return buildResolverRelativeToParent(parentResolver).getDuplicatesStrategy(); }
Example #19
Source File: SingleParentCopySpec.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { return buildResolverRelativeToParent(parentResolver).getDuplicatesStrategy(); }
Example #20
Source File: CloudServicesPackagingPlugin.java From commerce-gradle-plugin with Apache License 2.0 | 4 votes |
private void setupDatahubPackaging(Project p, PackagingExtension extension, Path packageFolder, Zip zipPackage, Task cleanTargetFolder) { Copy copyDataHubWar = p.getTasks().create("copyDataHubWar", Copy.class, t -> { t.from(extension.getDatahubWar(), s -> s.rename(".*", "datahub-webapp.war")); t.into(packageFolder.resolve("datahub/bin")); t.onlyIf(a -> { if (a.getInputs().getSourceFiles().isEmpty()) { throw new StopExecutionException("no datahub file found"); } return true; }); }); copyDataHubWar.dependsOn(cleanTargetFolder); zipPackage.dependsOn(copyDataHubWar); Set<String> environments = extension.getEnvironments().get(); Path configurationFolder = extension.getConfigurationFolder().getAsFile().get().toPath(); for (String environment : environments) { Path sourceFolder = configurationFolder.resolve(environment).resolve("datahub"); Path commonFolder = configurationFolder.resolve(COMMON_CONFIG).resolve("datahub"); Path targetFolder = packageFolder.resolve("datahub/config/" + environment); Copy copyCommonConfig = p.getTasks().create("copyDatahubCommonEnv_" + environment, Copy.class, t -> { t.from(commonFolder); t.into(targetFolder); t.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); t.exclude(DATAHUB_CONFIG_EXCLUDE); }); copyCommonConfig.dependsOn(cleanTargetFolder); Copy copyDatahubConfig = p.getTasks().create("copyDatahubEnv_" + environment, Copy.class, t -> { t.from(sourceFolder); t.into(targetFolder); t.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); t.exclude(DATAHUB_CONFIG_EXCLUDE); }); copyDatahubConfig.dependsOn(copyCommonConfig); MergePropertyFiles mergeProperties = p.getTasks().create("mergeDatahub_customer.properties_" + environment, MergePropertyFiles.class, t -> { t.getInputFiles().setFrom(Arrays.asList( commonFolder.resolve("customer.properties"), sourceFolder.resolve("customer.properties") )); t.setOutputFile(targetFolder.resolve("customer.properties")); }); mergeProperties.dependsOn(copyDatahubConfig); zipPackage.dependsOn(mergeProperties); } }
Example #21
Source File: NormalizingCopyActionDecorator.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { throw new UnsupportedOperationException(); }
Example #22
Source File: NormalizingCopyActionDecorator.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void setDuplicatesStrategy(DuplicatesStrategy strategy) { throw new UnsupportedOperationException(); }
Example #23
Source File: DefaultFileCopyDetails.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { return this.duplicatesStrategy; }
Example #24
Source File: DefaultFileCopyDetails.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void setDuplicatesStrategy(DuplicatesStrategy strategy) { this.duplicatesStrategy = strategy; }
Example #25
Source File: NormalizingCopyActionDecorator.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { throw new UnsupportedOperationException(); }
Example #26
Source File: NormalizingCopyActionDecorator.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void setDuplicatesStrategy(DuplicatesStrategy strategy) { throw new UnsupportedOperationException(); }
Example #27
Source File: DefaultFileCopyDetails.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public DuplicatesStrategy getDuplicatesStrategy() { return this.duplicatesStrategy; }
Example #28
Source File: DefaultFileCopyDetails.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void setDuplicatesStrategy(DuplicatesStrategy strategy) { this.duplicatesStrategy = strategy; }