本文整理了Java中org.gradle.api.Project.findProperty()
方法的一些代码示例,展示了Project.findProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.findProperty()
方法的具体详情如下:
包路径:org.gradle.api.Project
类名称:Project
方法名:findProperty
暂无
代码示例来源:origin: uber/okbuck
public static boolean isJetifierEnabled(Project project) {
Object prop = project.findProperty("android.enableJetifier");
return prop != null ? Boolean.valueOf((String) prop) : false;
}
代码示例来源:origin: lenskit/lenskit
String prjProp = "lenskit." + prop.getName();
if (project.hasProperty(prjProp)) {
Object val = project.findProperty(prjProp);
String vstr = val != null ? val.toString() : null;
logger.info("setting property {} to {}", prjProp, val);
代码示例来源:origin: typelead/gradle-eta
public static String parseStringProperty(final Project project, final String name,
final String def) {
Object v = project.findProperty("eta." + name);
String value;
if (v == null) {
value = def;
} else {
value = v.toString();
}
return value;
}
代码示例来源:origin: gradle.plugin.com.maxtropy.roc.beer/beer-plugin
@Override
public void apply(Project project) {
System.out.println("1.0 key args: " + project.findProperty("sourcePath") + " " + project.findProperty("classDir"));
project.getTasks().create("beer", Beer.class);
}
}
代码示例来源:origin: gradle.plugin.org.amdatu.blueprint/org.amdatu.blueprint.gradle
private String getProperty(String envVarNae, String gradlePropertyKey) {
String value = System.getenv(envVarNae);
if (value == null) {
value = (String) getProject().findProperty(gradlePropertyKey);
}
return value;
}
代码示例来源:origin: gradle-clojure/gradle-clojure
private String getLogLevel() {
Supplier<String> gradleLevel = () -> Stream.of(LogLevel.DEBUG, LogLevel.INFO, LogLevel.LIFECYCLE, LogLevel.WARN, LogLevel.QUIET, LogLevel.ERROR)
.filter(project.getLogger()::isEnabled)
.map(LogLevel::toString)
.map(String::toLowerCase)
.findFirst()
.orElse("info");
// allow level to come from either a project property or whatever level Gradle is set to
return Optional.ofNullable(project.findProperty("gradle-clojure.tools.logger.level"))
.map(Object::toString)
.orElseGet(gradleLevel);
}
}
代码示例来源:origin: typelead/gradle-eta
public static boolean parseBooleanProperty(final Project project, final String name,
final boolean def) {
Object v = project.findProperty("eta." + name);
boolean value;
if (v == null) {
value = def;
} else {
String booleanString = v.toString();
if (booleanString.equalsIgnoreCase("true")) {
value = true;
} else if (booleanString.equalsIgnoreCase("false")) {
value = false;
} else throw new GradleException("Invalid property value for eta."
+ name + ": " + booleanString);
}
return value;
}
}
代码示例来源:origin: io.github.gradle-clojure/gradle-clojure-plugin
private String getLogLevel() {
Supplier<String> gradleLevel = () -> Stream.of(LogLevel.DEBUG, LogLevel.INFO, LogLevel.LIFECYCLE, LogLevel.WARN, LogLevel.QUIET, LogLevel.ERROR)
.filter(project.getLogger()::isEnabled)
.map(LogLevel::toString)
.map(String::toLowerCase)
.findFirst()
.orElse("info");
// allow level to come from either a project property or whatever level Gradle is set to
return Optional.ofNullable(project.findProperty("gradle-clojure.tools.logger.level"))
.map(Object::toString)
.orElseGet(gradleLevel);
}
}
代码示例来源: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.tui.sse.mde4cpp/MDE4CPPCompilePlugin
/**
* select all project properties, which start with:
* - DEBUG_
* - CMAKE_
* - USER_
*
* @param project current project instance contains existing properties
* @return list with related property string: 'property name'='property value'
*/
static List<String[]> getPropertiesForCMake(Project project)
{
List<String[]> propertyList = new LinkedList<String[]>();
Set<String> keySet = project.getProperties().keySet();
for (String key : keySet)
{
if (key.startsWith("DEBUG_") || key.startsWith("CMAKE_") || key.startsWith("USER_"))
{
String[] variableSet = {key, project.findProperty(key).toString()};
propertyList.add(variableSet);
}
}
return propertyList;
}
}
代码示例来源:origin: gradle.plugin.com.maxtropy.roc.beer/beer-plugin
@TaskAction
void generateMessage() {
sourcePath = sourcePath == null ? String.valueOf(getProject().findProperty("sourcePath")) : sourcePath;
classDir = classDir == null ? String.valueOf(getProject().findProperty("classDir")) : classDir;
File sourceFile = new File(java.lang.String.valueOf(sourcePath));
File outDir = new File(java.lang.String.valueOf(classDir));
JavaFile a;
System.out.println("Start generating. " + sourceFile.getAbsolutePath() + " " + outDir.getAbsolutePath());
if (!sourceFile.exists()) {
System.out.println("Source file does not exist. Leaving......");
}
if (!outDir.exists()) {
System.out.println("Making output class dir......");
outDir.mkdir();
}
String[] args = new String[]{sourcePath, classDir};
try {
Generator.main(args);
} catch (IOException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: me.seeber.gradle/gradle-project-config
/**
* Get a property from the project or the environment
*
* First looks up the property value in the project's properties. If the property is not set, converts the property
* name to upper underscore format and checks if the value is set in the environment.
*
* @param name Property name
* @return Property value or <code>null</code> if the property does not exist
*/
public @Nullable String getProperty(String name) {
String env = toEnvName(name);
String property = name.toLowerCase();
String value = System.getProperty(env);
if (value == null) {
value = (String) getProject().findProperty(property);
}
return value;
}
代码示例来源:origin: gradle.plugin.me.seeber.gradle/gradle-project-config
/**
* Get a property from the project or the environment
*
* First looks up the property value in the project's properties. If the property is not set, converts the property
* name to upper underscore format and checks if the value is set in the environment.
*
* @param name Property name
* @return Property value or <code>null</code> if the property does not exist
*/
public @Nullable String getProperty(String name) {
String env = toEnvName(name);
String property = name.toLowerCase();
String value = System.getProperty(env);
if (value == null) {
value = (String) getProject().findProperty(property);
}
return value;
}
代码示例来源:origin: org.shipkit/shipkit
private static void authenticate(String projectProperty, Project project, String envVarName, EnvVariables envVariables) {
Object value = project.findProperty(projectProperty);
if (isEmpty(value)) {
value = envVariables.getNonEmptyEnv(envVarName);
BasicValidator.notNull(value, "Gradle Plugin Portal '" + projectProperty + "' is required. Options:\n" +
" - export '" + envVarName + "' env var (recommended for CI, don't commit secrets to VCS!)\n" +
" - use '" + projectProperty + "' project property");
project.getExtensions().getExtraProperties().set(projectProperty, value);
}
}
}
代码示例来源:origin: mockito/shipkit
private static void authenticate(String projectProperty, Project project, String envVarName, EnvVariables envVariables) {
Object value = project.findProperty(projectProperty);
if (isEmpty(value)) {
value = envVariables.getNonEmptyEnv(envVarName);
BasicValidator.notNull(value, "Gradle Plugin Portal '" + projectProperty + "' is required. Options:\n" +
" - export '" + envVarName + "' env var (recommended for CI, don't commit secrets to VCS!)\n" +
" - use '" + projectProperty + "' project property");
project.getExtensions().getExtraProperties().set(projectProperty, value);
}
}
}
代码示例来源:origin: gradle.plugin.com.enonic.gradle/xp-gradle-plugin
@Override
public void apply( final Project project )
{
final XpExtension ext = XpExtension.create( project );
ext.setVersion( "7.+" );
ext.setInstallDir( new File( project.getBuildDir(), "xp" ) );
ext.setHomeDir( findHomeDir( ext.getInstallDir(), project.findProperty( "xpHome" ) ) );
applyJavaBased( project );
}
代码示例来源:origin: gradle.plugin.com.enonic.xp/xp-gradle-plugin
@Override
public void apply( final Project project )
{
final XpExtension ext = XpExtension.create( project );
ext.setVersion( "6.+" );
ext.setInstallDir( new File( project.getBuildDir(), "xp" ) );
ext.setHomeDir( findHomeDir( ext.getInstallDir(), project.findProperty( "xpHome" ) ) );
applyJavaBased( project );
}
代码示例来源:origin: gradle.plugin.com.palantir.graal/gradle-graal
GraalExtension extension = project.getExtensions().create("graal", GraalExtension.class, project);
Path cacheDir = Optional.ofNullable((String) project.findProperty("com.palantir.graal.cache.dir"))
.map(Paths::get)
.orElse(project.getGradle().getGradleUserHomeDir().toPath()
代码示例来源:origin: palantir/gradle-graal
GraalExtension extension = project.getExtensions().create("graal", GraalExtension.class, project);
Path cacheDir = Optional.ofNullable((String) project.findProperty("com.palantir.graal.cache.dir"))
.map(Paths::get)
.orElse(project.getGradle().getGradleUserHomeDir().toPath()
代码示例来源:origin: mockito/shipkit
upgradeDependencyExtension.setBaseBranch("master");
String dependency = (String) project.findProperty(DEPENDENCY_PROJECT_PROPERTY);
内容来源于网络,如有侵权,请联系作者删除!