Skip to content

Commit 67bbbf0

Browse files
feat: JavaDoc 11/13 support
Salvaged the project from https://github.com/MarkusBernhardt/xml-doclet with PR MarkusBernhardt#17 and sanitized the build script and sources. Supports JavaDoc 11 up to JavaDoc 13. - Gradle Build, drop Maven - Format and Check sources - Publish to GitHub packages
1 parent 6bb0cc1 commit 67bbbf0

File tree

88 files changed

+7027
-3929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+7027
-3929
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
/target
2+
/build
3+
/out
24
/.settings
35
/.classpath
46
/.project
7+
/.gradle
8+
/.idea
9+

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ unreleased
2323

2424
1.0.0
2525
-----
26-
* Initial release
26+
* Initial release

README.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,33 @@ Usage
1212
If you are using maven you can use this library by adding the following report to your pom.xml:
1313

1414
<project>
15-
...
16-
<plugin>
17-
<groupId>org.apache.maven.plugins</groupId>
18-
<artifactId>maven-javadoc-plugin</artifactId>
19-
<executions>
20-
<execution>
21-
<id>xml-doclet</id>
22-
<phase>prepare-package</phase>
23-
<goals>
24-
<goal>javadoc</goal>
25-
</goals>
26-
<configuration>
27-
<doclet>com.github.markusbernhardt.xmldoclet.XmlDoclet</doclet>
28-
<additionalparam>-d ${project.build.directory} -filename ${project.artifactId}-${project.version}-javadoc.xml</additionalparam>
29-
<useStandardDocletOptions>false</useStandardDocletOptions>
30-
<docletArtifact>
31-
<groupId>com.github.markusbernhardt</groupId>
32-
<artifactId>xml-doclet</artifactId>
33-
<version>1.0.5</version>
34-
</docletArtifact>
35-
</configuration>
36-
</execution>
37-
</executions>
38-
</plugin>
39-
...
15+
...
16+
<plugin>
17+
<groupId>org.apache.maven.plugins</groupId>
18+
<artifactId>maven-javadoc-plugin</artifactId>
19+
<executions>
20+
<execution>
21+
<id>xml-doclet</id>
22+
<phase>prepare-package</phase>
23+
<goals>
24+
<goal>javadoc</goal>
25+
</goals>
26+
<configuration>
27+
<doclet>com.github.markusbernhardt.xmldoclet.XmlDoclet</doclet>
28+
<additionalparam>-d ${project.build.directory} -filename ${project.artifactId}-${project.version}-javadoc.xml</additionalparam>
29+
<useStandardDocletOptions>false</useStandardDocletOptions>
30+
<docletArtifact>
31+
<groupId>com.github.markusbernhardt</groupId>
32+
<artifactId>xml-doclet</artifactId>
33+
<version>1.0.5</version>
34+
</docletArtifact>
35+
</configuration>
36+
</execution>
37+
</executions>
38+
</plugin>
39+
...
4040
</project>
41-
41+
4242
Use 'mvn package' with maven.
4343
If you are not using maven, you can use the [jar-with-dependencies](http://search.maven.org/remotecontent?filepath=com/github/markusbernhardt/xml-doclet/1.0.5/xml-doclet-1.0.5-jar-with-dependencies.jar), which contains all required libraries.
4444

@@ -50,10 +50,10 @@ A Makefile target to generate xml from both the production and test code:
5050

5151

5252
javadoc:
53-
mkdir -p target/production target/test
54-
CLASSPATH=$$(echo $$(find ~/.m2/repository/ -name '*.jar'|grep -v jdk14 )|sed 's/ /:/g')\
53+
mkdir -p target/production target/test
54+
CLASSPATH=$$(echo $$(find ~/.m2/repository/ -name '*.jar'|grep -v jdk14 )|sed 's/ /:/g')\
5555
javadoc -doclet com.github.markusbernhardt.xmldoclet.XmlDoclet -sourcepath src/main/java -d target/production org.rulez.demokracia.PDEngine
56-
CLASSPATH=$$(echo $$(find ~/.m2/repository/ -name '*.jar'|grep -v jdk14 )|sed 's/ /:/g')\
56+
CLASSPATH=$$(echo $$(find ~/.m2/repository/ -name '*.jar'|grep -v jdk14 )|sed 's/ /:/g')\
5757
javadoc -doclet com.github.markusbernhardt.xmldoclet.XmlDoclet -sourcepath src/test/java -d target/test org.rulez.demokracia.PDEngine
5858

5959
If you want more control and feel adventurous you could you use this [jar](http://search.maven.org/remotecontent?filepath=com/github/markusbernhardt/xml-doclet/1.0.5/xml-doclet-1.0.5.jar) and provide all required libraries from this [list](DEPENDENCIES.md) on your own.
@@ -63,13 +63,12 @@ Options
6363

6464
-d <directory> Destination directory for output file.
6565
Default: .
66-
66+
6767
-docencoding <encoding> Encoding of the output file.
6868
Default: UTF8
69-
69+
7070
-dryrun Parse javadoc, but don't write output file.
7171
Default: false
72-
72+
7373
-filename <filename> Name of the output file.
7474
Default: javadoc.xml
75-

build.gradle

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'signing'
5+
6+
id("com.github.gradlecommunity.jaxb2") version "3.1.0"
7+
8+
id "com.github.spotbugs" version "latest.release"
9+
id "com.diffplug.spotless" version "latest.release"
10+
id 'pmd'
11+
id 'checkstyle'
12+
}
13+
14+
repositories {
15+
mavenLocal()
16+
maven {
17+
url = uri('https://oss.sonatype.org/content/repositories/snapshots')
18+
}
19+
20+
maven {
21+
url = uri('https://repo.maven.apache.org/maven2/')
22+
}
23+
}
24+
25+
dependencies {
26+
api 'commons-cli:commons-cli:+'
27+
api 'org.slf4j:slf4j-api:+'
28+
api 'javax.xml.bind:jaxb-api:2.+'
29+
jaxb2 'org.glassfish.jaxb:jaxb-runtime:2.+'
30+
jaxb2 'javax.activation:javax.activation-api:1.2.0'
31+
testImplementation 'org.slf4j:slf4j-simple:+'
32+
testImplementation 'junit:junit:+'
33+
}
34+
35+
36+
def getVersion = { boolean considerSnapshot ->
37+
def major = 0
38+
def minor = 0
39+
def patch = 0
40+
def commit = ""
41+
def snapshot =""
42+
new ByteArrayOutputStream().withStream { os ->
43+
exec {
44+
workingDir "$projectDir"
45+
args = [
46+
"--no-pager"
47+
, "describe"
48+
, "--tags"
49+
, "--always"
50+
, "--dirty=-SNAPSHOT"
51+
]
52+
executable "git"
53+
standardOutput = os
54+
}
55+
def versionStr = os.toString().trim()
56+
def matcher = versionStr =~ /(\d*)\.(\d*)-(\d*)-([a-zA-Z\d]*)/
57+
matcher.find()
58+
59+
major = matcher[0][1]
60+
minor = matcher[0][2]
61+
patch = matcher[0][3]
62+
commit = matcher[0][4]
63+
64+
if (considerSnapshot && versionStr.endsWith("SNAPSHOT")) {
65+
minor++
66+
snapshot = "-SNAPSHOT"
67+
}
68+
}
69+
return "${major}.${minor}${snapshot}"
70+
}
71+
version = getVersion(true)
72+
group = 'com.github.markusbernhardt'
73+
description = 'XML Doclet'
74+
75+
76+
publish {
77+
dependsOn(check)
78+
}
79+
80+
publishing {
81+
publications {
82+
mavenJava(MavenPublication) {
83+
from components.java
84+
versionMapping {
85+
usage('java-api') {
86+
fromResolutionOf('runtimeClasspath')
87+
}
88+
usage('java-runtime') {
89+
fromResolutionResult()
90+
}
91+
}
92+
pom {
93+
name = 'XML Doclet'
94+
description = 'Doclet for writing XML file (instead of JavaDoc HTML)'
95+
url = 'https://github.com/manticore-projects/xml-doclet'
96+
licenses {
97+
license {
98+
name = 'The Apache Software License, Version 2.0'
99+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
100+
}
101+
}
102+
developers {
103+
developer {
104+
id = 'mbe'
105+
name = 'Markus Bernhardt'
106+
email = 'markus.bernhardt@me.comt'
107+
}
108+
developer {
109+
id = 'are'
110+
name = 'Andreas Reichel'
111+
email = 'andreas@manticore-projects.com'
112+
}
113+
developer {
114+
id = 'vha'
115+
name = 'Vojtěch Habarta'
116+
}
117+
}
118+
scm {
119+
connection = 'scm:git:https://github.com/manticore-projects/xml-doclet.git'
120+
developerConnection = 'scm:git:ssh://git@github.com:manticore-projects/xml-doclet.git'
121+
url = 'https://github.com/manticore-projects/xml-doclet.git'
122+
}
123+
}
124+
}
125+
}
126+
repositories {
127+
// maven {
128+
// name "ossrh"
129+
//
130+
// def releasesRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
131+
// def snapshotsRepoUrl= "https://oss.sonatype.org/service/local/staging/deploy/maven2"
132+
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
133+
// credentials(PasswordCredentials)
134+
// }
135+
maven {
136+
name = "GitHubPackages"
137+
138+
url = uri("https://maven.pkg.github.com/manticore-projects/jsqlparser")
139+
credentials(PasswordCredentials)
140+
}
141+
}
142+
}
143+
144+
signing {
145+
sign publishing.publications.mavenJava
146+
}
147+
148+
java {
149+
withSourcesJar()
150+
withJavadocJar()
151+
152+
sourceCompatibility(JavaVersion.VERSION_1_8)
153+
targetCompatibility(JavaVersion.VERSION_1_8)
154+
155+
// needed for XML-Doclet to work (since Doclet changed again with Java 13)
156+
toolchain {
157+
languageVersion.set(JavaLanguageVersion.of(11))
158+
}
159+
}
160+
161+
jaxb2 {
162+
xjc {
163+
'xmldoclet-classes' {
164+
basePackage = 'com.github.markusbernhardt.xmldoclet.xjc'
165+
schema = 'src/main/xjc/javadoc.xsd'
166+
encoding = 'UTF-8'
167+
generatedSourcesDir = "${project.buildDir}/generated/java"
168+
}
169+
}
170+
}
171+
172+
javadoc {
173+
if(JavaVersion.current().isJava9Compatible()) {
174+
options.addBooleanOption('html5', true)
175+
}
176+
options.addBooleanOption("Xdoclint:none", true)
177+
}
178+
179+
tasks.withType(JavaCompile) {
180+
options.encoding = 'UTF-8'
181+
}
182+
183+
tasks.withType(Javadoc) {
184+
options.encoding = 'UTF-8'
185+
}
186+
187+
188+
spotbugsMain {
189+
reports {
190+
html {
191+
enabled = true
192+
destination = file("build/reports/spotbugs/main/spotbugs.html")
193+
stylesheet = 'fancy-hist.xsl'
194+
}
195+
}
196+
}
197+
198+
spotbugs {
199+
// fail only on P1 and without the net.sf.jsqlparser.parser.*
200+
excludeFilter = file("config/spotbugs/spotBugsExcludeFilter.xml")
201+
202+
// do not run over the test, although we should do that eventually
203+
spotbugsTest.enabled = false
204+
}
205+
206+
pmd {
207+
consoleOutput = false
208+
//toolVersion = "6.46.0"
209+
210+
sourceSets = [sourceSets.main]
211+
212+
// clear the ruleset in order to use configured rules only
213+
ruleSets = []
214+
215+
//rulesMinimumPriority = 1
216+
ruleSetFiles = files("config/pmd/ruleset.xml")
217+
218+
pmdMain {
219+
excludes = [
220+
"build/generated/*"
221+
]
222+
}
223+
}
224+
225+
tasks.whenTaskAdded {task ->
226+
if(task.name.contains("compileJaxb2Java")) {
227+
task.enabled = false
228+
}
229+
}
230+
231+
checkstyle {
232+
sourceSets = [sourceSets.main, sourceSets.test]
233+
configFile =rootProject.file('config/checkstyle/checkstyle.xml')
234+
}
235+
236+
spotless {
237+
// optional: limit format enforcement to just the files changed by this feature branch
238+
ratchetFrom 'origin/master'
239+
240+
format 'misc', {
241+
// define the files to apply `misc` to
242+
target '*.rst', '*.md', '.gitignore'
243+
// define the steps to apply to those files
244+
trimTrailingWhitespace()
245+
indentWithSpaces(4) // or spaces. Takes an integer argument if you don't like 4
246+
endWithNewline()
247+
}
248+
java {
249+
indentWithSpaces(4)
250+
eclipse().configFile('config/formatter/eclipse-java-google-style.xml')
251+
}
252+
}
253+
254+
tasks.withType(Checkstyle) {
255+
reports {
256+
xml.required = false
257+
html.required = true
258+
}
259+
}

0 commit comments

Comments
 (0)