1
1
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 " )
4
4
5
5
// Convention: majorVersion++ on api signature update (else: minorVersion ++)
6
6
val majorVersion = 3
@@ -14,23 +14,16 @@ version := s"$majorVersion.$minorVersion"
14
14
// ---------------------------------------------------------------------------------------------------------------------
15
15
16
16
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
+
31
22
32
23
// Update the compile process to generate the api version java class
33
24
compile in Compile := {
34
- sourceGenerator.value
25
+ apiVersionGenerator.value
26
+ (compile in Compile ).value
27
+ requirementsGenerator.value
35
28
(compile in Compile ).value
36
29
}
0 commit comments