Install task vs uploadArchives task: location and checksum issues

I’m a newbie to Gradle and use it on a first project. What I don’t get is the difference between the task ‘install’ and the task ‘uploadArchives’ assuming that both are task from the maven plugin… Here is my gradle.build:

apply plugin: 'eclipse'
apply from: 'file:///g:/Development/Netkernel/gradle-commons/netkernel-libs.gradle' // NetKernel libs
apply plugin: 'maven'
apply plugin: 'java'
  //Define the project group in which built modules are stored in the repository.
project.group = 'nkse-panel-security'
  //Provide this buildscript with repositories and dependencies to obtain the netkernel plugin
buildscript {
    repositories {
        mavenCentral()
        maven { url "file:///G:/Maven/m2/repository/"
}
    }
}
  // This task puts the resulting jar files into a local maven repository
uploadArchives {
    repositories {
        mavenDeployer {
          repository(url: "file:///G:/Maven/m2/repository/")
        }
    }
}
  //The repository where we'll get the deployed modules from
repositories {
    maven {
        url "file:///G:/Maven/m2/repository/"
    }
}
  dependencies {
 compile libraries.netkernel_core
 compile libraries.netkernel_modules_core
}

The file c:\Users\Stefan.m2\settings.xml has the entry

<localRepository>G:/Maven/m2/repository</localRepository><\code>
  <code>gradle install

results in the jar put at the correct location (‘G:\Maven\m2\repository’) and the pom file created.

gradle uploadArchives

results in the jar put in the correct location and unwanted in ‘c:\Users\Stefan.m2\repository’, the pom file created and checksum files (md5, sha1).

But how can I achieve my desired result: Only correct location (‘G:\Maven\m2\repository’) and checksum files?

Thanks in advance, Stefan

------------------------------------------------------------ Gradle 2.3 ------------------------------------------------------------

Build time:

2015-02-16 05:09:33 UTC Build number: none Revision:

586be72bf6e3df1ee7676d1f2a3afd9157341274

Groovy:

2.3.9 Ant:

Apache Ant™ version 1.9.3 compiled on December 23 2013 JVM:

1.8.0_31 (Oracle Corporation 25.31-b07) OS:

Windows 7 6.1 amd64

In your case, there is no difference. But if you were using a local Maven repo, say one configure internally using Apache Archiva or a similar server, uploadArchives would be set to put your builds there (as in the example below).

ext {
  localRepo = "http://sourcesrv:8080/repository/devel.internal/"
}
...
apply plugin: 'maven'
uploadArchives {
  repositories {
    mavenDeployer {
      repository(url: project.ext.localRepo) {
        authentication(userName: repoUserName, password: repoPassword)
      }
      pom.version = 'version'
      pom.groupId = 'group'
      pom.artifactId = 'artifact'
    }
  }
}
$ gradle install
 # to my local gradle cache
$ gradle uploadArchives
# to my workgroup's internal Apache Archiva server

I’ve not tried to set up install to point to ~/.m2/repository

Thanks for the answer Thad!

Difference is that the install task creates no checksums and the uploadArchives tasks installs twice. One time at the configured location and one time at ~/.m2/repository which I don’t want and didn’t configure knowingly. There a pom called ‘maven-metadata-remote.xml’ is created, maybe this helps why this install is done.

Thanks,

Stefan

Found the cause of my problem:

The task uploadArchives takes M2_HOME\conf\settings.xml into consideration. As I have no maven server installed, M2_HOME was not set, so I set it pointing to ~.m2\repository and inside added conf\settings.xml.

Now uploadArchives deploys only to the desired location and creates the checksums.

Stefan