Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 741ea6a

Browse files
committed
Added api sbt build utility.
1 parent 87a431b commit 741ea6a

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

build.sbt

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name := "chatoverflow-api"
2-
// The source generator creates a java class with the current version info
3-
lazy val sourceGenerator = TaskKey[Unit]("sourceGenerator")
2+
lazy val apiVersionGenerator = TaskKey[Unit]("apiVersionGenerator")
3+
lazy val requirementsGenerator = TaskKey[Unit]("requirementsGenerator")
44

55
// Convention: majorVersion++ on api signature update (else: minorVersion ++)
66
val majorVersion = 3
@@ -14,23 +14,16 @@ version := s"$majorVersion.$minorVersion"
1414
// ---------------------------------------------------------------------------------------------------------------------
1515

1616

17-
sourceGenerator := {
18-
val file = new File(sourceDirectory.value, "main/java/org/codeoverflow/chatoverflow/api/APIVersion.java")
19-
IO.write(file,
20-
"""package org.codeoverflow.chatoverflow.api;
21-
|
22-
|/**
23-
| * THIS CLASS IS GENERATED WHILE COMPILING. DO CHANGE THE VERSION NUMBERS IN THE APIS BUILD.SBT!
24-
| */
25-
|public class APIVersion {
26-
| public static final int MAJOR_VERSION = %d;
27-
| public static final int MINOR_VERSION = %d;
28-
|}
29-
|""".stripMargin.format(majorVersion, minorVersion))
30-
}
17+
apiVersionGenerator := APIUtility(streams.value.log)
18+
.generateAPIVersionFile(sourceDirectory.value, majorVersion, minorVersion)
19+
20+
requirementsGenerator := APIUtility(streams.value.log).generatedRequirements()
21+
3122

3223
// Update the compile process to generate the api version java class
3324
compile in Compile := {
34-
sourceGenerator.value
25+
apiVersionGenerator.value
26+
(compile in Compile).value
27+
requirementsGenerator.value
3528
(compile in Compile).value
3629
}

0 commit comments

Comments
 (0)