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: Open
    • Resolution: Unresolved
    • 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
          blaine Blaine Simpson added a comment - - edited

          I forgot to update this discussion last year. I updated my JavaPropFile plugin promptly. It supports the current API without warnings, and hasn't needed any modification since because of the rigorous unit tests. It will be updated aggresively whenever there is a need because it is used by very active open source projects. H

          Ido's snippet satisfies the most common use case. I often need more, like support for types other than strings, nesting of values, ability to reference sys properties (and set them), adding to arbitrary scope (not just the project), validation, default values, etc. See the feature list.

          Show
          blaine Blaine Simpson added a comment - - edited I forgot to update this discussion last year. I updated my JavaPropFile plugin promptly. It supports the current API without warnings, and hasn't needed any modification since because of the rigorous unit tests. It will be updated aggresively whenever there is a need because it is used by very active open source projects. H Ido's snippet satisfies the most common use case. I often need more, like support for types other than strings, nesting of values, ability to reference sys properties (and set them), adding to arbitrary scope (not just the project), validation, default values, etc. See the feature list .
          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.

            People

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

              Dates

              • Created:
                Updated:

                Development