# How to test the existence of an artifact before publishing?

**URL:** <https://discuss.gradle.org/t/how-to-test-the-existence-of-an-artifact-before-publishing/10756>\
**Category:** Help/Discuss\
**Created:** [July 23, 2015, 7:59am UTC](https://discuss.gradle.org/t/how-to-test-the-existence-of-an-artifact-before-publishing/10756 "2015-07-23T07:59:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://discuss.gradle.org/u/Loic)\
**Post date:** [July 23, 2015, 7:59am UTC](https://discuss.gradle.org/t/how-to-test-the-existence-of-an-artifact-before-publishing/10756/1 "2015-07-23T07:59:22Z")

</div>

Hi,  
We are developing a process to publish artifacts on a regular basis for integration testing. For this, I would like to ensure that publishing an artifact does not overwrite an existing one, with the same version.  
So I would like to check whether an artifact with a specific name and version is present at a specific URL.  
Another apllication could also be to find the next available minor number to publish the current sources.  
I think that the API provides the required features but I did not find the entry point for it.

Thanks,  
Loïc.

---

<div class="post-metadata">

**Author:** ![Francois\_Guillot](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/francois_guillot/32/8566_2.png) [@Francois\_Guillot](https://discuss.gradle.org/u/Francois_Guillot)\
**Post date:** [July 23, 2015, 9:03am UTC](https://discuss.gradle.org/t/how-to-test-the-existence-of-an-artifact-before-publishing/10756/2 "2015-07-23T09:03:43Z")

</div>

Look for Gradle Artifact resolution query.

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://discuss.gradle.org/u/Loic)\
**Post date:** [July 23, 2015, 9:31am UTC](https://discuss.gradle.org/t/how-to-test-the-existence-of-an-artifact-before-publishing/10756/3 "2015-07-23T09:31:52Z")

</div>

Hi François,  
Thanks for your quick answer.  
This is a part of the solution I am seeking for. This way, I can check artifacts in the repositories my build depends on. But I am not sure that the DependencyHandler includes the repositories defined in the “publish” configuration. Can you confirm this ?  
If the default DependencyHandler cannot be used, what would be the most efficient way to create a request on the repository defined in the “publish” configuration ?

Regards,  
Loïc.

---

<div class="post-metadata">

**Author:** ![Francois\_Guillot](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/francois_guillot/32/8566_2.png) [@Francois\_Guillot](https://discuss.gradle.org/u/Francois_Guillot)\
**Post date:** [July 23, 2015, 11:29am UTC](https://discuss.gradle.org/t/how-to-test-the-existence-of-an-artifact-before-publishing/10756/4 "2015-07-23T11:29:29Z")

</div>

“But I am not sure that the DependencyHandler includes the repositories defined in the “publish” configuration.”

True. Dependencies are looked on the repo from the project’s repositories block.  
The publish block has its own repositories container.

By looking deeply into it, I’m not sure that you can achieve what you want right now.

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://discuss.gradle.org/u/Loic)\
**Post date:** [July 23, 2015, 12:14pm UTC](https://discuss.gradle.org/t/how-to-test-the-existence-of-an-artifact-before-publishing/10756/5 "2015-07-23T12:14:22Z")

</div>

Ok, I’ll try some workarounds and will post in the forum if I can find  
something valuable.

One suggestion I would like to do is that it would be useful to have an  
option to not overwrite existing artifacts during “publish”. I don’t  
know whether this is the right forum for this.

Thanks for the inputs.

Loïc.
