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

update CONTRIBUTING #3960

Merged
merged 3 commits into from Feb 21, 2018

Conversation

Projects
None yet
3 participants
@eed3si9n
Copy link
Member

commented Feb 21, 2018

Fixes #3950

@eed3si9n eed3si9n requested review from retronym and dwijnand Feb 21, 2018


4. If a project has `project/build.properties` defined, either delete the file or change `sbt.version` to `1.0.0-SNAPSHOT`.
One drawback of `-SNAPSHOT` version is that it's slow to resolve as it tries to hit all the resolvers. You can workaround that by using a version name like `1.$MONIR.$PATCH-LOCAL1`. A non-SNAPSHOT artifacts will now be cached under `$HOME/.ivy/cache/` directory, so you need to clear that out using [sbt-dirty-money](https://github.com/sbt/sbt-dirty-money)'s `cleanLocal` task.

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

"MONIR"

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

You can workaround that by using a version name like 1.$MONIR.$PATCH-LOCAL1

Need instructions on how to pass that into the SBT build.


Directory `target` is removed by `clean` command. Second solution is using the artifact stored in the local ivy repository.
3. To build the launcher and publish all components locally,

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

Isn't the launcher in a different repo, not described in these instructions?

This comment has been minimized.

Copy link
@eed3si9n

eed3si9n Feb 21, 2018

Author Member

You're right.

