Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using task outputs and configurations as config files. #180

Conversation

erdi
Copy link
Contributor

@erdi erdi commented Jan 19, 2019

No description provided.

README.md Outdated

cargo {
containerId = 'jboss5x'

local {
configFile {
file = file('src/main/jboss5/login-config.xml')
files = file('src/main/jboss5/login-config.xml')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assigning a single file calling a setter on a file collection looks a little bit funny from a users perspective. Can we make it more obvious that it is basically an add operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy about this design either but I struggled to find a clean way of supporting file collections while not breaking the existing api. I'm happy to rework if you can suggest something better by saying how do you see the dsl to look when using a single file as a config file source and when using a file collection as a config file source.

Btw, this is not an add operation and actually a setter, so if you say:

cargo {
    local {
        configFile {
            files = file('src/main/jboss5/sample-roles.properties')
            files = file('src/main/jboss5/sample-users.properties')
            toDir = 'conf/props'
        }
    }
}

only the second file will be copied.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy to break the existing API. It doesn't have to be backward compatible.

How about we just make it a setter and you have to provide a list of Files or a list of Strings? I'd remove the existing file method in the DSL and only provide a single way to set the configuration files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will remove the file method in the DSL and leave the setter for files which will still be backed by Project.files() and take whatever that method takes, so all of the following will work:

files = 'src/main/jboss5/sample-roles.properties'
files = file('src/main/jboss5/sample-roles.properties')
files = ['src/main/jboss5/sample-roles.properties']
files = [file('src/main/jboss5/sample-roles.properties')]
files = configurations.configFiles
files = tasks.writeConfigFile

I will also rename ConfigFile class to ConfigFiles and configFile {} to configFiles {} in the DSL.

Can you please confirm that you're happy with all of the above before I do the necessary work?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we require a user to provide a FileCollection instead of trying to turn everything into a FileCollection internally by calling Project.files()? I'd find that much clearer from a user's perspective.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do, that's totally fine by me, I just thought it's more convenient and an established pattern in core Gradle DSLs (e.g. CopySpec) which I wanted to follow but requiring a FileCollection is also fine. I'll assume you are happy with the rest of the proposed changes and will update the PR in the coming days.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally find passing an Object array pretty confusing from a user's perspective. It's unclear what types are acceptable. Once you make the change to the API to only accept a FileCollection we are ready to merge. Thanks!

…e collections to be used when configuring config files.
@erdi
Copy link
Contributor Author

erdi commented Jan 27, 2019

ConfigFile API now only accepts a FileCollection as requested.

Copy link
Owner

@bmuschko bmuschko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@bmuschko bmuschko merged commit 09df0d3 into bmuschko:master Jan 29, 2019
@bmuschko bmuschko added this to the v2.5 milestone Jan 29, 2019
@erdi
Copy link
Contributor Author

erdi commented Jan 29, 2019

Thanks! Looking forward to the next release.

@bmuschko
Copy link
Owner

Was the the last PR you wanted to get merged? I can release a new version today if you want to have the features.

@erdi
Copy link
Contributor Author

erdi commented Jan 29, 2019

Yes, that was the last one I planned to submit. Having all of the changes I submitted recently released sometime soon would be nice.

@bmuschko
Copy link
Owner

I released a new version. The version should be available on the Plugin Portal and Maven Central later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants