-
Notifications
You must be signed in to change notification settings - Fork 54
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
Pact file output folders differ between SBT and tests for sub-projects #212
Comments
As a side note, when running tests in a sub-project the files are already written to the correct place (sub-project EDIT: actually, when I run the tests inside of intelliJ they seem to write to the root project |
I guess I'm less concerned about the default path, as long as it is consistent for both tests and SBT tasks. To clarify I am currently seeing the following behavior:
So it seems like the current oddball is the output location of sub-project tests. Strangely, when I debug the code, |
Oddly enough, this works: val file1 = new File("target/pacts")
println(file1.getAbsolutePath)
val file2 = new File(file1.getAbsolutePath + "/" + UUID.randomUUID())
file2.createNewFile()
println(file2.getAbsolutePath) I think updating scala-pact/scalapact-scalatest/src/main/scala/com/itv/scalapact/ScalaPactContractWriter.scala Line 35 in c4554a4
To use an absolute path instead of a relative path will fix the issue. |
For now I can use this workaround with implicit override val options: ScalaPactOptions = ScalaPactOptions(
writePactFiles = true,
outputPath = new File("target/pacts").getAbsolutePath
) Will open a PR for this tomorrow. |
Currently
ScalaPactEnv
setsoutputPath
toNone
by default:scala-pact/sbt-scalapact/src/main/scala/com/itv/scalapact/plugin/ScalaPactPlugin.scala
Line 155 in da2173a
In various places, a default value of
"target/pacts"
is then assigned. For example:scala-pact/scalapact-shared/src/main/scala/com/itv/scalapact/shared/ScalaPactSettings.scala
Line 25 in 7e1ef12
This results in the project root
target/pacts
folder being used by default, even for sub-projects. This means by default, pact commands will fail on sub-projects. I would suggest instead, we use a default of(target.value / "pacts").getPath
as provided by SBT, for example:This way the default target path will work on sub-projects by default. This means we should probably also update the logic so that other places in the code will expect the
outputPath
to always be defined and used as a fallback toProperties.envOrElse("pact.rootDir")
so that defining the system override will still take precedence.The text was updated successfully, but these errors were encountered: