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

Directory standard #3681

Open
eed3si9n opened this issue Oct 27, 2017 · 11 comments
Open

Directory standard #3681

eed3si9n opened this issue Oct 27, 2017 · 11 comments

Comments

@eed3si9n
Copy link
Member

eed3si9n commented Oct 27, 2017

steps

Run sbt.

problem

We use ~/.sbt etc.

expectation

Adhere to directory standards?

@liff
Copy link
Contributor

liff commented Jan 31, 2018

Would it be possible to use directories like coursier does?

@dwijnand
Copy link
Member

Yes - with two concerns:

  1. how do this change impact sbt, its launcher (sbt/launcher), its ecosystem of plugins, and plugin cross-building from the current usage of ~/.sbt, and how do we provide a graceful migration?
  2. what's the stability of directories binary API?

@soc
Copy link
Contributor

soc commented Apr 11, 2018

@dwijnand Let me know if I can provide any information that helps sorting this out.

@dwijnand
Copy link
Member

my first concern is more specific to sbt's current use of directories, and I haven't given it much thought.

the other one is partially directories-specific (I see the current version of directories is "10"), but it's actually generic to libraries on the jvm: selecting a library requires everything else to be compatible with that library's binary API. in sbt's case it means if we start using directories 10 then for the rest of sbt 1 all plugins will have to use directories 10 (or a version for which the API they depend on is compatible with directories 10).

@soc
Copy link
Contributor

soc commented Apr 11, 2018

@dwijnand Hi Dale!

Regarding directories: It is built on Java 6, doesn't have any dependencies and consists of 4 files (you can probably get rid of two of them). I only publish major versions, so that no person depending on it will ever get a different version from what they originally specified in their build config, without explicitly changing it himself/herself.

I would suggest shading (parts of) this library for SBT's purposes to avoid any kind of classpath or compatibility concerns. The API itself is likely to be very stable now, as I have already considered and either gone through or rejected every major redesign I (and other people) can think of. Nevertheless, you can pick a version and just stick with it.

Regarding .sbt:

  • Move global config and plugins to .config/sbt (XDG_CONFIG_HOME).
  • Move .sbt/boot to .cache/sbt/boot (XDG_CACHE_HOME).
  • Compiled configuration should go into an appropriately named sub-directory in .cache/sbt (XDG_CACHE_HOME).
  • Socket files and locks need to go to XDG_RUNTIME_DIR.
  • (Optional, on Linux) Add the launcher to .local/bin (XDG_BIN_HOME).
  • Introduce SBT_CACHE_HOME, SBT_CONFIG_HOME, ... as a more principled replacement of SBT_HOME.

Other platforms work the same, if you use directories it should work as intended out of the box.
Migration can be handled in one of the ways other projects have done before, not many surprises here.

Regarding SBT's use of directories in projects: When I was still using Scala, one of the really annoying things (in addition to SBT dumping things into my $HOME dir), was that it mixed configuration and compiled artifacts all over the place.

Not being able to copy and paste build.sbt and project/ to a new directory is annoying, and unnecessarily so. Very often I just wanted to copy an existing project directory when starting a new project with similar configuration, and it took seconds for the filesystem to finish because of all the compiled artifacts dumped into project, which had to be deleted anyway.

So if you decide to clean up SBT's usage of directories, I would suggest sorting this out in the same breath – have one directory for compiled artifacts, e. g. target/project and one directory for build configuration, e. g. project, but please don't mix them.

@eed3si9n eed3si9n added the uncategorized Used for Waffle integration label Sep 18, 2018
@liff
Copy link
Contributor

liff commented Oct 29, 2018

After a version with launcher with #3598 fix is released this can be approximated with something like this set of options in either SBT_OPTS, _JAVA_OPTIONS, command line or whatever method one likes. Compiled configuration will still be under $XDG_CONFIG_HOME, though.

-Dsbt.ivy.home=$XDG_CACHE_HOME/ivy
-Dsbt.boot.directory=$XDG_CACHE_HOME/sbt/boot
-Dsbt.preloaded=$XDG_CACHE_HOME/sbt/preloaded
-Dsbt.global.base=$XDG_CACHE_HOME/sbt
-Dsbt.global.staging=$XDG_CACHE_HOME/sbt/staging
-Dsbt.global.zinc=$XDG_CACHE_HOME/sbt/zinc
-Dsbt.dependency.base=$XDG_CACHE_HOME/sbt/dependency
-Dsbt.repository.config=$XDG_CONFIG_HOME/sbt/repositories
-Dsbt.global.settings=$XDG_CONFIG_HOME/sbt/global
-Dsbt.global.plugins=$XDG_CONFIG_HOME/sbt/plugins

