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

Fix JavaModule.artifactTypes #3719

Merged
merged 6 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object DocAnnotationsTests extends UtestIntegrationTestSuite {

assert(
globMatches(
"""core.ivyDepsTree(JavaModule.scala:893)
"""core.ivyDepsTree(JavaModule.scala:896)
| Command to print the transitive dependency tree to STDOUT.
|
| --inverse Invert the tree representation, so that the root is on the bottom val
Expand Down
5 changes: 4 additions & 1 deletion scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,10 @@ trait JavaModule
* Resolved dependencies based on [[transitiveIvyDeps]] and [[transitiveCompileIvyDeps]].
*/
def resolvedIvyDeps: T[Agg[PathRef]] = Task {
defaultResolver().resolveDeps(transitiveCompileIvyDeps() ++ transitiveIvyDeps())
defaultResolver().resolveDeps(
transitiveCompileIvyDeps() ++ transitiveIvyDeps(),
artifactTypes = Some(artifactTypes())
)
}

/**
Expand Down
Empty file.
29 changes: 29 additions & 0 deletions scalalib/test/src/mill/scalalib/ResolveDepsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import coursier.maven.MavenRepository
import mill.api.Result.{Failure, Success}
import mill.api.{PathRef, Result}
import mill.api.Loose.Agg
import mill.testkit.{UnitTester, TestBaseModule}
import utest._

object ResolveDepsTests extends TestSuite {
Expand All @@ -28,6 +29,21 @@ object ResolveDepsTests extends TestSuite {
assert(upickle.default.read[Dep](upickle.default.write(dep)) == dep)
}
}

object TestCase extends TestBaseModule {
object pomStuff extends JavaModule {
def ivyDeps = Agg(
// Dependency whose packaging is "pom", as it's meant to be used
// as a "parent dependency" by other dependencies, rather than be pulled
// as we do here. We do it anyway, to check that pulling the "pom" artifact
// type brings that dependency POM file in the class path. We need a dependency
// that has a "pom" packaging for that.
ivy"org.apache.hadoop:hadoop-yarn-server:3.4.0"
)
def artifactTypes = super.artifactTypes() + coursier.Type("pom")
}
}

val tests = Tests {
test("resolveValidDeps") {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3")
Expand Down Expand Up @@ -95,5 +111,18 @@ object ResolveDepsTests extends TestSuite {
val Failure(errMsg, _) = evalDeps(deps)
assert(errMsg.contains("fake"))
}

test("pomArtifactType") {
val sources = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "pomArtifactType"
UnitTester(TestCase, sourceRoot = sources).scoped { eval =>
val Right(compileResult) = eval(TestCase.pomStuff.compileClasspath)
val compileCp = compileResult.value.toSeq.map(_.path)
assert(compileCp.exists(_.lastOpt.contains("hadoop-yarn-server-3.4.0.pom")))

val Right(runResult) = eval(TestCase.pomStuff.runClasspath)
val runCp = runResult.value.toSeq.map(_.path)
assert(runCp.exists(_.lastOpt.contains("hadoop-yarn-server-3.4.0.pom")))
}
}
}
}
Loading