如何使用gradle和spring-boot发布到artifactory multimodule proj

时间:2016-02-04 13:54:54

标签: spring maven gradle build spring-boot

我正在使用gradle 2.7 我试图将我的一个子模块发布到artifactory中:

我的子模块的一部分被上传到snapshort,其中一部分被发布到release。

   apply plugin: 'java'
    apply plugin: 'idea'
    apply plugin: 'maven'
    apply plugin: 'maven-publish'



// Since spring-boot does not allow us to configure fat jar name...
task buildForCloud(type: Copy, dependsOn: [clean, build]) {
    from jar.archivePath
    into jar.destinationDir
    rename {
        'com.company.myapp-all.jar'
    }
}


//this module being uploaded into release and as soon as I added this //part I am getting errors
publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            artifact sourceJar {
                classifier "sources"
            }
        }
    }
}


buildForCloud.mustRunAfter(clean)

以这种方式运行:

./gradlew clean buildForCloud publishMavenJavaPublicationToMaven2Repository

错误:

* What went wrong:
Execution failed for task ':server:publishMavenJavaPublicationToMaven2Repository'.
> Failed to publish publication 'mavenJava' to repository 'maven2'
   > Unable to initialize POM pom-default.xml: Failed to validate POM for project com.mycompany.app:server at /Users/mycomp/IdeaProjects/user-service/server/build/publications/mavenJava/pom-default.xml

有什么想法吗?

添加了gradle日志请求:

Executing task ':server:sourceJar' (up-to-date check took 0.005 secs) due to:
  Output file /Users/comp/IdeaProjects/user-service/server/build/libs/server-1.1-SNAPSHOT-sources.jar has changed.
  Output file /Users/comp/IdeaProjects/user-service/server/build/libs/server-1.1-SNAPSHOT-sources.jar has been removed.
:server:sourceJar (Thread[main,5,main]) completed. Took 0.025 secs.
:server:publishMavenJavaPublicationToMaven2Repository (Thread[main,5,main]) started.
:server:publishMavenJavaPublicationToMaven2Repository
Executing task ':server:publishMavenJavaPublicationToMaven2Repository' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Publishing to repository org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository_Decorated@3c888166
[ant:null] An error has occurred while processing the Maven artifact tasks.
 Diagnosis:

Unable to initialize POM pom-default.xml: Failed to validate POM for project com.mycompany.userservice:server at /Users/comp/IdeaProjects/user-service/server/build/publications/mavenJava/pom-default.xml

:server:publishMavenJavaPublicationToMaven2Repository FAILED
:server:publishMavenJavaPublicationToMaven2Repository (Thread[main,5,main]) completed. Took 0.029 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':server:publishMavenJavaPublicationToMaven2Repository'.
> Failed to publish publication 'mavenJava' to repository 'maven2'
   > Unable to initialize POM pom-default.xml: Failed to validate POM for project com.mycompany.userservice:server at /Users/comp/IdeaProjects/user-service/server/build/publications/mavenJava/pom-default.xml

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 52.274 secs
Stopped 0 compiler daemon(s).
comps-MacBook-Pro-2:user-service comp$ ./gradlew clean buildForCloud -x test publishMavenJavaPublicationToMaven2Repository -i -

0 个答案:

没有答案