Search code examples
mavengradlepublishartifactmaven-publish

Publish Java artifact to Maven Local with Gradle


I am facing a problem when trying to install a generated jar into my local Maven Repository. The message error just show me 'task 'publish' is not found'

I am using this Gradle Script:

buildscript {
    ext {
        springBootVersion = '1.3.2.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'maven-publish'

jar {
    baseName = 'mongofoundry'
    version = '1.0.0'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7


repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-data-mongodb')
    testCompile('org.springframework.boot:spring-boot-starter-test') 
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}


eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.9'
}

Do you have some idea Why I am reading that error message? Thanks.

UPDATED

Running the command as @RaGe mentioned, solved the problem:

gradle publishToMavenLocal

Solution

  • The correct task to publish artifacts to local maven is

    gradle publishToMavenLocal