Add maven.repo.local, ivy.settings.dir, ivy.home and ivy.cache.dir to the mix if you like.

@eed3si9n eed3si9n added backlog and removed uncategorized Used for Waffle integration x/waffle labels Nov 8, 2018
@eed3si9n eed3si9n removed the backlog label Sep 10, 2019
dongjoon-hyun pushed a commit to apache/spark that referenced this issue Nov 18, 2020
…itHub Actions yaml

### What changes were proposed in this pull request?

This PR proposes:
- Add `~/.sbt` directory into the build cache, see also sbt/sbt#3681
- Move `hadoop-2` below to put up together with `java-11` and `scala-213`, see #30391 (comment)
- Remove unnecessary `.m2` cache if you run SBT tests only.
- Remove `rm ~/.m2/repository/org/apache/spark`. If you don't `sbt publishLocal` or `mvn install`, we don't need to care about it.
- Use Java 8 in Scala 2.13 build. We can switch the Java version to 11 used for release later.
- Add caches into linters. The linter scripts uses `sbt` in, for example, `./dev/lint-scala`, and uses `mvn` in, for example, `./dev/lint-java`. Also, it requires to `sbt package` in Jekyll build, see: https://github.com/apache/spark/blob/master/docs/_plugins/copy_api_dirs.rb#L160-L161. We need full caches here for SBT, Maven and build tools.
- Use the same syntax of Java version, 1.8 -> 8.

### Why are the changes needed?

- Remove unnecessary stuff
- Cache what we can in the build

### Does this PR introduce _any_ user-facing change?

No, dev-only.

### How was this patch tested?

It will be tested in GitHub Actions build at the current PR

Closes #30391 from HyukjinKwon/SPARK-33464.

Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
HyukjinKwon added a commit to HyukjinKwon/spark that referenced this issue Nov 19, 2020
…itHub Actions yaml

This PR proposes:
- Add `~/.sbt` directory into the build cache, see also sbt/sbt#3681
- Move `hadoop-2` below to put up together with `java-11` and `scala-213`, see apache#30391 (comment)
- Remove unnecessary `.m2` cache if you run SBT tests only.
- Remove `rm ~/.m2/repository/org/apache/spark`. If you don't `sbt publishLocal` or `mvn install`, we don't need to care about it.
- Use Java 8 in Scala 2.13 build. We can switch the Java version to 11 used for release later.
- Add caches into linters. The linter scripts uses `sbt` in, for example, `./dev/lint-scala`, and uses `mvn` in, for example, `./dev/lint-java`. Also, it requires to `sbt package` in Jekyll build, see: https://github.com/apache/spark/blob/master/docs/_plugins/copy_api_dirs.rb#L160-L161. We need full caches here for SBT, Maven and build tools.
- Use the same syntax of Java version, 1.8 -> 8.

- Remove unnecessary stuff
- Cache what we can in the build

No, dev-only.

It will be tested in GitHub Actions build at the current PR

Closes apache#30391 from HyukjinKwon/SPARK-33464.

Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
HyukjinKwon added a commit to HyukjinKwon/spark that referenced this issue Nov 19, 2020
…itHub Actions yaml

This PR proposes:
- Add `~/.sbt` directory into the build cache, see also sbt/sbt#3681
- Move `hadoop-2` below to put up together with `java-11` and `scala-213`, see apache#30391 (comment)
- Remove unnecessary `.m2` cache if you run SBT tests only.
- Remove `rm ~/.m2/repository/org/apache/spark`. If you don't `sbt publishLocal` or `mvn install`, we don't need to care about it.
- Use Java 8 in Scala 2.13 build. We can switch the Java version to 11 used for release later.
- Add caches into linters. The linter scripts uses `sbt` in, for example, `./dev/lint-scala`, and uses `mvn` in, for example, `./dev/lint-java`. Also, it requires to `sbt package` in Jekyll build, see: https://github.com/apache/spark/blob/master/docs/_plugins/copy_api_dirs.rb#L160-L161. We need full caches here for SBT, Maven and build tools.
- Use the same syntax of Java version, 1.8 -> 8.

