1
1
import scala .util .matching .Regex .Match
2
2
3
3
4
- scalacOptions in (Compile , doc) ++ =
4
+ scalacOptions in (Compile , doc) : =
5
5
Seq (
6
+ " -encoding" , " UTF-8" ,
6
7
" -sourcepath" , baseDirectory.value.getAbsolutePath,
7
8
" -doc-source-url" , s " https://github.com/dwhjames/aws-wrap/tree/v ${version.value}€{FILE_PATH}.scala " )
8
9
@@ -11,10 +12,17 @@ autoAPIMappings := true
11
12
12
13
apiURL := Some (url(" https://dwhjames.github.io/aws-wrap/api/current/" ))
13
14
14
- apiMappings += {
15
+ apiMappings ++= {
16
+ val builder = Map .newBuilder[sbt.File , sbt.URL ]
15
17
val jarFiles = (managedClasspath in Compile ).value.files
16
- val datomicJarFile = jarFiles.find(file => file.toString.contains(" com.amazonaws/aws-java-sdk" )).get
17
- (datomicJarFile -> url(" http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/" ))
18
+ jarFiles.filter(file => file.toString.contains(" com.amazonaws/aws-java-sdk" )).foreach { awsJarFile =>
19
+ builder += awsJarFile -> url(" http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/" )
20
+ }
21
+ val bootPath = System .getProperty(" sun.boot.library.path" )
22
+ if (bootPath ne null ) {
23
+ builder += file(bootPath + " /rt.jar" ) -> url(" http://docs.oracle.com/javase/6/docs/api/" )
24
+ }
25
+ builder.result()
18
26
}
19
27
20
28
lazy val transformJavaDocLinksTask = taskKey[Unit ](
@@ -26,17 +34,24 @@ transformJavaDocLinksTask := {
26
34
log.info(" Transforming JavaDoc links" )
27
35
val t = (target in (Compile , doc)).value
28
36
(t ** " *.html" ).get.filter(hasJavadocApiLink).foreach { f =>
29
- log.info(" Transforming " + f)
30
- val newContent = javadocApiLink.replaceAllIn(IO .read(f), transformJavaDocLinks)
31
- IO .write(f, newContent)
37
+ log.debug(" Transforming " + f)
38
+ val content1 = javadocApiLink.replaceAllIn(IO .read(f), transformJavaDocLinks)
39
+ val content2 = awsJavadocApiLink.replaceAllIn(content1, transformJavaDocLinks)
40
+ IO .write(f, content2)
32
41
}
33
42
}
34
43
35
44
val transformJavaDocLinks : Match => String = m =>
36
45
" href=\" " + m.group(1 ) + " ?" + m.group(2 ).replace(" ." , " /" ) + " .html"
37
46
38
- val javadocApiLink = """ href=\"(http://docs\.aws\.amazon\. com/AWSJavaSDK/latest/javadoc /index\.html)#([^"]*)""" .r
47
+ val javadocApiLink = """ href=\"(http://docs\.oracle\. com/javase/6/docs/api /index\.html)#([^"]*)""" .r
39
48
40
- def hasJavadocApiLink (f : File ): Boolean = (javadocApiLink findFirstIn IO .read(f)).nonEmpty
49
+ val awsJavadocApiLink = """ href=\"(http://docs\.aws\.amazon\.com/AWSJavaSDK/latest/javadoc/index\.html)#([^"]*)""" .r
50
+
51
+ def hasJavadocApiLink (f : File ): Boolean = {
52
+ val content = IO .read(f)
53
+ (javadocApiLink findFirstIn content).nonEmpty ||
54
+ (awsJavadocApiLink findFirstIn content).nonEmpty
55
+ }
41
56
42
57
transformJavaDocLinksTask <<= transformJavaDocLinksTask triggeredBy (doc in Compile )
0 commit comments