@@ -2,12 +2,13 @@ package com.itv.scalapact
2
2
3
3
import java .io .{File , PrintWriter }
4
4
import java .nio .charset .StandardCharsets
5
-
6
5
import com .itv .scalapact .model .ScalaPactMatchingRule ._
7
6
import com .itv .scalapact .model .{ScalaPactDescriptionFinal , ScalaPactInteractionFinal , ScalaPactMatchingRule }
8
7
import com .itv .scalapact .shared ._
9
8
import com .itv .scalapact .shared .json .IPactWriter
10
9
10
+ import java .nio .file .Paths
11
+
11
12
private [scalapact] object ScalaPactContractWriter {
12
13
def writePactContracts (outputPath : String )(implicit pactWriter : IPactWriter ): ScalaPactDescriptionFinal => Unit =
13
14
pactDescription => {
@@ -29,18 +30,21 @@ private[scalapact] object ScalaPactContractWriter {
29
30
.map(" %02x" .format(_))
30
31
.mkString
31
32
32
- val relativePath = outputPath + " /" + simplifyName(pactDescription.consumer) + " _" + simplifyName(
33
- pactDescription.provider
34
- ) + " _" + sha1 + " _tmp.json"
35
- val file = new File (relativePath)
33
+ val path = Paths .get(
34
+ // #212: ensure a consistent path is used between projects and sub-projects
35
+ dirFile.getAbsolutePath,
36
+ simplifyName(pactDescription.consumer) + " _" +
37
+ simplifyName(pactDescription.provider) + " _" + sha1 + " _tmp.json"
38
+ )
39
+ val file = new File (path.toUri)
36
40
37
41
if (file.exists()) {
38
42
file.delete()
39
43
}
40
44
41
45
file.createNewFile()
42
46
43
- new PrintWriter (relativePath ) {
47
+ new PrintWriter (file ) {
44
48
write(producePactJson(pactDescription))
45
49
close()
46
50
}
0 commit comments