- Remove unnecessary stuff
- Cache what we can in the build

No, dev-only.

It will be tested in GitHub Actions build at the current PR

Closes apache#30391 from HyukjinKwon/SPARK-33464.

Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun pushed a commit to apache/spark that referenced this issue Nov 19, 2020
…ure GitHub Actions yaml

### What changes were proposed in this pull request?

This PR backports #30391. Note that it's a partial backport.

This PR proposes:
- Add `~/.sbt` directory into the build cache, see also sbt/sbt#3681
- ~Move `hadoop-2` below to put up together with `java-11` and `scala-213`, see #30391 (comment)
- Remove unnecessary `.m2` cache if you run SBT tests only.
- Remove `rm ~/.m2/repository/org/apache/spark`. If you don't `sbt publishLocal` or `mvn install`, we don't need to care about it.
- ~Use Java 8 in Scala 2.13 build. We can switch the Java version to 11 used for release later.~
- Add caches into linters. The linter scripts uses `sbt` in, for example, `./dev/lint-scala`, and uses `mvn` in, for example, `./dev/lint-java`. Also, it requires to `sbt package` in Jekyll build, see: https://github.com/apache/spark/blob/master/docs/_plugins/copy_api_dirs.rb#L160-L161. We need full caches here for SBT, Maven and build tools.
- Use the same syntax of Java version, 1.8 -> 8.

### Why are the changes needed?

- Remove unnecessary stuff
- Cache what we can in the build

### Does this PR introduce _any_ user-facing change?

No, dev-only.

### How was this patch tested?

It will be tested in GitHub Actions build at the current PR

Closes #30416 from HyukjinKwon/SPARK-33464-3.0.

Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
HyukjinKwon added a commit to apache/spark that referenced this issue Nov 19, 2020
…ure GitHub Actions yaml

### What changes were proposed in this pull request?

This PR backports #30391. Note that it's a partial backport.

This PR proposes:
- Add `~/.sbt` directory into the build cache, see also sbt/sbt#3681
- ~Move `hadoop-2` below to put up together with `java-11` and `scala-213`, see #30391 (comment)
- Remove unnecessary `.m2` cache if you run SBT tests only.
- Remove `rm ~/.m2/repository/org/apache/spark`. If you don't `sbt publishLocal` or `mvn install`, we don't need to care about it.
- ~Use Java 8 in Scala 2.13 build. We can switch the Java version to 11 used for release later.~
- Add caches into linters. The linter scripts uses `sbt` in, for example, `./dev/lint-scala`, and uses `mvn` in, for example, `./dev/lint-java`. Also, it requires to `sbt package` in Jekyll build, see: https://github.com/apache/spark/blob/master/docs/_plugins/copy_api_dirs.rb#L160-L161. We need full caches here for SBT, Maven and build tools.
- Use the same syntax of Java version, 1.8 -> 8.

### Why are the changes needed?

- Remove unnecessary stuff
- Cache what we can in the build

### Does this PR introduce _any_ user-facing change?

No, dev-only.

### How was this patch tested?

It will be tested in GitHub Actions build at the current PR

Closes #30417 from HyukjinKwon/SPARK-33464-2.4.

Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
@ckipp01
Copy link
Contributor

ckipp01 commented Nov 1, 2022

Taken from #6914

I kind of agree. Here's the issue I created in 2017 - #3681
Likely we can't do much in sbt 1.x, but we can hope for sbt 2.x?

Is this a possibility for 2.x? Meaning if someone wanted to contribute and work on this, is it a direction that sbt would be ok with?

@SethTisue
Copy link
Member

@eed3si9n (this seems like something you might have meant to reply to?)

@eed3si9n
Copy link
Member Author

@SethTisue @ckipp01 Thanks Seth, and yea, probably this would be a good area of contribution.

@untainsYD
Copy link

@eed3si9n, are there any updates on that ISSUE? It's quite annoying, especially if you're trying to adhere to XDG standards; sbt ends up cluttering the home directory.

@eed3si9n
Copy link
Member Author

Besides the fact that I nominated this issue to sbt 2.0 ideas post, there's been no material update on this front.

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

No branches or pull requests

7 participants