abcxyz / lumberjack

Apache License 2.0
10 stars 4 forks source link

Lumberjack artifacts in maven repository don't work with gradle #456

Closed krjura closed 1 year ago

krjura commented 1 year ago

TL;DR

I am trying to integrate with Lumberjack library using Java and Gradle. Gradle is configured with

repositories {
    mavenCentral()

    maven {
        url = uri("https://us-maven.pkg.dev/abcxyz-artifacts/maven-repo")
        content {
            includeGroup("com.abcxyz.lumberjack")
            includeGroup("com.abcxyz.jvs")
        }
    }
}

dependencies {
   ...
    implementation("com.abcxyz.lumberjack:audit-client-library:0.0.5") {
        exclude(group = "org.slf4j", module = "slf4j-simple")
    }
   ...  
}

When I run a build I get the following error:

Execution failed for task ':kaptGenerateStubsKotlin'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve com.abcxyz.lumberjack:audit-client-library:0.0.5.
     Required by:
         project :
      > Could not resolve com.abcxyz.lumberjack:audit-client-library:0.0.5.
         > inconsistent module metadata found. Descriptor: com.abcxyz.lumberjack:audit-client-library:0.0.1 Errors: bad version: expected='0.0.5' found='0.0.1'

If I download the artifact from https://us-maven.pkg.dev/abcxyz-artifacts/maven-repo/com/abcxyz/lumberjack/audit-client-library/0.0.5/audit-client-library-0.0.5.pom I see that the version was not replaced but is

  <artifactId>audit-client-library</artifactId>
  <groupId>com.abcxyz.lumberjack</groupId>
  <version>${revision}</version>

The same seems to apply for JVS dependency

Execution failed for task ':kaptGenerateStubsKotlin'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve com.abcxyz.jvs:jvs-client:0.0.3.
     Required by:
         project : > com.abcxyz.lumberjack:audit-client-library:0.0.5
      > Could not resolve com.abcxyz.jvs:jvs-client:0.0.3.
         > inconsistent module metadata found. Descriptor: com.abcxyz.jvs:jvs-client:${revision} Errors: bad version: expected='0.0.3' found='${revision}'

I googled this problem and it seems your build might be affected by this issue https://stackoverflow.com/questions/41086512/maven-issue-to-build-one-module-using-revision-property. If I apply the fix (https://maven.apache.org/maven-ci-friendly.html#install-deploy - flatten plugin) to a local build and install the artefacts locally, version is set correctly.

Expected behavior

Version in the produced artifact should match release version.

Observed behavior

Artifact was produced with the correct layout but version inside the pom did not match the release version.

Environment Details

Java 20
Gradle 8.3

Additional information

No response

capri-xiyue commented 1 year ago

fixed by https://github.com/abcxyz/jvs/pull/373 and https://github.com/abcxyz/lumberjack/pull/454. You can use com.abcxyz.lumberjack:audit-client-library:0.0.6 to verify the issue already got fixed.