# Maven-publish plugin tasks managing with gradle 2.3

**URL:** <https://discuss.gradle.org/t/maven-publish-plugin-tasks-managing-with-gradle-2-3/1813>\
**Category:** Old Forum Archive\
**Created:** [March 2, 2015, 12:41pm UTC](https://discuss.gradle.org/t/maven-publish-plugin-tasks-managing-with-gradle-2-3/1813 "2015-03-02T12:41:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yura\_Denison](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@Yura\_Denison](https://discuss.gradle.org/u/Yura_Denison)\
**Post date:** [March 2, 2015, 12:41pm UTC](https://discuss.gradle.org/t/maven-publish-plugin-tasks-managing-with-gradle-2-3/1813/1 "2015-03-02T12:41:00Z")

</div>

Hi. I’ve applyed “maven-publish” plugin to my project and here is publishing code block (labels is list of strings)

publishing {

publications {

labels.each { label -\>

“model${label}”(MavenPublication) {

artifactId “model-${label.toLowerCase()}”

artifact tasks."${label.toLowerCase()}Jar"

artifact tasks.“source${label}Jar” {

classifier ‘sources’

}

}

}

}

repositories {

maven { name ‘snapshot’; url snapshotRepository }

maven { name ‘release’; url releaseRepository }

}

}

My goal is to create task which dependsOn all publishToSnapshotRepository tasks. In old gradle this worked:

task deliver(dependsOn: tasks.findAll { task -\> task.name.endsWith(‘ToSnapshotRepository’) })

But since 2.2 and [http://gradle.org/docs/2.2/release-notes#publishing-plugins-and-native-language-support-plugins-changes](http://gradle.org/docs/2.2/release-notes#publishing-plugins-and-native-language-support-plugins-changes) publishing tasks are created after afterEvaluate

I try to write:

model {

tasks.deliver.dependsOn tasks.findAll { task -\> task.name.endsWith(‘ToSnapshotRepository’) })

}

but get

No signature of method: org.gradle.model.dsl.internal.NonTransformedModelDslBacking.endsWith() is applicable for argument types: (java.lang.String) values: [ToSnapshotRepository]

What should I do and where can I read more information about ‘model’ extension?

---

<div class="post-metadata">

**Author:** ![Yura\_Denison](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@Yura\_Denison](https://discuss.gradle.org/u/Yura_Denison)\
**Post date:** [March 3, 2015, 2:55pm UTC](https://discuss.gradle.org/t/maven-publish-plugin-tasks-managing-with-gradle-2-3/1813/2 "2015-03-03T14:55:00Z")

</div>

Any suggestions?

---

<div class="post-metadata">

**Author:** ![Mark\_Viera](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_viera/32/1543_2.png) [@Mark\_Viera](https://discuss.gradle.org/u/Mark_Viera)\
**Post date:** [March 3, 2015, 9:39pm UTC](https://discuss.gradle.org/t/maven-publish-plugin-tasks-managing-with-gradle-2-3/1813/3 "2015-03-03T21:39:00Z")

</div>

Actually the task you are configuring is your custom task not a publishing task, so in fact, you do not have to put this configuration inside the ‘model {…}’ configuration block. The key here is instead of using the default Groovy collection method ‘findAll’, you’ll want to use one the the Gradle collection methods that returns a “live” collection.

[https://gradle.org/docs/current/javadoc/org/gradle/api/tasks/TaskCollection.html#matching(groovy.lang.Closure)](https://gradle.org/docs/current/javadoc/org/gradle/api/tasks/TaskCollection.html#matching(groovy.lang.Closure))

task deliver {

dependsOn tasks.matching { it.name.endsWith(‘toSnapshotRepository’) }

}

---

<div class="post-metadata">

**Author:** ![Yura\_Denison](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@Yura\_Denison](https://discuss.gradle.org/u/Yura_Denison)\
**Post date:** [March 4, 2015, 7:58am UTC](https://discuss.gradle.org/t/maven-publish-plugin-tasks-managing-with-gradle-2-3/1813/4 "2015-03-04T07:58:00Z")

</div>

Thank you, Mark! Perfect solution.