The launcher is located in:
```
$ ./sbt-allsources.sh
> ;{../io}/publishLocal; {../util}/publishLocal; {../librarymanagement}/publishLocal; {../zinc}/publishLocal

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

Also need to publishBridgesAndSet 2.12.4 in the zinc project. I couldn't figure out how to do that via sbt-allsources.

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

Can this documentation be replaced with a command alias in the build?

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

I tried:

sbt:sbtRoot> set commands ++= (commands in ProjectRef(uri("../zinc"), "zincCore")).value
[info] Defining commands
[info] The new value will be used by no settings or tasks.
[info] Reapplying settings...
^[[A[info] Set current project to sbtRoot (in build file:/Users/jz/code/sbt-modules/sbt/)

sbt:sbtRoot> publishBridgesAndSet 2.12.4
[error] Expected ID character
[error] Not a valid command: compilerInterface
[error] Expected project ID
[error] Expected configuration
[error] Expected ':'
[error] Expected key
[error] Not a valid key: compilerInterface (similar: compilerCache, compileOrder, compileIncSetup)
[error] compilerInterface/publishLocal
[error]                  ^

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

Maybe we should be the command definition in a packaged .scala file in the zinc build so we can access it from the SBT build under sbt-all-sources.

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

Okay, so this seems to work in the absence of a working + for this use case.

set {val p=ProjectRef(uri("../zinc"), "compilerBridge");  scalaVersion in p := (crossScalaVersions in p).value(0)}
{../zinc}compilerBridge/publishLocal

set {val p=ProjectRef(uri("../zinc"), "compilerBridge");  scalaVersion in p := (crossScalaVersions in p).value(1)}
{../zinc}compilerBridge/publishLocal

set {val p=ProjectRef(uri("../zinc"), "compilerBridge");  scalaVersion in p := (crossScalaVersions in p).value(2)}
{../zinc}compilerBridge/publishLocal


set {val p=ProjectRef(uri("../zinc"), "compilerBridge");  scalaVersion in p := (crossScalaVersions in p).value(3)}
{../zinc}compilerBridge/publishLocal

This comment has been minimized.

Copy link
@eed3si9n

eed3si9n Feb 21, 2018

Author Member

Here's what I was about to commit

  commands += Command.command("publishLocalAllModule") { state =>
    val extracted = Project.extract(state)
    import extracted._
    val sv      = get(scalaVersion)
    val projs   = structure.allProjectRefs
    val ioOpt   = projs find { case ProjectRef(_, id) => id == "ioRoot"; case _ => false }
    val utilOpt = projs find { case ProjectRef(_, id) => id == "utilRoot"; case _ => false }
    val lmOpt   = projs find { case ProjectRef(_, id) => id == "lmRoot"; case _ => false }
    val zincOpt = projs find { case ProjectRef(_, id) => id == "zincRoot"; case _ => false }
    (ioOpt   map { case ProjectRef(build, _) => "{" + build.toString + "}/publishLocal" }).toList :::
    (utilOpt map { case ProjectRef(build, _) => "{" + build.toString + "}/publishLocal" }).toList :::
    (lmOpt   map { case ProjectRef(build, _) => "{" + build.toString + "}/publishLocal" }).toList :::
    (zincOpt map { case ProjectRef(build, _) =>
      val zincSv = get(scalaVersion in ProjectRef(build, "zinc"))
      val csv = get(crossScalaVersions in ProjectRef(build, "compilerBridge")).toList
      (csv flatMap { bridgeSv =>
        s"++$bridgeSv" :: ("{" + build.toString + "}compilerBridge/publishLocal") :: Nil
      }) :::
      List(s"++$zincSv", "{" + build.toString + "}/publishLocal")
    }).getOrElse(Nil) :::
    List(s"++$sv", "publishLocal") :::
    state
  },

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

With that, and the other instructions, I was able to modify util to beautify the logging and compile a sample project:

⚡ sbt
[❆info] ❆Loading settings from gpg.sbt,idea.sbt ...
[❆info] ❆Loading global plugins from /Users/jz/.sbt/1.0/plugins
[❆info] ❆Updating ProjectRef(uri("file:/Users/jz/.sbt/1.0/plugins/"), "global-plugins")...
[❆info] ❆Done updating.
[❆info] ❆Compiling 2 Scala sources to /Users/jz/.sbt/1.0/plugins/target/scala-2.12/sbt-1.0/classes ...
[❆info] ❆Done compiling.
[❆info] ❆Loading project definition from /private/tmp/sbt-scratch/project
[❆info] ❆Updating ProjectRef(uri("file:/private/tmp/sbt-scratch/project/"), "sbt-scratch-build")...
[❆info] ❆Done updating.
[❆info] ❆Loading settings from build.sbt ...
[❆info] ❆Set current project to sbt-scratch (in build file:/private/tmp/sbt-scratch/)
[❆info] ❆sbt server started at local:///Users/jz/.sbt/1.0/server/d783f1fc400c8f31587a/sock
sbt:sbt-scratch> compile
[❆info] ❆Compiling 1 Scala source to /private/tmp/sbt-scratch/target/scala-2.13.0-M2/classes ...
[❆info] ❆Non-compiled module 'compiler-bridge_2.13.0-M2' for Scala 2.13.0-M2. Compiling...
[❆info] ❆  Compilation completed in 7.275s.
[❆info] ❆Done compiling.
[❆success] ❆Total time: 8 s, completed 21/02/2018 5:21:32 PM
```
$ cd ../hello
$ sbt -Dsbt-version=1.1.2-SNAPSHOT
```

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

Does this method differ from sbt -sbt-version? I was a bit confused by the subsequent message about the mismatch between the build.properties version and the active version which talked about the reboot command. So I went back to editing build.properties.. Perhaps just suggest that way of doing it (which should be familiar to people)

This comment has been minimized.

Copy link
@eed3si9n

eed3si9n Feb 21, 2018

Author Member

Yea. Let's keep it simple.

This comment has been minimized.

Copy link
@dwijnand

dwijnand Feb 21, 2018

Member

sbt.version is the sys prop to set, not sbt-version.


3. After each `publishLocal`, clean the `~/.sbt/boot/` directory. Alternatively, if sbt is running and the launcher hasn't changed, run `reboot full` to have sbt do this for you.
When you run a locally built sbt, the JAR artifacts will be now cached under `$HOME/.sbt/boot/scala-2.12.4/org.scala-sbt/sbt/1.$MINOR.$PATCh-SNAPSHOT` directory. To clear this out run: `reboot dev` command from sbt's session of your test application.

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

"PATCh"

@retronym

This comment has been minimized.

Copy link
Member

commented Feb 21, 2018

This patch might still be required to stop Ivy from trying to compare version numbers from the stable and -SHA versions. I had a problem where the util project took the old artifact via a transitive dependency, even though I'd modified the source dependency.

===================================================================
--- project/Dependencies.scala	(revision 7df32cff849e4c9ef1412d979628fe20702b73d0)
+++ project/Dependencies.scala	(revision 2266349a7747c8daa03214e2941365db81247741)
@@ -9,9 +9,9 @@
 @@ -55,7 +55,7 @@
   def addSbtModule(p: Project, path: Option[String], projectName: String, m: ModuleID) =
     path match {
       case Some(f) => p dependsOn ProjectRef(file(f), projectName)
-      case None    => p settings (libraryDependencies += m)
+      case None    => p settings (libraryDependencies += m, dependencyOverrides += m)
     }
 
   def addSbtIO(p: Project): Project = addSbtModule(p, sbtIoPath, "io", sbtIO)

Note that sbt is always built with the previous stable release. For example, the [1.0.x](https://github.com/sbt/sbt/tree/1.0.x) branch is built with 0.13.13 and the [v0.13.13](https://github.com/sbt/sbt/tree/v0.13.13) tag is built with 0.13.12.
If you're working on a bug fix, it's a good idea to start with the `1.$MINOR.x` branch. Since we can always safely merge from stable to `1.x`, but not other way around.

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

s/branch. Since we can/branch. We can/

@eed3si9n

This comment has been minimized.

Copy link
Member Author

commented Feb 21, 2018

Without bumping up the patch version SHA1 will probably be interpreted as a milestone version.


4. If a project has `project/build.properties` defined, either delete the file or change `sbt.version` to `1.0.0-SNAPSHOT`.
One drawback of `-SNAPSHOT` version is that it's slow to resolve as it tries to hit all the resolvers. You can workaround that by using a version name like `1.$MINOR.$PATCH-LOCAL1`. A non-SNAPSHOT artifacts will now be cached under `$HOME/.ivy/cache/` directory, so you need to clear that out using [sbt-dirty-money](https://github.com/sbt/sbt-dirty-money)'s `cleanLocal` task.

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

... You can set this version with:

sbt> set version in ThisBuild := (version in ThisBuild).value.replaceAll("-SNAPSHOT",  "-LOCAL1")

4. If a project has `project/build.properties` defined, either delete the file or change `sbt.version` to `1.0.0-SNAPSHOT`.
One drawback of `-SNAPSHOT` version is that it's slow to resolve as it tries to hit all the resolvers. You can workaround that by using a version name like `1.$MINOR.$PATCH-LOCAL1`. A non-SNAPSHOT artifacts will now be cached under `$HOME/.ivy/cache/` directory, so you need to clear that out using [sbt-dirty-money](https://github.com/sbt/sbt-dirty-money)'s `cleanLocal` task.

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

Do you mean $HOME/.ivy/local/ here?

This comment has been minimized.

Copy link
@dwijnand

dwijnand Feb 21, 2018

Member

no I think the mistake is the suggestion should be to run cleanCache

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

I've just been incrementing my version number to reduce the cognitive load :)


Directory `target` is removed by `clean` command. Second solution is using the artifact stored in the local ivy repository.
3. To build and publish all components locally,

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member

Test changes to modules using sbt test in the module directory, and/or by following other the instructions in the module's README.

Once you're ready to integration test changes to module(s) with SBT:

$ cd sbt 
$ ./sbt-allsources.sh
 sbt:sbtRoot> publishLocalAllModule
}).getOrElse(Nil) :::
List(s"++$sv", "publishLocal") :::
state
},

This comment has been minimized.

Copy link
@retronym

This comment has been minimized.

Copy link
@retronym

retronym Feb 21, 2018

Member
./sbt-allsources.sh 'set version in ThisBuild ~= (_.replaceAll("-SNAPSHOT",  "-LOCAL1"))' cleanLocal publishLocalAllModule

worked for me

@retronym

This comment has been minimized.

Copy link
Member

commented Feb 21, 2018

This section could be edited to refer to these more complete instructions.

@dwijnand
Copy link
Member

left a comment

LGTM

@eed3si9n eed3si9n merged commit 9a5b7bc into sbt:1.1.x Feb 21, 2018

0 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@eed3si9n eed3si9n deleted the eed3si9n:wip/contributing branch Feb 21, 2018

@eed3si9n eed3si9n removed the in progress label Feb 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.