Project

Profile

Help

Revision acdcff21

Added by Norman Tovey-Walsh 8 months ago

Fix JavaDoc HTML and XML generation

View differences:

build-doc.gradle
22 22

  
23 23
// ============================================================
24 24

  
25
task filter_sources_for_javadoc(
26
  type: Copy,
27
  description: "Copy the Java source files for making JavaDoc (excludes some classes)"
28
) {
29
  inputs.files fileTree(dir: "${projectDir}/src/main/java")
30
  outputs.files fileTree(dir: "${buildDir}/javadoc_src")
31

  
32
  into "${buildDir}/javadoc_src"
33
  from ("${projectDir}/src/main/java") {
34
    include "net/**"
35
    include "com/**"
36
    include "javax/**"
37
    exclude "com/saxonica/testdriver/**"
38
    exclude "net/sf/saxon/testdriver/**"
39
    exclude "**/dotnet/**"
40
    exclude "**/DotNetVerifier.java"
41
  }
42
}
43

  
25 44
task product_javadoc(
26
  type: Javadoc,
27
  dependsOn: ["eej_sources"],
28
  description: "Generate Javadoc HTML files"
29
) {
30
  inputs.files fileTree(dir: "${buildDir}/src/eej")
45
  type: Exec,
46
  dependsOn: ["filter_sources_for_javadoc"],
47
  description: "Generate Javadoc files"
48
) {
49
  // If you can't do something the easy way, do it the hard way.
50
  // The Gradle JavaDoc plugin should be able to do this, but it doesn't
51
  // do the right thing and it's completely unclear why. (The symptom that
52
  // forced me to resort to this approach was including every file twice.)
53
  inputs.files fileTree(dir: "${buildDir}/javadoc_src")
31 54
  outputs.files fileTree(dir: "${buildDir}/javadoc")
32 55

  
33
  classpath = configurations.documentation
34
  source = new File("${buildDir}/src/eej")
35
  destinationDir= new File("${buildDir}/javadoc")
36
  // noindex="false" notree="false"
37
  // maxmemory="512M" source="1.8"
38
  // -includeNamespace
39
  options.addStringOption("Xdoclint:none", "-quiet")
40
  include "net/**"
41
  include "com/**"
42
  include "javax/**"
43
  exclude "com/saxonica/testdriver/**"
44
  exclude "net/sf/saxon/testdriver/**"
45
  exclude "**/dotnet/**"
46
  exclude "**/DotNetVerifier.java"
47
  exclude "**/*.html"
56
  def cp = ""
57
  configurations.documentation.resolve().each { path ->
58
    cp = cp + System.getProperty("path.separator") + path
59
  }
60

  
61
  // Any directory that contains a java file is assumed to be a
62
  // package...because that's the way packages work in Java.
63
  // Frustratingly, we have to base this on the main source directory,
64
  // not the one created by filter_sources_for_javadoc because this
65
  // calculation runs during the Gradle configuration phase when
66
  // that directory might not yet exist. FIXME: do this better
67
  def packages = [:]
68
  fileTree(dir: "${projectDir}/src/main/java",
69
           include: ["net/**", "com/**", "javax/**"],
70
           exclude: ["com/saxonica/testdriver/**",
71
                     "net/sf/saxon/testdriver/**",
72
                     "**/dotnet/**"]).each { pkg ->
73
    def fn = pkg.toString()
74
    fn = fn.substring("{$projectDir}/src/main/java".length()-1)
75
    def pos = fn.lastIndexOf("/")
76
    fn = fn.substring(0, pos).replaceAll("/", ".")
77
    packages[fn] = 1
78
  }
79

  
80
  def command = ["javadoc",
81
                 "-sourcepath", "${buildDir}/javadoc_src",
82
                 "-Xdoclint:none",
83
                 "-d", "${buildDir}/javadoc",
84
                 "-package",
85
                 "-classpath", cp,
86
                 "-bottom", "Copyright (c) 2004-2021 Saxonica Limited.",
87
                 "-doctitle", "Saxon ${saxonVersion} Java API Documentation",
88
                 "-group", "s9api Interface", "net.sf.saxon.s9api",
89
                 "-group", "Other Interfaces", "net.sf.saxon:net.sf.saxon.lib:net.sf.saxon.om:net.sf.saxon.query:net.sf.saxon.sxpath:net.sf.saxon.value:net.sf.saxon.type:net.sf.saxon.xpath:net.sf.saxon.xqj",
90
                 "-group", "External Interfaces", "javax.xml.xquery",
91
                 "-source", "1.8"] + packages.keySet()
92

  
93
  commandLine command
94

  
95
  doFirst {
96
      mkdir "${buildDir}/javadoc"
97
    }
48 98
}
49 99

  
50 100
task product_jeljavadoc(
51
  type: Javadoc,
52
  dependsOn: ["eej_sources"],
101
  type: Exec,
102
  dependsOn: ["filter_sources_for_javadoc"],
53 103
  description: "Generate Javadoc XML files"
54 104
) {
55
  inputs.files fileTree(dir: "${buildDir}/src/eej")
105
  // If you can't do something the easy way, do it the hard way.
106
  // The Gradle JavaDoc plugin should be able to do this, but it doesn't
107
  // do the right thing with package descriptions and it's completely
108
  // unclear why.
109
  inputs.files fileTree(dir: "${buildDir}/javadoc_src")
56 110
  inputs.file "${projectDir}/lib/jeldoc.jar"
57 111
  outputs.files fileTree(dir: "${buildDir}/jeljavadoc")
58 112

  
59
  classpath = configurations.documentation
60
  source = new File("${buildDir}/src/eej")
61
  destinationDir= new File("${buildDir}/jeljavadoc")
62
  options.doclet = "com.jeldoclet.JELDoclet"
63
  options.docletpath = configurations.jeldoclet.files.asType(List)
64
  // noindex="false" notree="false"
65
  // maxmemory="512M" source="1.8"
66
  options.addStringOption("access", "package")
67
  options.addStringOption("filename", "jeldoclet-out.xml")
68
  options.addStringOption("outputEncoding", "utf-8")
69
  // -includeNamespace
70
  include "net/**"
71
  include "com/**"
72
  include "javax/**"
73
  exclude "com/saxonica/testdriver/**"
74
  exclude "net/sf/saxon/testdriver/**"
75
  exclude "**/dotnet/**"
76
  exclude "**/DotNetVerifier.java"
77
  exclude "**/*.html"
113
  def cp = ""
114
  configurations.documentation.resolve().each { path ->
115
    cp = cp + System.getProperty("path.separator") + path
116
  }
117

  
118
  // Any directory that contains a java file is assumed to be a
119
  // package...because that's the way packages work in Java.
120
  // Frustratingly, we have to base this on the main source directory,
121
  // not the one created by filter_sources_for_javadoc because this
122
  // calculation runs during the Gradle configuration phase when
123
  // that directory might not yet exist. FIXME: do this better
124
  def packages = [:]
125
  fileTree(dir: "${projectDir}/src/main/java",
126
           include: ["net/**", "com/**", "javax/**"],
127
           exclude: ["com/saxonica/testdriver/**",
128
                     "net/sf/saxon/testdriver/**",
129
                     "**/dotnet/**"]).each { pkg ->
130
    def fn = pkg.toString()
131
    fn = fn.substring("{$projectDir}/src/main/java".length()-1)
132
    def pos = fn.lastIndexOf("/")
133
    fn = fn.substring(0, pos).replaceAll("/", ".")
134
    packages[fn] = 1
135
  }
136

  
137
  def command = ["javadoc",
138
                 "-sourcepath", "${buildDir}/javadoc_src",
139
                 "-d", "${buildDir}/jeljavadoc",
140
                 "-package",
141
                 "-filename", "jeldoclet-out.xml",
142
                 "-includeNamespace",
143
                 "-outputEncoding", "utf-8",
144
                 "-classpath", cp,
145
                 "-doclet", "com.jeldoclet.JELDoclet",
146
                 "-docletpath", cp,
147
                 "-source", "1.8"] + packages.keySet()
148

  
149
  commandLine command
150

  
151
  doFirst {
152
      mkdir "${buildDir}/jeljavadoc"
153
    }
78 154
}
79 155

  
80 156
task product_xsljavadoc(
build.gradle
114 114
  )
115 115
  documentation (
116 116
    [group: "com.saxonica", name: "Saxon-EE", version: "10.3"],
117
    [group: "org.ccil.cowan.tagsoup", name: "tagsoup", version: "1.2.1"],
118
    files("lib/jeldoc.jar"),
117 119
    files(saxonLicenseDir)
118 120
  )
119 121
  jeldoclet (

Also available in: Unified diff