10

I'm trying to build Apache S4 and publish it to our Nexus repository. gradle publishToMavenLocal worked, so I added

publishing {
    repositories {
        maven {
            credentials {
                username "admin"
                password "admin123"
            }
            url "http://127.0.0.1:9081/nexus/content/repositories/releases/"
        }
    }
}    

to build.gradle after apply plugin: 'maven-publish'. This worked for other projects on the same machine. However, now I get

aromanov@ws:~/etc/apache-s4-0.6.0$ gradle clean publish
Build file '/home/aromanov/etc/apache-s4-0.6.0/subprojects/s4-benchmarks/s4-benchmarks.gradle': line 42
The RepositoryHandler.mavenRepo() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the maven() method instead.
Runs Apache RAT. Exclusions are defined in .rat-excludes fileUNDEFINED
:clean
:s4-base:clean
:s4-benchmarks:clean
:s4-comm:clean
:s4-core:clean
:s4-tools:clean
:test-apps:clean
:test-apps:consumer-app:clean
:test-apps:producer-app:clean
:test-apps:simple-deployable-app-1:clean
:s4-base:publish UP-TO-DATE
:s4-benchmarks:publish UP-TO-DATE
:s4-comm:publish UP-TO-DATE
:s4-core:publish UP-TO-DATE
:s4-tools:publish UP-TO-DATE
:test-apps:publish UP-TO-DATE
:test-apps:consumer-app:publish UP-TO-DATE
:test-apps:producer-app:publish UP-TO-DATE
:test-apps:simple-deployable-app-1:publish UP-TO-DATE

BUILD SUCCESSFUL

Total time: 10.468 secs

Using gradle -i I get

Selected primary task 'publish'
Tasks to be executed: [task ':s4-base:publish', task ':s4-benchmarks:publish', task ':s4-comm:publish', task ':s4-core:publish', task ':s4-tools:publish', task ':test-apps:publish', task ':test-apps:consumer-app:publish', task ':test-apps:producer-app:publish', task ':test-apps:simple-deployable-app-1:publish']
:s4-base:publish (Thread[main,5,main]) started.
:s4-base:publish
Skipping task ':s4-base:publish' as it has no actions.
:s4-base:publish UP-TO-DATE
:s4-base:publish (Thread[main,5,main]) completed. Took 0.005 secs.
... so on for other subprojects

There is no output at the Nexus repository. How can I fix this?

UPDATE: if I use configuration from chapter 51 of the User Guide, replacing ivy by maven:

uploadArchives {
    repositories {
        maven {
            credentials {
                username "admin"
                password "admin123"
            }
            url "http://127.0.0.1:9081/nexus/content/repositories/releases/"
        }
    }
}

then upload works, but it uploads jars and ivy.xml, without POMs. With config from Chapter 52:

configurations {
    deployerJars
}

dependencies {
    deployerJars "org.apache.maven.wagon:wagon-http:2.2"
}

uploadArchives {
    configuration = configurations.deployerJars
    repositories {
        mavenDeployer {
            repository(url: "http://127.0.0.1:9081/nexus/content/repositories/releases/") {
                authentication(userName: "admin", password: "admin123")
            }
        }
    }
}

I get

aromanov@ws:~/etc/apache-s4-0.6.0$ gradle -i upload
Starting Build
Starting file lock listener thread.
...
Publishing configuration: configuration ':s4-base:deployerJars'
Publishing to repository 'mavenDeployer'
[ant:null] Error reading settings file '/tmp/gradle_empty_settings2934509160228124339.xml' - ignoring. Error was: /tmp/gradle_empty_settings2934509160228124339.xml (No such file or directory)
:s4-base:uploadArchives (Thread[main,5,main]) completed. Took 1.113 secs.
...

The complete build script.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
  • Did you declare any publications, as explained in the [Gradle User Guide](http://gradle.org/docs/current/userguide/userguide_single.html)? Also note that the new & incubating `maven-publish` plugin has known limitations. For the time being, it's generally safer to use the existing `maven` plugin. – Peter Niederwieser Nov 19 '13 at 11:45
  • @PeterNiederwieser I've tried to use the `maven` plugin, but didn't succeed. See the update. – Alexey Romanov Nov 19 '13 at 12:14
  • If it uploads `ivy.xml`, then something is likely wrong with your build script (but based on the information provided I can't say what). The last snippet fails because a configuration has to be declared before it's being used (i.e. `configurations` has to come before `dependencies`). – Peter Niederwieser Nov 19 '13 at 12:24
  • Yes. I've fixed that part, along with `uploadArchives` config. Still no success, but there is at least some progress. – Alexey Romanov Nov 19 '13 at 12:31
  • To help further, I'd need to see all configuration related to publishing in one piece. Not sure what the settings file error means, and whether it's really an error, rather than just some info message. – Peter Niederwieser Nov 19 '13 at 12:33
  • I've added the complete build script in a gist. I think the only part directly related to publishing which wasn't there before is that all of this is in `subprojects` after `apply plugin: 'maven'`. – Alexey Romanov Nov 19 '13 at 12:59
  • 1
    Some more hints: 1. I wouldn't apply both the `maven` and the `maven-publish` plugin. 2. `uploadArchives.configuration` determines what to upload. Instead, what you want is `uploadArchives.repositories.mavenDeployer.configuration = configurations.deployerJars`. Did we get that wrong in the docs somewhere? – Peter Niederwieser Nov 19 '13 at 13:19

1 Answers1

11

If no any action found, it will mark as up to date . I am using gradle 2.4 and this is working like a charm

publishing {
  publications {
      mavenJava(MavenPublication) {
          from components.java
      }
  }
  repositories {
    maven {
      credentials {
        username 'admin'
        password 'password'
      }
      url "http://baseUrl/artifactory/libs-release-local"
    }
  }
}

you need to provide publish repositories and publications.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
Vivek Adhikari
  • 221
  • 2
  • 7
  • I was having same issue until I added a local repository ~/.m2/repository as follows: repositories { maven { url 'file://' + System.getProperty('user.home') + '/.m2/repository/' } } – Farrukh Najmi Dec 18 '15 at 17:45
  • In my case, I got the same message "publish UP-TO-DATE" and the problem solved adding publications { mavenJava(MavenPublication) { from components.java } } – Peter S. Oct 09 '20 at 09:39