Gradle publish does not send files to the nexus repository (maven 2)

0

I'm trying to make my project send the JARs files to a nexus repository (maven 2) but I'm not getting it. The project is scheduled in kotlin.

This code snippet is closest to what I got from a result:

plugins {
     id 'maven'
}

allprojects {
    uploadArchives {
        repositories {
            mavenDeployer {
                repository(url: "http://meusite.com/repository/meurepo-releases/") {
                    authentication(userName: variavelComUser, password: variavelComPass)
                }

                snapshotRepository(url: "http://meusite.com/repository/meurepo-snapshots/") {
                    authentication(userName: variavelComUser, password: variavelComPass)
                }
            }
        }
    }
}

When I run the task publish this occurs:

20:02:07: Executing task 'uploadArchives'...

> Task :uploadArchives
> Task :environment:core:compileJava NO-SOURCE
> Task :environment:core:compileKotlinCommon
> Task :environment:core:processResources NO-SOURCE
> Task :environment:core:classes
> Task :environment:core:inspectClassesForKotlinIC
> Task :environment:core:jar
> Task :environment:core:uploadArchives
> Task :environment:js:compileJava NO-SOURCE
> Task :environment:js:compileKotlin2Js
> Task :environment:js:processResources NO-SOURCE
> Task :environment:js:classes
> Task :environment:js:inspectClassesForKotlinIC
> Task :environment:js:jar
> Task :environment:js:uploadArchives
> Task :environment:jvm:compileKotlin
> Task :environment:jvm:compileJava NO-SOURCE
> Task :environment:jvm:processResources NO-SOURCE
> Task :environment:jvm:classes UP-TO-DATE
> Task :environment:jvm:inspectClassesForKotlinIC
> Task :environment:jvm:jar
> Task :environment:jvm:uploadArchives

BUILD SUCCESSFUL in 14s

But when I access the nexus I see nothing there, it is still empty.

What am I doing wrong or what is missing to do?

    
asked by anonymous 10.12.2018 / 00:05

1 answer

0

The problem is that uploadArchives block was not being applied to all projects as it seemed.

As my root project was just a container of other subprojects I solved it like this:

subprojects {
    afterEvaluate {
        if (it.plugins.hasPlugin('maven') ) {
            uploadArchives {
                repositories {
                    mavenDeployer {
                        repository(url: "http://meusite.com/repository/meurepo-releases/") {
                            authentication(userName: varComUser, password: varComSenha)
                        }

                        snapshotRepository(url: "http://meusite.com/repository/meurepo-snapshots/") {
                            authentication(userName: varComUser, password: varComSenha)
                        }
                    }
                }
            }
        }
    }
}

Looking at 3 major changes:

  • I've changed allprojects to subprojects since my root project has no source code.
  • I inserted the block afterEvaluate to execute the block after the first configurations are ready in all the submodules.
  • I added a check if you have the maven plugin before putting the uploadArchives and put the plugin in all the modules I want to export to nexus, so I took the block id maven from the plugins block of the root module .
  • In this way I was able to have each module sent to the nexus individually.

        
    10.12.2018 / 02:44