|
| 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