Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK 21 (WIP) - Close #3 #4

Merged
merged 8 commits into from
Jan 14, 2025
72 changes: 11 additions & 61 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repositories {
}

dependencies {
api 'commons-cli:commons-cli:+'
api 'commons-cli:commons-cli:1.9.0'
api 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'

// We need to export this as API explicitly and fix the Versions
Expand All @@ -71,47 +71,8 @@ dependencies {
xmlDoclet 'net.sf.saxon:Saxon-HE:12.5'
}

def getVersion = { boolean considerSnapshot ->
Integer major = 0
Integer minor = 0
Integer patch = null
Integer build = null
def commit = null
def snapshot = ""
new ByteArrayOutputStream().withStream { os ->
exec {
args = [
"--no-pager"
, "describe"
, "--tags"
, "--always"
, "--dirty=-SNAPSHOT"
]
executable "git"
standardOutput = os
}
def versionStr = os.toString().trim()
def pattern = /(?<major>\d*)\.(?<minor>\d*)(\.(?<patch>\d*))?(-(?<build>\d*)-(?<commit>[a-zA-Z\d]*))?/
def matcher = versionStr =~ pattern
if (matcher.find()) {
major = matcher.group('major') as Integer
minor = matcher.group('minor') as Integer
patch = matcher.group('patch') as Integer
build = matcher.group('build') as Integer
commit = matcher.group('commit')
}

if (considerSnapshot && ( versionStr.endsWith('SNAPSHOT') || build!=null) ) {
minor++
if (patch!=null) patch = 0
snapshot = "-SNAPSHOT"
}
}
return patch!=null
? "${major}.${minor}.${patch}${snapshot}"
: "${major}.${minor}${snapshot}"
}
version = getVersion(true)
tasks.register('customVersionTask', CustomVersionTask)
version = tasks.named('customVersionTask').get().getVersion(true)
group = 'com.manticore-projects.tools'
description = 'XML Doclet'

Expand Down Expand Up @@ -168,7 +129,7 @@ publishing {
}
repositories {
maven {
name "ossrh"
name = "ossrh"

def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl= "https://s01.oss.sonatype.org/content/repositories/snapshots/"
Expand All @@ -192,25 +153,15 @@ java {
withSourcesJar()
withJavadocJar()

sourceCompatibility(JavaVersion.VERSION_21)
targetCompatibility(JavaVersion.VERSION_21)
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
modularity.inferModulePath = true
}

compileJava {
doFirst {
options.compilerArgs += [
'--module-path', classpath.asPath,
'-Xmaxerrs', 1000
]
classpath = files()
}
}

jar {
manifest {
attributes('Main-Class': 'com.github.markusbernhardt.xmldoclet.XmlDoclet')
Expand Down Expand Up @@ -249,7 +200,7 @@ javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
options.addBooleanOption("Xdoclint:none", true)
options.addBooleanOption("Xdoclint:none", false)
}

tasks.named('sourcesJar') {
Expand Down Expand Up @@ -343,11 +294,11 @@ spotless {
target '*.rst', '*.md', '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces(4) // or spaces. Takes an integer argument if you don't like 4
leadingTabsToSpaces(4)
endWithNewline()
}
java {
indentWithSpaces(4)
leadingTabsToSpaces(4)
eclipse().configFile('config/formatter/eclipse-java-google-style.xml')
target 'src/**/*.java'
}
Expand Down Expand Up @@ -393,9 +344,8 @@ tasks.register('upload') {
}

tasks.register('gitChangelogTask', GitChangelogTask) {
fromRepo = file("$projectDir")
file = new File("${projectDir}/src/site/sphinx/changelog.md")
fromRef = "1.0"
fromRepo.set("$projectDir")
file.set(file("${projectDir}/src/site/sphinx/changelog.md"))
}

tasks.register('printModulePath') {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/CustomVersionTask.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import org.gradle.process.ExecOperations

import javax.inject.Inject

class CustomVersionTask extends DefaultTask {
Expand All @@ -26,7 +27,6 @@ class CustomVersionTask extends DefaultTask {
def commit = null
def snapshot = ""
new ByteArrayOutputStream().withStream { os ->
// TODO: use ExecOperations.exec
execOperations.exec { spec ->
spec.args = [
"--no-pager"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ Set<CustomOption> toDocletOptions() {
}

private void newOneArgOption(final String optionName, final String description) {
final var parsedOptionName = parseOptionName(optionName);
final var option = Option.builder(parsedOptionName)
.argName(parsedOptionName)
final var option = Option.builder(optionName)
.argName(optionName)
.required(false)
.numberOfArgs(1)
.desc(description)
Expand All @@ -63,8 +62,8 @@ private void newOneArgOption(final String optionName, final String description)
}

private void newArgOption(final String optionName, final String argName, final String description) {
final var option = Option.builder(parseOptionName(optionName))
.argName(parseOptionName(argName))
final var option = Option.builder(optionName)
.argName(argName)
.required(false)
.hasArg()
.desc(description)
Expand All @@ -73,14 +72,9 @@ private void newArgOption(final String optionName, final String argName, final S
cliOptions.addOption(option);
}

private static String parseOptionName(final String optionName) {
return optionName.startsWith("-") ? optionName : "-" + optionName;
}

private void newNoArgOption(final String optionName, final String description) {
final var parsedOptionName = parseOptionName(optionName);
final var option = Option.builder(parsedOptionName)
.argName(parsedOptionName)
final var option = Option.builder(optionName)
.argName(optionName)
.required(false)
.hasArg(false)
.desc(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ public class XmlDoclet implements Doclet {
private PrintWriter stdout;

public XmlDoclet() {
final var supportedOptions = new SupportedOptions();
this.cliOptions = supportedOptions.get();
this.options = supportedOptions.toDocletOptions();
try {
final var supportedOptions = new SupportedOptions();
this.cliOptions = supportedOptions.get();
this.options = supportedOptions.toDocletOptions();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to initialize XmlDoclet", e);
throw e;
}
}

@Override
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/module-info.java

This file was deleted.

Loading