Skip to content
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

sbt-sonatype 3 does not work with sbt-dynver #95

Closed
Atry opened this issue Sep 6, 2019 · 19 comments
Closed

sbt-sonatype 3 does not work with sbt-dynver #95

Atry opened this issue Sep 6, 2019 · 19 comments

Comments

@Atry
Copy link
Contributor

Atry commented Sep 6, 2019

I use sbt-sonatype with sbt-dynver, to publish dynamic versions (e.g. 1.0.0+3-1234abcd ) to Maven Central.

Originally in sbt-sonatype 2.x, I used the command sbt ++$TRAVIS_SCALA_VERSION "sonatypeOpen \"Travis Job $TRAVIS_JOB_NAME $TRAVIS_JOB_NUMBER ($TRAVIS_JOB_WEB_URL)\"" publishSigned sonatypeRelease on Travis CI to publish a release.

After I upgrade sbt-sonatype to 3.4, I use the command sbt "set sonatypeSessionName := \"Travis Job $TRAVIS_JOB_NAME $TRAVIS_JOB_NUMBER ($TRAVIS_JOB_WEB_URL)\"" "set every publishTo := sonatypePublishToBundle.value" publishSigned sonatypeBundleRelease instead.

Unfortunately I got an error message of 400: Bad Request because sonatypePublishToBundle is sonatypeSnapshots, which does not support dynamic versions.

@xerial
Copy link
Owner

xerial commented Sep 6, 2019

It seems Sonatype API rejects bundles that contain dynamic version files like project-1.0.0+3-1234abcd.jar.

In this case, we need to fall back to the previous step (it still works in sbt-sonatype 3.x):

  • Setting publishTo := sonatypePublishTo.value (for direct upload)
  • sonatypePrepare
  • +publishSigned
  • sonatypeReleaseAll

I'll look into more details to see if there is any workaround.

@Atry
Copy link
Contributor Author

Atry commented Sep 6, 2019

sbt-dynver set isSnapshot to true for dynamic versions, which do not end with -SNAPSHOT.

@xerial
Copy link
Owner

xerial commented Sep 6, 2019

ah. OK. Then using isVersionStable will be more appropriate for sbt-dynver user.

@Atry
Copy link
Contributor Author

Atry commented Sep 6, 2019

You may be not willing to depend on sbt-dynver. Let's just check the version suffix. See #96

@xerial
Copy link
Owner

xerial commented Sep 6, 2019

Ok. #96 is merged. The next step is to test whether the bundle can be uploaded properly.

@xerial
Copy link
Owner

xerial commented Sep 6, 2019

ok. It seemed the comment #95 (comment) was my misunderstanding. I can properly upload artifacts that use sbt-dynver.

@xerial
Copy link
Owner

xerial commented Sep 6, 2019

I'm releasing sbt-sonatype-3.6 with the fix in #96 now.

Thank you for the fix!

@xerial xerial closed this as completed Sep 6, 2019
@Atry
Copy link
Contributor Author

Atry commented Sep 8, 2019

I just wonder if we could skip the snapshot version check for sonatypePublishToBundle, allowing for bundle uploading for any versions, no matter whether they end with -SNAPSHOT.

@Atry
Copy link
Contributor Author

Atry commented Sep 8, 2019

@xerial What do you think?

@xerial
Copy link
Owner

xerial commented Sep 9, 2019

Uploading jars with -SNAPSHOT suffix is possible with bundle upload, but the validation will anyway fail. So there is no point in allowing that operation.

And also there seems no Sonatype API to upload snapshot versions as a bundle to Sonatype Snapshot repository.

@Atry
Copy link
Contributor Author

Atry commented Sep 9, 2019 via email

@xerial
Copy link
Owner

xerial commented Sep 9, 2019

Unfortunately, publish and publishSigned share the same publishTo setting, so returning None is not good for Snapshot releases.

@Atry
Copy link
Contributor Author

Atry commented Sep 9, 2019 via email

@xerial
Copy link
Owner

xerial commented Sep 9, 2019

As long as we ask users to use publishTo := sonatypePublishToBundle.value, returning None for this value would not work. Othewise, we need to ask users to set settings like this:

publishTo := {
   if(version.value.endsWith("-SNAPSHOT")) 
      Opts(Sonatype.snapshot..)
   else 
      Opts(local resolver to staging folder) 
}

It's a design choice and I prefer a simpler one. Advanced users just can specify a local staging folder or arbitrary snapshot repository for publishTo.

@Atry
Copy link
Contributor Author

Atry commented Sep 9, 2019 via email

@xerial
Copy link
Owner

xerial commented Sep 9, 2019

There are various types of build settings (including parallel build), which cannot be covered by a single task:
https://github.com/xerial/sbt-sonatype#advanced-build-settings

Some people (including your case #26) want to publish each sub-module individually to different sonatype profile, but majorities of the case would be aggregating all sub-modules artifacts into a single staging folder.

A tricky part is to tweak publish(Signed)To setting internally without explicitly modifying it. We need to use sbt commands, but sbt commands cannot be run for each project. So we need to use Tasks to define things like SonatypeBundleUploading task (or command). However, calling a task from commands also can be tricky code.

I think implementing it is too much (at least for me for now).

If sbt has a command like publishStaging and publishStagingAggregate, then the role of sbt-sonatype will be much simpler. (cc: @dwijnand, @eed3si9n)

@Atry
Copy link
Contributor Author

Atry commented Sep 9, 2019 via email

@xerial
Copy link
Owner

xerial commented Sep 9, 2019

@dwijnand
Copy link

dwijnand commented Sep 16, 2019

You may be not willing to depend on sbt-dynver. Let's just check the version suffix. See #96

sbt identifies keys by structural equality.

So you can just define your own isVersionStable key and use it:

val isVersionStable = settingKey[Boolean]("")

// usage:
val result: Option[Boolean] = isVersionStable.?.value
// Using `?` in case sbt-dynver isn't present:
// None most probably means it's not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants