{"action":"closed","issue":{"url":"https://api.github.com/repos/gradle/gradle-native/issues/781","repository_url":"https://api.github.com/repos/gradle/gradle-native","labels_url":"https://api.github.com/repos/gradle/gradle-native/issues/781/labels{/name}","comments_url":"https://api.github.com/repos/gradle/gradle-native/issues/781/comments","events_url":"https://api.github.com/repos/gradle/gradle-native/issues/781/events","html_url":"https://github.com/gradle/gradle-native/issues/781","id":344934411,"node_id":"MDU6SXNzdWUzNDQ5MzQ0MTE=","number":781,"title":"Configurability of elements using the lazy API","user":{"login":"big-guy","id":5387972,"node_id":"MDQ6VXNlcjUzODc5NzI=","avatar_url":"https://avatars0.githubusercontent.com/u/5387972?v=4","gravatar_id":"","url":"https://api.github.com/users/big-guy","html_url":"https://github.com/big-guy","followers_url":"https://api.github.com/users/big-guy/followers","following_url":"https://api.github.com/users/big-guy/following{/other_user}","gists_url":"https://api.github.com/users/big-guy/gists{/gist_id}","starred_url":"https://api.github.com/users/big-guy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/big-guy/subscriptions","organizations_url":"https://api.github.com/users/big-guy/orgs","repos_url":"https://api.github.com/users/big-guy/repos","events_url":"https://api.github.com/users/big-guy/events{/privacy}","received_events_url":"https://api.github.com/users/big-guy/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"big-guy","id":5387972,"node_id":"MDQ6VXNlcjUzODc5NzI=","avatar_url":"https://avatars0.githubusercontent.com/u/5387972?v=4","gravatar_id":"","url":"https://api.github.com/users/big-guy","html_url":"https://github.com/big-guy","followers_url":"https://api.github.com/users/big-guy/followers","following_url":"https://api.github.com/users/big-guy/following{/other_user}","gists_url":"https://api.github.com/users/big-guy/gists{/gist_id}","starred_url":"https://api.github.com/users/big-guy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/big-guy/subscriptions","organizations_url":"https://api.github.com/users/big-guy/orgs","repos_url":"https://api.github.com/users/big-guy/repos","events_url":"https://api.github.com/users/big-guy/events{/privacy}","received_events_url":"https://api.github.com/users/big-guy/received_events","type":"User","site_admin":false},"assignees":[{"login":"big-guy","id":5387972,"node_id":"MDQ6VXNlcjUzODc5NzI=","avatar_url":"https://avatars0.githubusercontent.com/u/5387972?v=4","gravatar_id":"","url":"https://api.github.com/users/big-guy","html_url":"https://github.com/big-guy","followers_url":"https://api.github.com/users/big-guy/followers","following_url":"https://api.github.com/users/big-guy/following{/other_user}","gists_url":"https://api.github.com/users/big-guy/gists{/gist_id}","starred_url":"https://api.github.com/users/big-guy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/big-guy/subscriptions","organizations_url":"https://api.github.com/users/big-guy/orgs","repos_url":"https://api.github.com/users/big-guy/repos","events_url":"https://api.github.com/users/big-guy/events{/privacy}","received_events_url":"https://api.github.com/users/big-guy/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-07-26T17:24:20Z","updated_at":"2018-07-28T19:49:45Z","closed_at":"2018-07-28T19:49:45Z","author_association":"MEMBER","body":"For `TaskContainer`, we return `TaskProvider<T>`s for `register()` and `named()`.\nFor generic containers, we return a `Provider<T>` for the same. \n\nFor tasks, you can do things like:\n```\n// Supply configuration for the element when you register\ntasks.register(\"foo\") { /* configuration */ }\n\n// Supply configuration for an element after it's been registered\ntasks.named(\"foo\").configure { /* configuration */ }\n\n// Supply configuration for an element after it's been registered, some time later.\nfoo = tasks.register(\"foo\")\n// somewhere else\nfoo.configure { /* configuration */ }\n```\n\nFor any other domain object container, you're limited to configuring an element when you register it because only `TaskProvider` has a `configure()` method or realizing the element and configuring it.\n\nThis extends to the task container in Kotlin DSL because we're limited to the return type `Provider<T>` in some contexts.\n\n```\ntasks.withType<JavaCompile>().configureEach {} // OK\ntasks.withType(JavaCompile::class.java).named(\"compileJava\").configure {} // OK\ntasks.named(\"foo\").configure {} // OK\ntasks.register(\"foo\", JavaCompile::class.java) {} // OK\n\ntasks.withType<JavaCompile>().named(\"compileJava\") // doesn't work, named isn't visible\n\ntasks {\n    register(\"foo\", JavaCompile::class.java) {} // OK\n\n    named(\"foo\").configure {} // doesn't work because return type is Provider<T>\n    withType(JavaCompile::class.java).named(\"foo\").configure {} // doesn't work because return type is Provider<T>\n    withType<JavaCompile>().named(\"compileJava\") // doesn't work, named isn't visible \n}\n```\n\nWe could introduce a `named(String, Action)`, which will fix the common cases.\n\n```\ntasks {\n    named(\"foo\").configure {} \n    withType(JavaCompile::class.java).named(\"foo\").configure {}\n}\n```\nbecomes\n```\ntasks {\n    named(\"foo\") {} \n    withType(JavaCompile::class.java).named(\"foo\") {}\n}\n```\n\nBut this would look different when outside of `tasks {}`.  To counteract that, we could remove `TaskProvider.configure` so you must go through the container to configure anything.\n\nAlternatively, we could introduce a `ConfigurableProvider<T>` with a `configure` method and change the return types of the generic containers to `ConfigurableProvider<T>`.  This would make everything consistent at the expensive of another `Provider`-type.  This may be a little weird if elements are immutable/not configurable, but this is no worse than what it means to configure immutable elements with `all(Action)`, `configureEach(Action)` or `getByName(String, Action)`.\n\nAre there any other suggestions? Making changes to the return types will be a breaking change for the new methods (coming in 4.10, so now is the time).  Removing `TaskProvider.configure` is a breaking change as well, but could be less disruptive.\n"}}
{"actor":{"display_login":"big-guy"}}