Skip to content

JReleaser fix problem with maven-metadata.xml not containing previous release versions info #10094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions local-build-plugins/src/main/groovy/local.publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,42 @@ tasks.withType(PublishToMavenLocal).configureEach {
}
}

def buildMavenMetadataXmlURI(groupId,artifactId) {
def snapshotRepo = "https://oss.sonatype.org/content/repositories/snapshots/"
def mavenRepo = "https://repo.maven.apache.org/maven2/"
def metadataXml = "${groupId.replace(".", "/")}/${artifactId}/maven-metadata.xml"

if (ormBuildDetails.hibernateVersion.isSnapshot) {
return "${snapshotRepo}${metadataXml}"
} else {
return "${mavenRepo}${metadataXml}"
}
}

/*
Needed because when publishing to the local staging folder the
maven-metadata.xml generated does not contain all the previous published versions
*/
def downloadMavenMetadataFile(groupId, artifactId) {

def destinationFolderName = "staging-deploy${File.separator}maven${File.separator}${groupId.replace(".", File.separator)}${File.separator}${artifactId}"
def destinationFolder = rootProject.layout.buildDirectory.dir(destinationFolderName).get()

def asFile = destinationFolder.getAsFile()
if (!asFile.exists()) {
asFile.mkdirs()
}
def destinationFile = new File(asFile.toString() + "/maven-metadata.xml")

def metadataFileURI = buildMavenMetadataXmlURI(groupId, artifactId)
new URI(metadataFileURI).toURL().withInputStream {
i -> destinationFile.withOutputStream { it << i }
}
}

tasks.withType(PublishToMavenRepository).configureEach {
doFirst {
downloadMavenMetadataFile(publication.groupId, publication.artifactId)
logger.lifecycle("PublishToMavenRepository ({} : {})", publication.name, repository.name)
logger.lifecycle(" - {} : {} : {} ", publication.groupId, publication.artifactId, publication.pom.packaging)
logger.lifecycle(" - artifacts ({})...", publication.artifacts.size())
Expand Down
Loading