How to exclude zip only from archives for Maven repo upload?

Hi all,

I’ve inherited a multi-project build using application plugin. I’ve added maven plugin to upload artifacts to a repo. I want to upload the distTar artifacts only. I want the distZip artifacts to be excluded from the upload. Or ideally not generated at all…

The build runs distZip and distTar. When I exclude distZip (with -x distZip or distZip.enabled = false) the uploadArchives task fails with the error below.

Should skipping distZip be enough?

I also tried adding an exclude '**/*.zip' to the distributions { main{ contents {} } } config to no avail. Also tried this - Gradle distribution DSL containing an exclude rule that uses a regex to filter out all but one properties file. · GitHub

:subproj1:distTar (Thread[Daemon worker Thread 4,5,main]) started.
:subproj1:distTar
Executing task ‘:subproj1:distTar’ (up-to-date check took 0.046 secs) due to:
No history is available.
:subproj1:distTar (Thread[Daemon worker Thread 4,5,main]) completed. Took 6.652 secs.
:subproj1:distZip (Thread[Daemon worker Thread 4,5,main]) started.
:subproj1:distZip
Skipping task ‘:subproj1:distZip’ as task onlyIf is false.
:subproj1:distZip SKIPPED
:subproj1:distZip (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.0 secs.
:subproj1:uploadArchives (Thread[Daemon worker Thread 4,5,main]) started.
:subproj1:uploadArchives
Executing task ‘:subproj1:uploadArchives’ (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
Publishing configuration: configuration ‘:subproj1:archives’
:subproj1:uploadArchives FAILED
:subproj1:uploadArchives (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.0 secs.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:subproj1:uploadArchives’.

Could not publish configuration ‘archives’
Cannot publish artifact ‘subproj1.zip (mainproj:subproj1:1.0-141)’ (C:\DATA\dev\mainproj\subproj1\build\distributions\subproj1-1.0-141.zip) as it does not exist.

$ gradle -version


Gradle 2.6

Build time: 2015-08-10 13:15:06 UTC
Build number: none
Revision: 233bbf8e47c82f72cb898b3e0a96b85d0aad166e

Groovy: 2.3.10
Ant: Apache Ant™ version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_65 (Oracle Corporation 25.65-b01)
OS: Windows 7 6.1 amd64

Many thanks,
B.

Something like this should do:

configurations.archives.with {
    artifacts.remove artifacts.find { it.archiveTask.is distZip }
}

Many thanks. That worked.

I naively hoped disabling the distZip task would do this :slight_smile: but wrenching the zip artifacts out of the archives collection by brute force as part of the uploadArchives configuration setup works fine.

Perhaps the new maven-publish plugin that currently incubating may just-work™ in this manner.

Hi,

it seems this solution is not working with Gradle 5 any more. I get the following error:

* What went wrong:
Execution failed for task ':publishMavenJavaPublicationToMavenLocal'.
> Failed to publish publication 'mavenJava' to repository 'mavenLocal'
   > Invalid publication 'mavenJava': artifact file does not exist: 'blablalba.zip'

Do you know an alternate solution?

Thanks
Andy