Closed seveneves closed 1 year ago
Also, the pom files are broken for transitive plugin dependencies with 1.9.0 and some dependencies are not included resulting in wrong dependency tree when a released plugin is used
This is known #76 . Patches are welcome.
This is known #76 . Patches are welcome.
I saw the issues but misunderstood its content. Will see if I can create a PR for it
Unfortunately, no time to fix this plugin in order to support sbt 1.9.0
. Instead, I wrote a small plugin that suits my use case.
Here is some relevant info how to fix the problem post sbt 1.9.0
if anyone else is having the issue of publishing to maven repositories and having maven-metadata.xml
updated at the same time (quite relevant for GitLab package repositories for example).
Precondition: all sbt projects that depend on the custom sbt plugin must be updated to 1.9.x
When publishing sbt plugin, use org.eclipse.aether.RepositorySystem
to publish along with following set sbtPluginPublishLegacyMavenStyle := false
Create org.eclipse.aether.RepositorySystem
with default services, no need to have a special case for sbt plugin.
Because of sbtPluginPublishLegacyMavenStyle
no special overrides are required for org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory
and org.eclipse.aether.impl.MetadataGenerator
val locator = new DefaultServiceLocator()
locator.addService(classOf[VersionResolver], classOf[DefaultVersionResolver])
locator.addService(classOf[VersionRangeResolver], classOf[DefaultVersionRangeResolver])
locator.addService(classOf[ArtifactDescriptorReader], classOf[DefaultArtifactDescriptorReader])
locator.addService(classOf[RepositoryConnectorFactory], classOf[BasicRepositoryConnectorFactory])
locator.addService(classOf[MetadataGeneratorFactory], classOf[VersionsMetadataGeneratorFactory])
locator.addService(classOf[ModelCacheFactory], classOf[DefaultModelCacheFactory])
locator.addService(classOf[TransporterFactory], classOf[HttpTransporterFactory])
val system: RepositorySystem = locator.getService(classOf[RepositorySystem])
convert Compile / packagedArtifacts
into org.eclipse.aether.artifact.DefaultArtifact
as
val request = new DeployRequest
request.addArtifact(
new DefaultArtifact(
organization,
art.name,
art.classifier.orNull,
art.extension,
version,
Collections.emptyMap[String, String](),
file,
)
)
Finally, call system.deploy(session, deployRequest)
to publish all artifacts with maven-metadata.xml
updated.
SBT 1.9.0 introduced
POM consistency of sbt plugin publishing
, this publishes artifacts in two formats.Aether plugin does not support this new format. For example here is output of
sbt publishM2
with different sbt version❗Aether plugin is installing these artifacts into the same destination, this results in duplicated request to install artifacts to a remote repository, which can fail if re-uploading is disabled
Here's output of
sbt aetherInstall | grep Installing
to show this problem when running locallyAlso, when setting key
sbtPluginPublishLegacyMavenStyle
to disable legacy format, Aether plugin is doing following❗
com.example:sbt-upload-bug:jar:0.1.0-SNAPSHOT
is installed twice once again.