Java源码示例:org.gradle.api.file.DuplicatesStrategy
示例1
@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/")));
})
);
});
}
示例2
@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/")));
})
);
});
}
示例3
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);
}
});
}
});
}
示例4
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);
}
});
}
});
}
示例5
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);
}
}
示例6
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");
}
示例7
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");
}
示例8
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);
}
});
}
});
}
示例9
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);
}
});
}
});
}
示例10
public DuplicatesStrategy getDuplicatesStrategy() {
return buildResolverRelativeToParent(parentResolver).getDuplicatesStrategy();
}
示例11
public void setDuplicatesStrategy(DuplicatesStrategy strategy) {
this.duplicatesStrategy = strategy;
}
示例12
public DuplicatesStrategy getDuplicatesStrategy() {
return this.duplicatesStrategy;
}
示例13
public void setDuplicatesStrategy(DuplicatesStrategy strategy) {
throw new UnsupportedOperationException();
}
示例14
public DuplicatesStrategy getDuplicatesStrategy() {
throw new UnsupportedOperationException();
}
示例15
public void setDuplicatesStrategy(DuplicatesStrategy strategy) {
this.duplicatesStrategy = strategy;
}
示例16
public DuplicatesStrategy getDuplicatesStrategy() {
return this.duplicatesStrategy;
}
示例17
public void setDuplicatesStrategy(DuplicatesStrategy strategy) {
throw new UnsupportedOperationException();
}
示例18
public DuplicatesStrategy getDuplicatesStrategy() {
throw new UnsupportedOperationException();
}
示例19
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);
}
}
示例20
public DuplicatesStrategy getDuplicatesStrategy() {
return buildResolverRelativeToParent(parentResolver).getDuplicatesStrategy();
}
示例21
public void setDuplicatesStrategy(DuplicatesStrategy strategy) {
this.duplicatesStrategy = strategy;
}
示例22
public DuplicatesStrategy getDuplicatesStrategy() {
return this.duplicatesStrategy;
}
示例23
public void setDuplicatesStrategy(DuplicatesStrategy strategy) {
throw new UnsupportedOperationException();
}
示例24
public DuplicatesStrategy getDuplicatesStrategy() {
throw new UnsupportedOperationException();
}
示例25
public void setDuplicatesStrategy(DuplicatesStrategy strategy) {
this.duplicatesStrategy = strategy;
}
示例26
public DuplicatesStrategy getDuplicatesStrategy() {
return this.duplicatesStrategy;
}
示例27
public void setDuplicatesStrategy(DuplicatesStrategy strategy) {
throw new UnsupportedOperationException();
}
示例28
public DuplicatesStrategy getDuplicatesStrategy() {
throw new UnsupportedOperationException();
}