本文整理了Java中org.gradle.api.Project.provider()
方法的一些代码示例,展示了Project.provider()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.provider()
方法的具体详情如下:
包路径:org.gradle.api.Project
类名称:Project
方法名:provider
暂无
代码示例来源:origin: typelead/gradle-eta
private static Provider<Optional<Boolean>> sendMetricsPropertyProvider
(final Project project) {
return project.provider(() -> {
Object value = project.findProperty
(ETA_SEND_METRICS_PROPERTY);
if (value == null) {
return Optional.empty();
} else {
String stringValue = (String) value;
if (value.equals("true") || value.equals("false")) {
return Optional.of(Boolean.valueOf(stringValue));
} else {
throw new GradleException
("Invalid value '" + stringValue +
"' for the etaSendMetrics property." +
" Must be either 'true' or 'false'.");
}
}
});
}
代码示例来源:origin: gradle.plugin.mpern.sap.commerce/commerce-gradle-plugin
@javax.inject.Inject
public HybrisPlatform(Project project) {
projectRoot = project.getProjectDir().toPath();
platformDir = project.provider(() -> project.getLayout().getProjectDirectory().dir("hybris/bin/platform"));
platformVersion = project.provider(this::readVersion);
antHome = project.provider(() -> project.getLayout().getProjectDirectory().dir(getRelativeAntHomepath()));
}
代码示例来源:origin: typelead/gradle-eta
public EtlasMavenRepository(Project project, File repositoryDirectory) {
this.project = project;
this.repositoryDirectory = repositoryDirectory;
this.resolvedEta = project.provider
(() -> project.getRootProject().getExtensions()
.getByType(EtaExtension.class).getEta().get());
}
代码示例来源:origin: org.gosu-lang.gosu/gradle-gosu-plugin
private static void configureOutputDirectoryForSourceSet(final SourceSet sourceSet, final SourceDirectorySet sourceDirectorySet, AbstractCompile compile, final Project target) {
final String sourceSetChildPath = "classes/" + sourceDirectorySet.getName() + "/" + sourceSet.getName();
sourceDirectorySet.setOutputDir(target.provider(() -> {
if (sourceSet.getOutput().isLegacyLayout()) {
return sourceSet.getOutput().getClassesDir();
}
return new File(target.getBuildDir(), sourceSetChildPath);
}));
((ConfigurableFileCollection) sourceSet.getOutput().getClassesDirs()).from(target.provider( sourceDirectorySet::getOutputDir));
compile.setDestinationDir(target.provider(sourceDirectorySet::getOutputDir));
}
代码示例来源:origin: typelead/gradle-eta
public Provider<List<String>> defaultModulesProvider() {
return project.provider
(() -> {
final List<String> modules = new ArrayList<>();
if (sourceDirectories != null) {
sourceDirectories.getAsFileTree().visit
(file -> {
if (!file.isDirectory()) {
String moduleWithExtension =
file.getPath().replace('/', '.');
String module = moduleWithExtension
.substring(0, moduleWithExtension.lastIndexOf("."));
if (module.equals("Main")) {
executable.set(file.getFile().getAbsolutePath());
} else {
modules.add(module);
}
}});
}
return modules;
});
}
代码示例来源:origin: typelead/gradle-eta
@Internal
public Provider<Set<EtaDependency>>
getDefaultDependencyProvider() {
return project.provider(() -> {
Set<EtaDependency> allDependencies = new LinkedHashSet<>();
for (Project p: project.getAllprojects()) {
for (Configuration c: p.getConfigurations()) {
final EtaConfiguration etaConfiguration =
ExtensionHelper.getExtension(c, EtaConfiguration.class);
if (etaConfiguration != null) {
allDependencies.addAll(etaConfiguration.getAllDependencies());
}
}
}
return allDependencies;
});
}
代码示例来源:origin: palantir/sls-packaging
@Inject
public BaseDistributionExtension(Project project) {
serviceGroup = project.getObjects().property(String.class);
serviceName = project.getObjects().property(String.class);
podName = project.getObjects().property(String.class);
productType = project.getObjects().property(ProductType.class);
productDependencies = project.getObjects().listProperty(ProductDependency.class);
ignoredProductDependencies = project.getObjects().setProperty(ProductId.class);
serviceGroup.set(project.provider(() -> project.getGroup().toString()));
serviceName.set(project.provider(project::getName));
podName.set(project.provider(project::getName));
manifestExtensions = Maps.newHashMap();
}
代码示例来源:origin: typelead/gradle-eta
public EtaRepl() {
this.project = getProject();
this.destinationDir =
project.getLayout().directoryProperty();
Property<String[]> argsProp = (Property<String[]>)
project.getObjects().property(String[].class);
argsProp.set(new String[0]);
this.args = new OverridingProperty<String[]>
(project.provider(() -> {
String args = parseStringProperty(project, "args");
if (args == null) return null;
return args.split(" ");
}),
Optional.empty(),
argsProp);
}
代码示例来源:origin: typelead/gradle-eta
private void configureSourceSetInjection(final Project p, SourceSet sourceSet) {
EtaInjectDependencies injectDependenciesTask = p.getTasks()
.create(NamingScheme.getInjectDependenciesTaskName(sourceSet.getName()),
EtaInjectDependencies.class);
injectDependenciesTask.setTargetConfiguration
(project.provider(() -> sourceSet.getCompileClasspathConfigurationName()));
injectDependenciesTask.dependsOnProjects();
sourceSet.setCompileClasspath
(sourceSet.getCompileClasspath()
.plus(p.files().builtBy(injectDependenciesTask)));
}
代码示例来源:origin: typelead/gradle-eta
public EtaCompile() {
final Project project = getProject();
final EtaExtension extension =
project.getRootProject().getExtensions().getByType(EtaExtension.class);
this.resolvedEta = extension.getEta();
this.destinationDir = project.getLayout().directoryProperty();
this.classesDir = project.getLayout().directoryProperty();
/* TODO: Do these paths need to be portable? */
this.packageDB = project.provider
(() ->
new File(getDestinationDir(), "dist/packagedb/eta-" + getEtaVersion()));
this.outputJar = project.provider
(() -> {
String packageId = getPackageName() + "-" + getPackageVersion();
return Paths.get(getDestinationDir().getAbsolutePath(),
"dist", "build", "eta-" + getEtaVersion(),
packageId, "build", packageId + "-inplace.jar")
.toFile();
});
getOutputs().upToDateWhen(task -> false);
}
代码示例来源:origin: gradle.plugin.com.github.ramonwirsch/fopRenderer
@Inject
public FopRenderTask(WorkerExecutor workerExecutor) {
setGroup("build");
setDescription("Render all available PDFs using fop");
this.workerExecutor = workerExecutor;
inputFileProperty = newInputFile();
outputFileProperty = newOutputFile();
Provider<String> outputFileRel = getProject().provider(() -> "doc/"+renderConfig.getName()+".pdf");
outputFileProperty.set(getProject().getLayout().getBuildDirectory().file(outputFileRel));
}
代码示例来源:origin: typelead/gradle-eta
public EtaInstallAllDependencies() {
this.project = getProject();
this.destinationDir =
project.getLayout().directoryProperty();
destinationDir.set(project.getLayout().getBuildDirectory()
.dir(DEFAULT_DESTINATION_DIR));
this.freezeConfigFile = project.provider
(() -> destinationDir
.file(EtaResolveDependencies.DEFAULT_FREEZE_CONFIG_FILENAME)
.get().getAsFile());
this.cabalFile = destinationDir
.file(project.provider(() -> project.getName()
+ DEFAULT_CABAL_FILENAME));
getOutputs().upToDateWhen(task -> false);
}
代码示例来源:origin: gradle.plugin.de.acetous/gradle-require-dependency-compliance-plugin
public DependencyComplianceExtension(Project project) {
outputFile = project.getLayout().fileProperty(project.provider(() -> project.getLayout().getProjectDirectory().file("dependency-compliance-report.json")));
ignore = project.getObjects().listProperty(String.class);
ignoreMavenLocal = project.getObjects().property(Boolean.class);
}
代码示例来源:origin: io.freefair.gradle/android-gradle-plugins
private Provider<Directory> determineConfigurationDirectory() {
return project.provider(() -> {
if (usesSubprojectCheckstyleConfiguration()) {
DeprecationLogger.nagUserWithDeprecatedIndirectUserCodeCause("Setting the Checkstyle configuration file under 'config/checkstyle' of a sub project", "Use the root project's 'config/checkstyle' directory instead.");
return project.getLayout().getProjectDirectory().dir(CONFIG_DIR_NAME);
}
return project.getRootProject().getLayout().getProjectDirectory().dir(CONFIG_DIR_NAME);
});
}
代码示例来源:origin: typelead/gradle-eta
public EtaInstallDependencies() {
this.project = getProject();
this.freezeConfigFile = project.files();
this.destinationDir =
project.getLayout().directoryProperty();
final EtaExtension extension =
project.getRootProject().getExtensions().getByType(EtaExtension.class);
this.etaInfo = extension.getEtaInfo();
destinationDir.set(project.getLayout().getBuildDirectory()
.dir(DEFAULT_DESTINATION_DIR));
this.modulesProvider = defaultModulesProvider();
this.dependencies =
project.provider
(() -> ConfigurationUtils.getEtaConfiguration
(project, EtaInstallDependencies.this.getTargetConfiguration())
.getAllDependencies());
this.cabalProjectFile = destinationDir.file(DEFAULT_CABAL_PROJECT_FILENAME);
this.cabalFile = destinationDir
.file(project.provider(() -> getPackageName() + DEFAULT_CABAL_FILENAME));
this.executable = project.getObjects().property(String.class);
getOutputs().upToDateWhen(task -> false);
}
代码示例来源:origin: io.freefair.gradle/android-gradle-plugins
private void configureTaskConventionMapping(Configuration configuration, Checkstyle task) {
ConventionMapping taskMapping = task.getConventionMapping();
taskMapping.map("checkstyleClasspath", Callables.returning(configuration));
taskMapping.map("config", (Callable<TextResource>) () -> extension.getConfig());
taskMapping.map("configProperties", (Callable<Map<String, Object>>) () -> extension.getConfigProperties());
taskMapping.map("ignoreFailures", (Callable<Boolean>) () -> extension.isIgnoreFailures());
taskMapping.map("showViolations", (Callable<Boolean>) () -> extension.isShowViolations());
taskMapping.map("maxErrors", (Callable<Integer>) () -> extension.getMaxErrors());
taskMapping.map("maxWarnings", (Callable<Integer>) () -> extension.getMaxWarnings());
task.setConfigDir(project.provider(() -> extension.getConfigDir()));
}
代码示例来源:origin: io.github.gradle-clojure/gradle-clojure-plugin
private void configureSourceSetDefaults(Project project, ClojureExtension extension) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
ClojureSourceSet clojureSourceSet = new DefaultClojureSourceSet("clojure", sourceDirectorySetFactory);
new DslObject(sourceSet).getConvention().getPlugins().put("clojure", clojureSourceSet);
clojureSourceSet.getClojure().srcDir(String.format("src/%s/clojure", sourceSet.getName()));
// in case the clojure source overlaps with the resources source
sourceSet.getResources().getFilter().exclude(element -> clojureSourceSet.getClojure().contains(element.getFile()));
sourceSet.getAllSource().source(clojureSourceSet.getClojure());
ClojureBuild build = extension.getBuilds().create(sourceSet.getName());
build.getSourceSet().set(sourceSet);
((DefaultSourceSetOutput) sourceSet.getOutput()).addClassesDir(() -> build.getOutputDir().get().getAsFile());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(build.getTaskName("compile"));
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(build.getTaskName("check"));
sourceSet.getOutput().dir(project.provider(() -> {
if (build.isCompilerConfigured()) {
return clojureSourceSet.getClojure().getSourceDirectories();
} else {
return build.getOutputDir();
}
}));
});
}
代码示例来源:origin: io.github.gradle-clojure/gradle-clojure-plugin
private void configureSourceSetDefaults(Project project, ClojureScriptExtension extension) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all((SourceSet sourceSet) -> {
ClojureScriptSourceSet clojurescriptSourceSet = new DefaultClojureScriptSourceSet("clojurescript", sourceDirectorySetFactory);
new DslObject(sourceSet).getConvention().getPlugins().put("clojurescript", clojurescriptSourceSet);
clojurescriptSourceSet.getClojureScript().srcDir(String.format("src/%s/clojurescript", sourceSet.getName()));
// in case the clojure source overlaps with the resources source
sourceSet.getResources().getFilter().exclude(element -> clojurescriptSourceSet.getClojureScript().contains(element.getFile()));
sourceSet.getAllSource().source(clojurescriptSourceSet.getClojureScript());
ClojureScriptBuild build = extension.getBuilds().create(sourceSet.getName());
build.getSourceSet().set(sourceSet);
sourceSet.getOutput().dir(build.getOutputDir());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(build.getTaskName("compile"));
sourceSet.getOutput().dir(project.provider(() -> {
if (build.isCompilerConfigured()) {
return clojurescriptSourceSet.getClojureScript().getSourceDirectories();
} else {
return build.getOutputDir();
}
}));
});
}
代码示例来源:origin: gradle-clojure/gradle-clojure
private void configureSourceSetDefaults(Project project, ClojureScriptExtension extension) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all((SourceSet sourceSet) -> {
ClojureScriptSourceSet clojurescriptSourceSet = new DefaultClojureScriptSourceSet("clojurescript", objects);
new DslObject(sourceSet).getConvention().getPlugins().put("clojurescript", clojurescriptSourceSet);
clojurescriptSourceSet.getClojureScript().srcDir(String.format("src/%s/clojurescript", sourceSet.getName()));
// in case the clojure source overlaps with the resources source
sourceSet.getResources().getFilter().exclude(element -> clojurescriptSourceSet.getClojureScript().contains(element.getFile()));
sourceSet.getAllSource().source(clojurescriptSourceSet.getClojureScript());
ClojureScriptBuild build = extension.getBuilds().create(sourceSet.getName());
build.getSourceSet().set(sourceSet);
sourceSet.getOutput().dir(build.getOutputDir());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(build.getTaskName("compile"));
sourceSet.getOutput().dir(project.provider(() -> {
if (build.isCompilerConfigured()) {
return build.getOutputDir();
} else {
return clojurescriptSourceSet.getClojureScript().getSourceDirectories();
}
}));
});
}
代码示例来源:origin: gradle.plugin.mpern.sap.commerce/commerce-gradle-plugin
@Inject
public PackagingExtension(Project project) {
datahub = project.getObjects().property(Boolean.class);
datahub.set(Boolean.FALSE);
solr = project.getObjects().property(Boolean.class);
solr.set(Boolean.FALSE);
preProductionEnvironment = project.getObjects().property(String.class);
customerID = project.getObjects().property(String.class);
projectID = project.getObjects().property(String.class);
packageName = project.provider(() -> buildPackageName(project));
datahubWar = project.getLayout().fileProperty();
platformZip = project.getLayout().fileProperty();
allExtensionsZip = project.getLayout().fileProperty();
environments = project.getObjects().setProperty(String.class);
configurationFolder = project.getLayout().directoryProperty();
distributionFolder = project.getLayout().directoryProperty();
tempFolder = project.getLayout().directoryProperty();
}
内容来源于网络,如有侵权,请联系作者删除!