Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-1419

Add support for loading arbitrary properties files as per gradle.properties

    Details

    • Type: New Feature
    • Status: Resolved
    • Resolution: Won't Fix
    • Affects Version/s: 1.0-milestone-1
    • Fix Version/s: None

      Description

      Gradle can currently load properties from a file called gradle.properties in the project directory. It would be great if the functionality that loads gradle.properties was made available as part of the dsl in order to load any arbitrary properties file as per the Ant <property> element.

        Issue Links

          Activity

          Hide
          annorax Ido added a comment -

          You say "The properties are loaded as extra properties of your project, so when reading them you don't use the "ext." qualifier (read them just like dynamic properties), as opposed to when writing into them."

          Could you please give an exact example?

          Sure:

          myprops.properties
          db-host-addr=100.100.100.100
          db-port=222
          db-name=myDB
          
          build.gradle
          ...
          loadProperties 'myprops.properties'
          ...
          println db-name // output: myDB
          ...
          
          Show
          annorax Ido added a comment - You say "The properties are loaded as extra properties of your project, so when reading them you don't use the "ext." qualifier (read them just like dynamic properties), as opposed to when writing into them." Could you please give an exact example? Sure: myprops.properties db-host-addr=100.100.100.100 db-port=222 db-name=myDB build.gradle ... loadProperties 'myprops.properties' ... println db-name // output: myDB ...
          Hide
          nagkumar Raja Nagendra Kumar added a comment - - edited

          It would be nice to have this as default method.
          Else, we need to include the script for loadProperties everywhere.. as loading properties from any where is so commonly used. More so this method is no optimal as one needs to read and assign to global properties.

          Please consider to get this ASAP.

          Regards,
          Raja Nagendra Kumar

          Show
          nagkumar Raja Nagendra Kumar added a comment - - edited It would be nice to have this as default method. Else, we need to include the script for loadProperties everywhere.. as loading properties from any where is so commonly used. More so this method is no optimal as one needs to read and assign to global properties. Please consider to get this ASAP. Regards, Raja Nagendra Kumar
          Hide
          bmuschko Benjamin Muschko added a comment -

          As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

          We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

          Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

          • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
          • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

          We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

          Show
          bmuschko Benjamin Muschko added a comment - As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by: Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines . Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete. We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!
          Hide
          mauromol Mauro Molinari added a comment -

          I'm still missing this feature and relying on third-party plugins. I think it should be a core feature.

          Show
          mauromol Mauro Molinari added a comment - I'm still missing this feature and relying on third-party plugins. I think it should be a core feature.
          Hide
          bmuschko Benjamin Muschko added a comment - - edited

          What I read from the issue are two different aspects:

          1. I want to define properties in a different file than gradle.properties.
          2. I want to be able to use properties as placeholders within a properties file to form other properties.

          Some suggestions here:

          1. I'd assume that the main purpose is to define extra properties. Why not just define those properties in a script plugin? Then you don't have to jump through the hoops of translating key/value pairs into extra properties. For example:

          myproperties.gradle:

          ext {
              myProp = 'test'
          }
          

          build.gradle:

          apply from: 'myproperties.gradle'
          

          2. You can easily replace portions of an extra property with another property value e.g.

          myproperties.gradle:

          ext {
              myProp = 'a'
              myFile = "${myProp}.txt"
          }
          

          Given these suggestions and other recommendation mentioned in this card, I'd like to just close the issue. From my perspective it is more idiomatic to create the extra properties directly in a Gradle build script than in a properties file. Please open an issue on GitHub (separately by the aspects mentioned above) if you would still like to pursue other approaches.

          Show
          bmuschko Benjamin Muschko added a comment - - edited What I read from the issue are two different aspects: 1. I want to define properties in a different file than gradle.properties . 2. I want to be able to use properties as placeholders within a properties file to form other properties. Some suggestions here: 1. I'd assume that the main purpose is to define extra properties. Why not just define those properties in a script plugin? Then you don't have to jump through the hoops of translating key/value pairs into extra properties. For example: myproperties.gradle: ext { myProp = 'test' } build.gradle: apply from: 'myproperties.gradle' 2. You can easily replace portions of an extra property with another property value e.g. myproperties.gradle: ext { myProp = 'a' myFile = "${myProp}.txt" } Given these suggestions and other recommendation mentioned in this card, I'd like to just close the issue. From my perspective it is more idiomatic to create the extra properties directly in a Gradle build script than in a properties file. Please open an issue on GitHub (separately by the aspects mentioned above) if you would still like to pursue other approaches.

            People

            • Assignee:
              Unassigned
              Reporter:
              kevinstembridge Kevin Stembridge
            • Votes:
              15 Vote for this issue
              Watchers:
              19 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development