diff options
author | Olivier Mélois <baccata64@gmail.com> | 2018-04-18 22:36:00 +0100 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-04-18 14:36:00 -0700 |
commit | 7898368fe809779e73ef1cd909f1b2e5de84e6c1 (patch) | |
tree | 1ebe94dd2066fdb7db07ea8d3fd486d9775138ec /main/test/resources/examples | |
parent | 5314da0e2dea8d61400241d6c9899ea9077fff8d (diff) | |
download | mill-7898368fe809779e73ef1cd909f1b2e5de84e6c1.tar.gz mill-7898368fe809779e73ef1cd909f1b2e5de84e6c1.tar.bz2 mill-7898368fe809779e73ef1cd909f1b2e5de84e6c1.zip |
Make builds able to depend on external projects (#291)
* Make builds able to depend on external projects
Builds are now able to load external projects and depend on them
as if they were local submodules.
`import $file.external.path.build`
* Disambiguate "dest" for foreign modules.
* Calling modules loaded from external directories "Foreign" to avoid
conflicting with the already existing concept of "ExternalModule".
* Amended the way `dest` is computed for foreign modules
* Added tests to check that the source paths and dest are as expected
* Added a test to show that local modules do not conflict with foreign
modules when they are named the same
* WIP windows build fail
* Added bootstrapping step in CYGWIN CI job
* * Revert externalOutPath deletion
* Add documentation for foreign-modules
* reverting appveyor changes
* Disabling Foreign modules tests against Java9
See https://github.com/lihaoyi/mill/issues/302
Diffstat (limited to 'main/test/resources/examples')
6 files changed, 156 insertions, 0 deletions
diff --git a/main/test/resources/examples/foreign/conflict/build.sc b/main/test/resources/examples/foreign/conflict/build.sc new file mode 100644 index 00000000..d6c08b81 --- /dev/null +++ b/main/test/resources/examples/foreign/conflict/build.sc @@ -0,0 +1,24 @@ +import $file.inner.{build => innerBuild} +import mill._ +import ammonite.ops._ + +// In this build, we have a local module targeting +// the 'inner sub-directory, and an imported foreign +// module in that same directory. Their sourcePaths +// should be the same, but their dest paths should +// be different to avoid both modules over-writing +// each other's caches . + +def checkPaths : T[Unit] = T { + if (innerBuild.millSourcePath != inner.millSourcePath) + throw new Exception("Source paths should be the same") +} + +def checkDests : T[Unit] = T { + if (innerBuild.selfDest == inner.selfDest) + throw new Exception("Dest paths should be different") +} + +object inner extends mill.Module { + def selfDest = T { T.ctx().dest / up / up } +} diff --git a/main/test/resources/examples/foreign/conflict/inner/build.sc b/main/test/resources/examples/foreign/conflict/inner/build.sc new file mode 100644 index 00000000..729f4f3d --- /dev/null +++ b/main/test/resources/examples/foreign/conflict/inner/build.sc @@ -0,0 +1,4 @@ +import mill._ +import ammonite.ops._ + +def selfDest = T { T.ctx().dest / up / up } diff --git a/main/test/resources/examples/foreign/outer/build.sc b/main/test/resources/examples/foreign/outer/build.sc new file mode 100644 index 00000000..b53cca70 --- /dev/null +++ b/main/test/resources/examples/foreign/outer/build.sc @@ -0,0 +1,16 @@ +import $file.inner.build +import mill._ +import ammonite.ops._ + +trait PathAware extends mill.Module { + def selfPath = T { millSourcePath } +} + +trait DestAware extends mill.Module { + def selfDest = T { T.ctx().dest / up / up } +} + +object sub extends PathAware with DestAware { + object sub extends PathAware with DestAware +} + diff --git a/main/test/resources/examples/foreign/outer/inner/build.sc b/main/test/resources/examples/foreign/outer/inner/build.sc new file mode 100644 index 00000000..2d978292 --- /dev/null +++ b/main/test/resources/examples/foreign/outer/inner/build.sc @@ -0,0 +1,15 @@ +import mill._ +import ammonite.ops._ + +trait PathAware extends mill.Module { + def selfPath = T { millSourcePath } +} + +trait DestAware extends mill.Module { + def selfDest = T { T.ctx().dest / up / up } +} + +object sub extends PathAware with DestAware { + object sub extends PathAware with DestAware +} + diff --git a/main/test/resources/examples/foreign/project/build.sc b/main/test/resources/examples/foreign/project/build.sc new file mode 100644 index 00000000..80c2af9b --- /dev/null +++ b/main/test/resources/examples/foreign/project/build.sc @@ -0,0 +1,82 @@ +import $file.^.outer.build +import $file.inner.build + +import ammonite.ops._ +import mill._ + +def assertPaths(p1 : Path, p2 : Path) : Unit = if (p1 != p2) throw new Exception( + s"Paths were not equal : \n- $p1 \n- $p2" +) + +object sub extends PathAware with DestAware { + + object sub extends PathAware with DestAware + + object sub2 extends ^.outer.build.PathAware with ^.outer.build.DestAware + +} + +def checkProjectPaths = T { + val thisPath : Path = millSourcePath + assert(thisPath.last == "project") + assertPaths(sub.selfPath(), thisPath / 'sub) + assertPaths(sub.sub.selfPath(), thisPath / 'sub / 'sub) + assertPaths(sub.sub2.selfPath(), thisPath / 'sub / 'sub2) +} + +def checkInnerPaths = T { + val thisPath : Path = millSourcePath + assertPaths(inner.build.millSourcePath, thisPath / 'inner ) + assertPaths(inner.build.sub.selfPath(), thisPath / 'inner / 'sub) + assertPaths(inner.build.sub.sub.selfPath(), thisPath / 'inner / 'sub / 'sub) +} + +def checkOuterPaths = T { + val thisPath : Path = millSourcePath + assertPaths(^.outer.build.millSourcePath, thisPath / up / 'outer ) + assertPaths(^.outer.build.sub.selfPath(), thisPath / up / 'outer / 'sub) + assertPaths(^.outer.build.sub.sub.selfPath(), thisPath / up / 'outer / 'sub / 'sub) +} + +def checkOuterInnerPaths = T { + val thisPath : Path = millSourcePath + assertPaths(^.outer.inner.build.millSourcePath, thisPath / up / 'outer / 'inner ) + assertPaths(^.outer.inner.build.sub.selfPath(), thisPath / up / 'outer / 'inner /'sub) + assertPaths(^.outer.inner.build.sub.sub.selfPath(), thisPath / up / 'outer / 'inner / 'sub / 'sub) +} + +def checkProjectDests = T { + val outPath : Path = millSourcePath / 'out + assertPaths(sub.selfDest(), outPath / 'sub) + assertPaths(sub.sub.selfDest(), outPath / 'sub / 'sub) + assertPaths(sub.sub2.selfDest(), outPath / 'sub / 'sub2) +} + +def checkInnerDests = T { + val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + assertPaths(inner.build.sub.selfDest(), foreignOut / 'inner / 'sub) + assertPaths(inner.build.sub.sub.selfDest(), foreignOut / 'inner / 'sub / 'sub) +} + +def checkOuterDests = T { + val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + assertPaths(^.outer.build.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'sub ) + assertPaths(^.outer.build.sub.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'sub / 'sub) +} + +def checkOuterInnerDests = T { + val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + assertPaths(^.outer.inner.build.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'inner / 'sub) + assertPaths(^.outer.inner.build.sub.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'inner / 'sub / 'sub) +} + + +trait PathAware extends mill.Module { + + def selfPath = T { millSourcePath } +} + +trait DestAware extends mill.Module { + def selfDest = T { T.ctx().dest / up / up } +} + diff --git a/main/test/resources/examples/foreign/project/inner/build.sc b/main/test/resources/examples/foreign/project/inner/build.sc new file mode 100644 index 00000000..2d978292 --- /dev/null +++ b/main/test/resources/examples/foreign/project/inner/build.sc @@ -0,0 +1,15 @@ +import mill._ +import ammonite.ops._ + +trait PathAware extends mill.Module { + def selfPath = T { millSourcePath } +} + +trait DestAware extends mill.Module { + def selfDest = T { T.ctx().dest / up / up } +} + +object sub extends PathAware with DestAware { + object sub extends PathAware with DestAware +} + |