Home > Software engineering >  How do I publish file created by zip task in gradle
How do I publish file created by zip task in gradle

Time:01-24

I'd like to publish the output of my custom zip task to a maven repo. My problem is that when I set the artifact of the publication as the zip task, the file that gets zipped is not what gets published. Instead what gets published is the value given to the "from" argument of my custom zip task. How would I make it so that "jar.zip" is the file that is published?

tasks.register('zipJars', Zip) {
    archiveFileName = "jar.zip"
    destinationDirectory = layout.buildDirectory.dir("${projectDir.parentFile}/DesktopAndroid/jars/zipped")
    from fatJarDev
}


publishing {

    publications {

        apkBuilding(MavenPublication){
            artifact zipJars
        }
    }

    repositories {
        maven {
            name = 'Local'
            url = "file://${rootDir}/Repository"
        }
        
    }
}```

CodePudding user response:

Ah - are you referring to the name of the file in the maven repo ? you will need to customise it in publication ;

see https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPublication.html

publishing {
    publications {
        apkBuilding(MavenPublication){
            artifact zipJars
            artifactId 'zipjars'
        }
    }

    repositories {
        maven {
            name = 'Local'
            url = "file://${rootDir}/Repository"
        }
    }
}
  • Related