Issues Publishing Custom Gradle Plugin

I am having some issues publishing a custom Gradle plugin, and I am struggling to figure out what I have done wrong.

When I publish my plugin via “publishToMavenLocal”, I am able to resolve it correctly and everything looks fine.

When I publish my plugin to my own HTTP maven repository, the artifacts are ending up in the locations I expected. However when I go to use it, it fails with the following error:

Could not HEAD ‘https://myHttpUrl/maven/com/business/cicd/business-project/com.business.cicd.business-project.gradle.plugin/0.1/com.business.cicd.business-project.gradle.plugin-0.1.jar

The format in that error message looks to be the plugin marker format which I expect it to only use for the initial POM resolution and then it should resolve the plugins JAR files based on the dependency in the plugin marker POM.

When looking at the differences between my ~.m2 directory and what gets created on the HTTP server, the folder paths all look correct but the maven local version is not producing as many files. My .m2 version will have

com/business/cicd/business-project/com.business.cicd.business-project.gradle.plugin/0.1/com.business.cicd.business-project.gradle.plugin-0.1.pom

but the HTTP repository version will have

.pom
.pom.md5
.pom.sha1
.pom.sha256
.pom.sha.512

Here is the contents of the POM file from my HTTP repository

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.business.cicd.business-project</groupId>
  <artifactId>com.business.cicd.buisness-project.gradle.plugin</artifactId>
  <version>0.1</version>
  <packaging>pom</packaging>
  <dependencies>
    <dependency>
      <groupId>com.buisness.cicd</groupId>
      <artifactId>cicd-worker</artifactId>
      <version>0.1</version>
    </dependency>
  </dependencies>
</project>

Here is the contents of my POM file from mavenLocal

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.business.cicd.business-project</groupId>
  <artifactId>com.business.cicd.business-project.gradle.plugin</artifactId>
  <version>0.1</version>
  <packaging>pom</packaging>
  <dependencies>
    <dependency>
      <groupId>com.business.cicd</groupId>
      <artifactId>cicd-worker</artifactId>
      <version>0.1</version>
    </dependency>
  </dependencies>
</project>

The com.business.cicd:cicd-worker:0.1 dependency is able to be resolved from my HTTP repository if I try to use it as an implementation dependency, it just seems to be an issue with the plugin marker not resolving correctly.

Any insight at all to this would be greatly appreciated.

It is normal for the remote repository to have checksums with various algorithms. I wouldn’t be concerned with this difference.

This is ultimately the final error, but it’s not the one that you need to look for or that’s actually causing a problem. When a POM cannot be resolved at a location, there’s a last ditch effort to find a JAR file at the same coordinates. As the final error, that’s usually the most obvious output at the end, but you should be able to find why the retrieval of the POM file failed first. I would expect a misconfiguration on the build side over an issue with what is actually in the repository.

Thank you very much for the reply! I’ve been trying to rerun with different flags like --stacktrace, --info and --debug, to try and get more information as to what the exact error is but I seem to keep coming up empty handed. The full error message from a normal run is :

2021-08-24T10:47:40.777-0230 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2021-08-24T10:47:40.777-0230 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Error resolving plugin [id: 'com.business.cicd.business-project', version: '0.1', apply: false]
2021-08-24T10:47:40.777-0230 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not resolve all dependencies for configuration 'detachedConfiguration1'.
2021-08-24T10:47:40.777-0230 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]    > Could not determine artifacts for com.business.cicd.business-project:com.business.cicd.business-project.gradle.plugin:0.1
2021-08-24T10:47:40.777-0230 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]       > Could not get resource 'https://myMavenHttpUrl/com/business/cicd/business-project/com.business.cicd.business-project.gradle.plugin/0.1/com.business.cicd.business-project.gradle.plugin-0.1.jar'.
2021-08-24T10:47:40.778-0230 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]          > Could not HEAD 'https://myMavenHttpUrl/com/business/cicd/business-project/com.business.cicd.business-project.gradle.plugin/0.1/com.business.cicd.business-project.gradle.plugin-0.1.jar'. Received status code 403 from server: Forbidden

I happen to be using a public S3 bucket for my http server, so that 403 forbidden in reality should be a 404 as the object does not exist. The only files present at the path

https://myMavenHttpUrl/com/business/cicd/business-project/com.business.cicd.business-project.gradle.plugin/0.1/

is the .pom file and 4 checksum files, there is no JAR.

I am wondering if the issue is downloading the transitive dependencies of my plugin? Here is the contents of the POM file for the com.business.cicd:cicd-worker:0.1 artifact, which is what I am expecting my plugin marker POM to resolve.

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.business.cicd</groupId>
  <artifactId>cicd-worker</artifactId>
  <version>0.1</version>
  <dependencies>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>apache-client</artifactId>
      <version>2.17.4</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>auth</artifactId>
      <version>2.17.4</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>sts</artifactId>
      <version>2.17.4</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
</project>

If anyone comes across this same issue, I was able to resolve it by using a

buildscript{} block instead of pluginManagement{} in the settings.gradle file and adding a class path dependency to the direct jar file and skipping the plugin marker pom file entirely.

Old:

settings.gradle

pluginManagement {
    repositories {
        maven {
            url 'myCustomUrl'
        }
        mavenCentral()
    }
}

build.gradle

plugins {
    id "com.business.cicd.my-plugin-name" version "0.1.5" apply false
}

subprojects {
    apply plugin: "com.business.cicd.my-plugin-name"
}

New:

settings.gradle

buildscript {
    repositories {
        maven {
            url "myCustomUrl"
        }
        mavenCentral()
    }
    dependencies {
        classpath "com.business.cicd:my-plugin-name:0.1.5"
    }
}

build.gradle

subprojects {
    apply plugin: "com.business.cicd.my-plugin-name"
}