Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Cross compile to SBT {0.13.16, 1.0.1} #510

Merged
merged 11 commits into from
Sep 8, 2017
Merged

Conversation

suhasgaddam
Copy link
Contributor

No description provided.

jdk: oraclejdk8
env:
- SBT_VERSION=1.0.1
- scala: 2.10.6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be 2.12.3 because sbt version in build.properties is 1.0.1, but we are compiling for 0.13.16 which requires 2.10.6. It might be a trial/error to see if one is faster than the other.

@@ -25,6 +25,7 @@ import com.github.marklister.base64.Base64._
import github4s.Github
import github4s.GithubResponses._
import github4s.free.domain._
// import sbt.io.IO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following

import sbt.io._
import sbt.io.syntax._

and the equivalent are the just "notes" and would be the imports if we were using purely sbt 1.0.

https://github.com/dwijnand/sbt-compat allows us to keep the equivalent sbt 0.13 imports.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I think we could starting using those soon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of how sbt-compat, it exposes the sbt 1.0 api through the sbt 0.13 import statements. It's either that or have scala version specific source files where the only difference is something like

47deg-suhas:main suhas$ diff scala-2.10/sbtorgpolicies/io/io.scala scala-2.12/sbtorgpolicies/io/io.scala
24c24,25
< import sbt.{file, File}
---
> import sbt.io._
> import sbt.io.syntax._

I think we'll need to keep this until we stop supporting sbt 0.13.


val crossScalaVersions: List[String] = List(`2.11`, `2.12`)

}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better name for sbtV? I originally had sbt but that might inadvertently clash with the _root_.sbt

These will be removed once we have a snapshot published and use the corresponding sbtV and scalac in model.scala.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, can't think a better one now so I'm good keeping it as it is for now ;)

sbtBinaryVersionValue,
scalaBinaryVersionValue)
)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/tpolecat/tut
0.6.x -> sbt 1.x
0.5.x -> sbt 0.13.x

sbt-scalafmt -> I want to eventually switch to neo-sbt-scalafmt but I didn't then understand why scala 2.12 dependencies were getting pulled in for scalafmt-core. I currently kept different versions fot sbt-scalafmt to simply keep status quo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, let's open an issue to address that migration later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch to neo-sbt-scalafmt : #511

import sbt.Keys._
import sbt._

trait AllSettingsSpecific extends dependencies {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a naming convention for scala version specific files?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming things is always the hardest part 😛 .

Maybe just ScalaSettings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More naming questions :)
How about dependenciesSpecific.scala? Or should I just merge both files under ScalaSettings?
https://github.com/47deg/sbt-org-policies/pull/510/files#diff-c498862754c166dea83d0b202b567241

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could merge it under ScalaSettings 👍

scalaOrganization.value % "scalap" % scalaVersion.value
)
)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependencyOverrides ++= Set( / scala-2.10
vs
dependencyOverrides ++= Seq( / scala-2.12 (I need to look up how dependency precedence would work in this case)

@@ -1,4 +1,4 @@
import sbtorgpolicies.model._
import sbtorgpolicies.model.{ApacheLicense, GitHubSettings}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't completely understand why the wildcard import didn't work. It might be related to the original model.sbt object in model.scala I had.

@suhasgaddam
Copy link
Contributor Author

https://github.com/47deg/sbt-org-policies/pull/510/files#diff-a84f91f20f040218bccd09fed4761fb3R5 and https://github.com/47deg/sbt-org-policies/pull/510/files#diff-4198f89a479a3a8c2b310affc814c14fR127 took me the longest time to figure out.

First link: I didn't notice the difference of % and %% for a long time.

  • scripted-plugin : 0.13.16 exists for scala-2.10
  • scripted-plugin_2.12 : 1.0.1 exists for scala-2.12

How I found out the second link was possible sbt/sbt#3473 (comment).

Copy link
Member

@juanpedromoreno juanpedromoreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, outstanding work!

Before merging, let's wait until @fedefernandez can take a look since there are some changes initially added by me.

@@ -25,6 +25,7 @@ import com.github.marklister.base64.Base64._
import github4s.Github
import github4s.GithubResponses._
import github4s.free.domain._
// import sbt.io.IO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I think we could starting using those soon

@@ -44,7 +44,7 @@ object libraries {
"cats-effect" -> "0.3",
"circe" -> "0.8.0",
"config" -> "1.3.1",
"coursier" -> "1.0.0-RC9",
"coursier" -> "1.0.0-RC10",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think RC11 was already released.


val crossScalaVersions: List[String] = List(`2.11`, `2.12`)

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, can't think a better one now so I'm good keeping it as it is for now ;)


val scalaBinaryVersionValue = (scalaBinaryVersion in update).value

sbtVersionValue match {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this pattern match to only extract the tut and scalafmt deps, leaving just one Seq of settings at the end. What do you think?

Copy link
Contributor Author

@suhasgaddam suhasgaddam Sep 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean use the pattern match only and return ("0.5.3", "0.6.8") or ("0.6.0", "1.2.0")? DRY up the repeated group id and artifact id? If so, makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I meant ;)

sbtBinaryVersionValue,
scalaBinaryVersionValue)
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, let's open an issue to address that migration later on.

sbt.version = 1.0.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

import sbt.Keys._
import sbt._

trait AllSettingsSpecific extends dependencies {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming things is always the hardest part 😛 .

Maybe just ScalaSettings?

@suhasgaddam
Copy link
Contributor Author

@fedefernandez Can you look this PR over also?

Copy link
Contributor

@fedefernandez fedefernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -1,2 +1,2 @@
resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("com.47deg" % "sbt-org-policies" % sys.props("plugin.version"))
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.6.0-SNAPSHOT")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the environment variable

@suhasgaddam suhasgaddam merged commit b79af08 into master Sep 8, 2017
@suhasgaddam suhasgaddam deleted the sg-port-to-sbt-1.0.x branch September 8, 2017 16:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants