Publish Java artifact to Maven Local with Gradle

孤人 提交于 2020-07-17 07:06:06

问题


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.

回答1:


The correct task to publish artifacts to local maven is

gradle publishToMavenLocal



回答2:


I use the task called install, like: gradle clean install



来源:https://stackoverflow.com/questions/35094655/publish-java-artifact-to-maven-local-with-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!