-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Fix conflicting dependencies between upstream JavaModule
s
#2735
Merged
lihaoyi
merged 27 commits into
com-lihaoyi:main
from
lihaoyi:fix-conflicting-dependencies
Sep 14, 2023
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8df4ed0
.
lihaoyi 9d1cf9f
.
lihaoyi f2a66b4
.
lihaoyi c3d12eb
.
lihaoyi ada4658
.
lihaoyi 69e58c5
.
lihaoyi 81865e6
.
lihaoyi d363717
.
lihaoyi 4ad1b83
wip
lihaoyi 4d03f0b
wip
lihaoyi bb49351
wip
lihaoyi 324e2a2
wip
lihaoyi 33009ca
wip
lihaoyi ae23dd7
wip
lihaoyi e124d62
.
lihaoyi 4e65f06
fixes
lihaoyi 189eaa4
make compileIvyDeps not transitive
lihaoyi 9a4e827
fixjimfs
lihaoyi 2fca25b
.
lihaoyi 6f54cf5
.
lihaoyi 52383e3
try to fix bsp bootstrap compile
lihaoyi 066c19a
put back transitive compileIvyDeps
lihaoyi 9f8774c
.
lihaoyi 8503340
.
lihaoyi 57b17e6
.
lihaoyi 06d9637
.
lihaoyi e0ac3b7
.
lihaoyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,12 +128,34 @@ trait JavaModule | |
/** The compile-only direct dependencies of this module. */ | ||
def compileModuleDeps: Seq[JavaModule] = Seq.empty | ||
|
||
/** The direct and indirect dependencies of this module */ | ||
def recursiveModuleDeps: Seq[JavaModule] = { | ||
moduleDeps.flatMap(_.transitiveModuleDeps).distinct | ||
} | ||
|
||
/** | ||
* Like `recursiveModuleDeps` but also include the module itself, | ||
* basically the modules whose classpath are needed at runtime | ||
*/ | ||
def transitiveModuleDeps: Seq[JavaModule] = Seq(this) ++ recursiveModuleDeps | ||
|
||
/** | ||
* All direct and indirect module dependencies of this module, including | ||
* compile-only dependencies: basically the modules whose classpath are needed | ||
* at compile-time. | ||
* | ||
* Note that `compileModuleDeps` are defined to be non-transitive, so we only | ||
* look at the direct `compileModuleDeps` when assembling this list | ||
*/ | ||
def transitiveModuleCompileModuleDeps: Seq[JavaModule] = { | ||
(moduleDeps ++ compileModuleDeps).flatMap(_.transitiveModuleDeps).distinct | ||
} | ||
|
||
/** The compile-only transitive ivy dependencies of this module and all it's upstream compile-only modules. */ | ||
def transitiveCompileIvyDeps: T[Agg[BoundDep]] = T { | ||
// We never include compile-only dependencies transitively, but we must include normal transitive dependencies! | ||
compileIvyDeps().map(bindDependency()) ++ T | ||
.traverse(compileModuleDeps)(_.transitiveIvyDeps)() | ||
.flatten | ||
compileIvyDeps().map(bindDependency()) ++ | ||
T.traverse(compileModuleDeps)(_.transitiveIvyDeps)().flatten | ||
} | ||
|
||
/** | ||
|
@@ -158,16 +180,6 @@ trait JavaModule | |
T.log.outputStream.println(asString) | ||
} | ||
|
||
/** The direct and indirect dependencies of this module */ | ||
def recursiveModuleDeps: Seq[JavaModule] = { | ||
moduleDeps.flatMap(_.transitiveModuleDeps).distinct | ||
} | ||
|
||
/** Like `recursiveModuleDeps` but also include the module itself */ | ||
def transitiveModuleDeps: Seq[JavaModule] = { | ||
Seq(this) ++ recursiveModuleDeps | ||
} | ||
|
||
/** | ||
* Additional jars, classfiles or resources to add to the classpath directly | ||
* from disk rather than being downloaded from Maven Central or other package | ||
|
@@ -180,28 +192,22 @@ trait JavaModule | |
* This is calculated from [[ivyDeps]], [[mandatoryIvyDeps]] and recursively from [[moduleDeps]]. | ||
*/ | ||
def transitiveIvyDeps: T[Agg[BoundDep]] = T { | ||
(ivyDeps() ++ mandatoryIvyDeps()).map(bindDependency()) ++ T.traverse(moduleDeps)( | ||
_.transitiveIvyDeps | ||
)().flatten | ||
(ivyDeps() ++ mandatoryIvyDeps()).map(bindDependency()) ++ | ||
T.traverse(moduleDeps)(_.transitiveIvyDeps)().flatten | ||
} | ||
|
||
/** | ||
* The upstream compilation output of all this module's upstream modules | ||
*/ | ||
def upstreamCompileOutput: T[Seq[CompilationResult]] = T { | ||
T.traverse((recursiveModuleDeps ++ compileModuleDeps.flatMap( | ||
_.transitiveModuleDeps | ||
)).distinct)(_.compile) | ||
T.traverse(transitiveModuleCompileModuleDeps)(_.compile) | ||
} | ||
|
||
/** | ||
* The transitive version of `localClasspath` | ||
*/ | ||
def transitiveLocalClasspath: T[Agg[PathRef]] = T { | ||
T.traverse( | ||
(moduleDeps ++ compileModuleDeps).flatMap(_.transitiveModuleDeps).distinct | ||
)(m => m.localClasspath)() | ||
.flatten | ||
T.traverse(transitiveModuleCompileModuleDeps)(_.localClasspath)().flatten | ||
} | ||
|
||
/** | ||
|
@@ -210,20 +216,16 @@ trait JavaModule | |
// Keep in sync with [[transitiveLocalClasspath]] | ||
@internal | ||
def bspTransitiveLocalClasspath: T[Agg[UnresolvedPath]] = T { | ||
T.traverse( | ||
(moduleDeps ++ compileModuleDeps).flatMap(_.transitiveModuleDeps).distinct | ||
)(m => m.bspLocalClasspath)() | ||
.flatten | ||
T.traverse(transitiveModuleCompileModuleDeps)(_.bspLocalClasspath)().flatten | ||
} | ||
|
||
/** | ||
* The transitive version of `compileClasspath` | ||
*/ | ||
def transitiveCompileClasspath: T[Agg[PathRef]] = T { | ||
T.traverse( | ||
(moduleDeps ++ compileModuleDeps).flatMap(_.transitiveModuleDeps).distinct | ||
)(m => T.task { m.compileClasspath() ++ Agg(m.compile().classes) })() | ||
.flatten | ||
T.traverse(transitiveModuleCompileModuleDeps)(m => | ||
T.task { m.localCompileClasspath() ++ Agg(m.compile().classes) } | ||
)().flatten | ||
} | ||
|
||
/** | ||
|
@@ -232,9 +234,7 @@ trait JavaModule | |
// Keep in sync with [[transitiveCompileClasspath]] | ||
@internal | ||
def bspTransitiveCompileClasspath: T[Agg[UnresolvedPath]] = T { | ||
T.traverse( | ||
(moduleDeps ++ compileModuleDeps).flatMap(_.transitiveModuleDeps).distinct | ||
)(m => | ||
T.traverse(transitiveModuleCompileModuleDeps)(m => | ||
T.task { | ||
m.bspCompileClasspath() ++ Agg(m.bspCompileClassesPath()) | ||
} | ||
|
@@ -355,11 +355,11 @@ trait JavaModule | |
} | ||
|
||
/** | ||
* The output classfiles/resources from this module, excluding upstream | ||
* modules and third-party dependencies | ||
* The *output* classfiles/resources from this module, used for execution, | ||
* excluding upstream modules and third-party dependencies | ||
*/ | ||
def localClasspath: T[Seq[PathRef]] = T { | ||
compileResources() ++ resources() ++ Agg(compile().classes) | ||
localCompileClasspath().toSeq ++ resources() ++ Agg(compile().classes) | ||
} | ||
|
||
/** | ||
|
@@ -368,9 +368,8 @@ trait JavaModule | |
*/ | ||
@internal | ||
def bspLocalClasspath: T[Agg[UnresolvedPath]] = T { | ||
(compileResources() ++ resources()).map(p => UnresolvedPath.ResolvedPath(p.path)) ++ Agg( | ||
bspCompileClassesPath() | ||
) | ||
(compileResources() ++ resources()).map(p => UnresolvedPath.ResolvedPath(p.path)) ++ | ||
Agg(bspCompileClassesPath()) | ||
} | ||
|
||
/** | ||
|
@@ -379,53 +378,51 @@ trait JavaModule | |
*/ | ||
// Keep in sync with [[bspCompileClasspath]] | ||
def compileClasspath: T[Agg[PathRef]] = T { | ||
transitiveCompileClasspath() ++ | ||
compileResources() ++ | ||
unmanagedClasspath() ++ | ||
resolvedIvyDeps() | ||
resolvedIvyDeps() ++ transitiveCompileClasspath() ++ localCompileClasspath() | ||
} | ||
|
||
/** | ||
* The *input* classfiles/resources from this module, used during compilation, | ||
* excluding upstream modules and third-party dependencies | ||
*/ | ||
def localCompileClasspath: T[Agg[PathRef]] = T { | ||
compileResources() ++ unmanagedClasspath() | ||
} | ||
|
||
/** Same as [[compileClasspath]], but does not trigger compilation targets, if possible. */ | ||
// Keep in sync with [[compileClasspath]] | ||
@internal | ||
def bspCompileClasspath: T[Agg[UnresolvedPath]] = T { | ||
bspTransitiveCompileClasspath() ++ | ||
(compileResources() ++ unmanagedClasspath() ++ resolvedIvyDeps()) | ||
(localCompileClasspath() ++ resolvedIvyDeps()) | ||
.map(p => UnresolvedPath.ResolvedPath(p.path)) | ||
} | ||
|
||
/** | ||
* Resolved dependencies based on [[transitiveIvyDeps]] and [[transitiveCompileIvyDeps]]. | ||
*/ | ||
def resolvedIvyDeps: T[Agg[PathRef]] = T { | ||
resolveDeps(T.task { | ||
transitiveCompileIvyDeps() ++ transitiveIvyDeps() | ||
})() | ||
resolveDeps(T.task { transitiveCompileIvyDeps() ++ transitiveIvyDeps() })() | ||
} | ||
|
||
/** | ||
* All upstream classfiles and resources necessary to build and executable | ||
* assembly, but without this module's contribution | ||
*/ | ||
def upstreamAssemblyClasspath: T[Agg[PathRef]] = T { | ||
transitiveLocalClasspath() ++ | ||
unmanagedClasspath() ++ | ||
resolvedRunIvyDeps() | ||
resolvedRunIvyDeps() ++ transitiveLocalClasspath() | ||
} | ||
|
||
def resolvedRunIvyDeps: T[Agg[PathRef]] = T { | ||
resolveDeps(T.task { | ||
runIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() | ||
})() | ||
resolveDeps(T.task { runIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() })() | ||
} | ||
|
||
/** | ||
* All classfiles and resources from upstream modules and dependencies | ||
* necessary to run this module's code after compilation | ||
*/ | ||
def runClasspath: T[Seq[PathRef]] = T { | ||
localClasspath() ++ | ||
upstreamAssemblyClasspath() | ||
resolvedRunIvyDeps().toSeq ++ transitiveLocalClasspath() ++ localClasspath() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We remove |
||
} | ||
|
||
/** | ||
|
@@ -470,10 +467,7 @@ trait JavaModule | |
* without those from upstream modules and dependencies | ||
*/ | ||
def jar: T[PathRef] = T { | ||
Jvm.createJar( | ||
localClasspath().map(_.path).filter(os.exists), | ||
manifest() | ||
) | ||
Jvm.createJar(localClasspath().map(_.path).filter(os.exists), manifest()) | ||
} | ||
|
||
/** | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change adds
unmanagedClasspath
tolocalClasspath
. This is probably the right thing to do, since it means it'll probably be aggregated from upstream modules intoupstreamAssemblyClasspath
, where it wouldn't before