摇篮性质没有从〜/ .gradle / gradle.properties读 [英] Gradle properties not being read from ~/.gradle/gradle.properties

查看:187
本文介绍了摇篮性质没有从〜/ .gradle / gradle.properties读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也有类似的问题,因为在这里详细介绍:
http://gradle.1045684.n5.nabble.com/gradle-gradle-properties-not-being-read-td4372872.html

I have a similar problem as detailed here: http://gradle.1045684.n5.nabble.com/gradle-gradle-properties-not-being-read-td4372872.html

在事实上,它的的确切的同样的问题 - 除了从该线程解决方案并不为我工作。我在OS / X,使用gradle这个一个Android版本。中发生了什么要点是,用下面的〜/ .gradle / gradle.properties文件:

In fact, it's the exact same problem - except that the solution from that thread doesn't work for me. I'm on OS/X, with an android build using gradle. The gist of what's happening is that with the following ~/.gradle/gradle.properties file:

uploadUsername=scottj
uploadKeyFile=/home/scottjohnson/.ssh/uploadKey

和以下的build.gradle文件:

And the following build.gradle file:

...跳过的gradle一般和具体Android的东西...

... skipped general gradle and android-specific stuff ...

task checkProperties << {
  if (!hasProperty('uploadUsername')) {
    throw new RuntimeException("Couldn't find uploadUsername property. Did you forget to specify it in ~/.gradle/gradle.properties?")
  } else if (!hasProperty('uploadKeyFile')) {
    throw new RuntimeException("Couldn't find uploadKeyFile property. Did you forget to specify it in ~/.gradle/gradle.properties?")
  }
  println("***** DEBUG_jwir3: " + project.getProperty('uploadUsername'))
}

当我运行 ./ gradlew checkProperties ,我得到:

失败:建立失败,一个异常

FAILURE: Build failed with an exception.


  • 其中:
    建立文件'/Users/scottjohnson/Source/core-android/crux/build.gradle'行:50

  • Where: Build file '/Users/scottjohnson/Source/core-android/crux/build.gradle' line: 50

出了什么问题:
执行失败的任务。:症结:checkProperties

What went wrong: Execution failed for task ':crux:checkProperties'.

找不到uploadUsername财产。你忘了在〜/ .gradle / gradle.properties?

Couldn't find uploadUsername property. Did you forget to specify it in ~/.gradle/gradle.properties?

尝试:
与--stacktrace选项获取堆栈跟踪运行。与--info或--debug选项来运行,以获得更多的日志输出。

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    构建失败

    总时间:7.072秒。

    Total time: 7.072 secs

    更有趣,如果我指定我想调试日志记录,我得到以下内容:

    What's more interesting, if I specify that I want debug logging, I get the following:

    mustafar:core-android scottjohnson$ ./gradlew checkProperties -d | grep properties
    19:22:35.507 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found env project properties: []
    19:22:35.508 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found system project properties: []
    19:22:35.865 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Looking for project properties from: /Users/scottjohnson/Source/core-android/buildSrc/gradle.properties
    19:22:37.161 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found env project properties: []
    19:22:37.161 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found system project properties: []
    19:22:37.200 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Looking for project properties from: /Users/scottjohnson/Source/core-android/gradle.properties
    19:22:37.200 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Adding project properties (if not overwritten by user properties): [CORE_GROUP, CORE_VERSION_NAME, CORE_VERSION_CODE]
    19:22:37.201 [DEBUG] [org.gradle.initialization.ProjectPropertySettingBuildLoader] Looking for project properties from: /Users/scottjohnson/Source/core-android/crux/gradle.properties
    

    正如你所看到的,它承认在核心的Andr​​oid / gradle.properties文件(CORE_GROUP,CORE_VERSION_NAME和CORE_VERSION_ code)的属性,但我没有看到任何的属性从〜/ .gradle /gradle.properties正在拉入。

    As you can see, it's recognizing the properties in the core-android/gradle.properties file (CORE_GROUP, CORE_VERSION_NAME, and CORE_VERSION_CODE), but I don't see either of the properties from ~/.gradle/gradle.properties being pulled in.

    我不希望指定在我的项目的gradle.properties这些特性,因为它们是特定于用户(对于推动私人Maven仓库凭据)。

    I don't want to specify these properties in my project's gradle.properties, because they are user-specific (credentials for pushing to a private maven repository).

    我在做什么错误是导致不以拉?

    What am I doing wrong that is causing the gradle.properties not to be pulled in?

    推荐答案

    里面一个任务操作, hasProperty 将解析为任务#hasProperty 。而是使用 project.hasProperty(...)

    Inside a task action, hasProperty will resolve to Task#hasProperty. Instead use project.hasProperty(...).

    这篇关于摇篮性质没有从〜/ .gradle / gradle.properties读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