0

I am trying to publish to my local repositories

I have a multi module project. For one of the sub project, I am trying to publish to local maven repo.

But nothing is pushed but task is success.

Am I missing something

plugins {
    id 'org.springframework.boot' version "${gradleSpringBootPluginVersion}" apply false
    id 'io.spring.dependency-management' version "${gradleSpringDependencyPluginVersion}"
    id 'java'
    id 'maven-publish'
}
group 'org.gagagag'
version '1.0-SNAPSHOT'

subprojects {

    apply plugin: 'java'
    apply plugin: 'maven-publish'
    apply plugin: 'io.spring.dependency-management'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    configurations {
        compileOnly {
            extendsFrom annotationProcessor
        }
    }


    dependencyManagement {
        imports {
            mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
        }
    }

    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
    }

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

    dependencies {
        compileOnly 'org.projectlombok:lombok'
        annotationProcessor 'org.projectlombok:lombok'
        testAnnotationProcessor 'org.projectlombok:lombok'
    }

    repositories {
        mavenLocal()
        mavenCentral()
    }


    tasks.named('test') {
        useJUnitPlatform()
    }

}

I am checking maven repo, but cannot find the jar. Am I doing anything wrong.

Patan
  • 17,073
  • 36
  • 124
  • 198

1 Answers1

0

As you are using the 'maven-publish' plugin, the repository does not need to be declared in the publishing block

Remove the repository, so it returns it to:

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

then from the sub-project directory run the following which is included as part of the 'maven-publish' plugin:

./gradlew publishToMavenLocal

This will publish the jar to your local .m2 repository

djmonki
  • 3,020
  • 7
  • 18