jitpack / jitpack.io

Documentation and issues of https://jitpack.io
MIT License
2.49k stars 175 forks source link

Support SBT plugin builds #377

Open Darkyenus opened 8 years ago

Darkyenus commented 8 years ago

Jitpack already supports sbt's cross compiling (#178) and this is just a step further. When sbt publishes a sbt plugin (set by sbtPlugin := true in plugin's build.sbt), the resulting artifact name is in the following format: "artifactName_scalaVersion_sbtVersion" and jitpack does not seem to pick it up (standard cross compiling has only "artifactName_scalaVersion").

Here is a log from trying to build a sbt plugin: https://jitpack.io/com/github/Darkyenus/sbt-robovm/-1.12-g12bb28f-1/build.log Here is what sbt reports on my machine when trying to depend on it:

[info] Resolving com.github.Darkyenus#sbt-robovm;-SNAPSHOT ...
[warn]  module not found: com.github.Darkyenus#sbt-robovm;-SNAPSHOT
[warn] ==== typesafe-ivy-releases: tried
[warn]   https://repo.typesafe.com/typesafe/ivy-releases/com.github.Darkyenus/sbt-robovm/-SNAPSHOT/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.github.Darkyenus/sbt-robovm/-SNAPSHOT/ivys/ivy.xml
[warn] ==== local: tried
[warn]   /Users/Darkyen/.ivy2/local/com.github.Darkyenus/sbt-robovm/-SNAPSHOT/ivys/ivy.xml
[warn] ==== jcenter: tried
[warn]   https://jcenter.bintray.com/com/github/Darkyenus/sbt-robovm/-SNAPSHOT/sbt-robovm--SNAPSHOT.pom
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/com/github/Darkyenus/sbt-robovm/-SNAPSHOT/sbt-robovm--SNAPSHOT.pom
[warn] ==== jitpack: tried
[warn]   https://jitpack.io/com/github/Darkyenus/sbt-robovm/-SNAPSHOT/sbt-robovm--SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.github.Darkyenus#sbt-robovm;-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]          com.github.Darkyenus:sbt-robovm:-SNAPSHOT (/Users/Darkyen/IntelliJProjects/TinfoilPigeon/project/plugins.sbt#L8-9)
[warn]            +- default:tinfoilpigeon-build:0.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13)
sbt.ResolveException: unresolved dependency: com.github.Darkyenus#sbt-robovm;-SNAPSHOT: not found

Btw. great work, Jitpack is extremely useful to me, thanks!

jitpack-io commented 8 years ago

Hi

Thanks for reporting and for the nice words! Had a quick look and it appears that the plugin publishes a jar but not a pom https://jitpack.io/com/github/Darkyenus/sbt-robovm/-1.12-g12bb28f-1/build.log and that's why it is not picked up.

Darkyenus commented 8 years ago

You are right, the pom generation was for some reason disabled. But even after enabling it, jitpack does not seem to pick it up: https://jitpack.io/com/github/Darkyenus/sbt-robovm/1.12j/build.log

sbt looks for the pom at https://jitpack.io/com/github/Darkyenus/sbt-robovm_2.10_0.13/1.12j/sbt-robovm-1.12j.pom and fails. Querying that url in the browser prompts for authentication (?).

Thanks for the quick response!

jitpack-io commented 8 years ago

Aha, so sbt publishes the pom to: ~/.m2/repository/org/roboscala/sbt-robovm_2.10_0.13/1.12.0/sbt-robovm-1.12.0.pom while JitPack expects it to be: ~/.m2/repository/org/roboscala/sbt-robovm/1.12.0/sbt-robovm-1.12.0.pom

That is the issue.

lockwobr commented 8 years ago

any news on this issue?

jitpack-io commented 8 years ago

Ok, got an update. One of our users got it working by renaming the directory where files are published: https://github.com/avdv/sbt-release/blob/252c2556a4efcf80cdc4078dacea94ec76185342/build.sbt#L9-L17

publishM2 := {
  publishM2.value

  val d = file(sys.env("HOME")) / s".m2/repository/com/github/gseitz/sbt-release_${scalaBinaryVersion.value}_${sbtBinaryVersion.value}"
  d.renameTo(file(sys.env("HOME")) / ".m2/repository/com/github/gseitz/sbt-release")
}

sbtPlugin := true
publishMavenStyle := true

That build worked too. Is this something you can give a try? @Darkyenus @lockwobr

Darkyenus commented 8 years ago

This method works, thanks!

However it isn't so simple, or at least I have had some problems, this time with sbt itself, because it added <properties><scalaVersion>...</> <sbtVersion>...</></> to the .pom and the sbt attempted to retrieve cross compiled version anyway (even though the libraryDependenc(ies)y was specified without it). So I had to strip it first, using pomPostProcess: https://github.com/Darkyenus/sbt-robovm/commit/c52dfacda07660984d7425bc841ec7cd084addf9

emanresusername commented 7 years ago

looks like sbt has a lot of support for this out of the box... unfortunately, the same can't be said for the documentation of that support :sweat_smile:

my usecase

  1. forked git repo: https://github.com/emanresusername/scala-js-chrome.git
  2. non-master branch: scala-js-bundler
  3. multi project build of which i only needed one subproject: plugin

    project/plugins.sbt

    
    lazy val root = project.in(file(".")).dependsOn(scalaJsChromePlugin)

lazy val scalaJsChromePlugin = ProjectRef( build = uri("https://github.com/emanresusername/scala-js-chrome.git#scala-js-bundler"), project = "plugin" )


*NOTE:* the above would replace the `addSbtPlugin("net.lullabyte", "scala-js-chrome", "version")` line that would go in there otherwise

# similar usecases
https://stackoverflow.com/a/21211671/5886125
https://stackoverflow.com/a/20799240/5886125
http://alvinalexander.com/scala/using-github-projects-scala-library-dependencies-sbt-sbteclipse

# related issues
#806 
MarconZet commented 3 years ago

If someone is still looking for solution, this is what worked for me: build.sbt plugin.sbt