Search code examples
mavengradlequarkus

Quarkus Application PublishToMavenLocal not working


I'm trying to publish a Quarkus application to MavenLocal but I don't see any files in my .m2/repository folder. I've added the maven-publish plugin to my build.gradle file and I'm not getting any errors when publishing.
Maybe I've missed something and need to do more configuration to publish it ?
Here is my build.gradle file and my gradle.properties file :

plugins {
    id 'java'
    id 'io.quarkus'
    id 'maven-publish'
}

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    implementation 'io.quarkus:quarkus-config-yaml'
    implementation 'io.quarkus:quarkus-rest-client-reactive-jackson'
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    implementation 'io.quarkus:quarkus-arc'
    testImplementation 'io.quarkus:quarkus-junit5'
    testImplementation 'io.rest-assured:rest-assured'
}

group 'org.acme'
version '1.0.0-SNAPSHOT'

java {
    sourceCompatibility = JavaVersion.VERSION_21
    targetCompatibility = JavaVersion.VERSION_21
}

test {
    systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
}
compileJava {
    options.encoding = 'UTF-8'
    options.compilerArgs << '-parameters'
}

compileTestJava {
    options.encoding = 'UTF-8'
}
#Gradle properties
#Sat Jan 13 11:02:39 CET 2024
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus.platform
quarkusPlatformVersion=3.6.5
quarkusPluginId=io.quarkus
quarkusPluginVersion=3.6.5

Solution

  • That's because maven-publish plugin is not configured properly.
    By enabling detailed log like ./gradlew --info publishToMavenLocal no related task(s) will be found.

    To enable publishing just add the following section to build.gradle

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

    NOTE #1

    There are many options to customize publication. For further information see Maven Publish Plugin's guide.

    NOTE #2

    In Gradle 8.5 the :generateMetadataFileForMavenJavaPublication task will fail due to enfordec platform spec.

    To disable this check just add the following snippet to build.gradle

    tasks.withType(GenerateModuleMetadata).configureEach {
        suppressedValidationErrors.add('enforced-platform')
    }