Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 25 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ repositories {
configurations {
bootstrap
genresources
java9
jpms
}

ext {
Expand Down Expand Up @@ -127,9 +127,6 @@ dependencies {
implementation "com.github.javaparser:javaparser-core:${javaparserVersion}"
implementation "com.github.javaparser:javaparser-symbol-solver-core:${javaparserVersion}"

// only necessary to compile against JDK8 internals - for Java9+ there's a multimodule implementation
implementation 'com.sun.org.apache.xml.internal:resolver:20050927'

// NOTE: newer JUnit breaks some tests for some reason
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.3'
Expand Down Expand Up @@ -161,16 +158,17 @@ dependencies {
genresources "com.github.javaparser:javaparser-core:${javaparserVersion}"
genresources "com.github.javaparser:javaparser-symbol-solver-core:${javaparserVersion}"

// need an own configuration for Java9 builds, as the maven plugin module-config is overlapping lot
java9 "org.apache.logging.log4j:log4j-api:${log4jVersion}"
java9("net.sf.saxon:Saxon-HE:${saxonVersion}") {
// module path for compiling module-info.java - kept separate, as the maven plugin dependencies
// would otherwise end up on the module path too
jpms "org.apache.logging.log4j:log4j-api:${log4jVersion}"
jpms("net.sf.saxon:Saxon-HE:${saxonVersion}") {
exclude group: 'xml-apis', module: 'xml-apis'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'org.apache.httpcomponents', module: 'httpcore'
}
java9 "org.apache.ant:ant:${antVersion}"
java9 "com.github.javaparser:javaparser-core:${javaparserVersion}"
java9("com.github.javaparser:javaparser-symbol-solver-core:${javaparserVersion}") {
jpms "org.apache.ant:ant:${antVersion}"
jpms "com.github.javaparser:javaparser-core:${javaparserVersion}"
jpms("com.github.javaparser:javaparser-symbol-solver-core:${javaparserVersion}") {
exclude group: 'com.google.guava', module: 'failureaccess'
exclude group: 'com.google.guava', module: 'listenablefuture'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
Expand Down Expand Up @@ -286,21 +284,20 @@ compileTestJava {
dependsOn testSchemas.collect {"${it.name}_SchemaGen" }
}

task compileJava9(type: JavaCompile) {
// Compiles module-info.java on its own: the already compiled classes are patched into the module
// and its dependencies are taken from the module path. The module-info.class ends up in the jar root.
tasks.register('compileModuleInfo', JavaCompile) {
dependsOn 'compileJava'

javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(jdkVersion)
}
sourceCompatibility = 17
targetCompatibility = 17
destinationDirectory = file('build/classes/java9/main/META-INF/versions/9')
source = file('src/main/java9')
options.release = 17
destinationDirectory = layout.buildDirectory.dir('classes/jpms/main')
source = file('src/main/jpms')
classpath = files()
options.compilerArgs = [
'--patch-module', "org.apache.xmlbeans=${sourceSets.main.output.asPath}",
'--module-path', files(sourceSets.main.output.files + configurations.java9.asFileTree.files).asPath
]
doFirst {
options.compilerArgs = [
'--patch-module', "org.apache.xmlbeans=${sourceSets.main.output.asPath}",
'--module-path', files(sourceSets.main.output.files + configurations.jpms.files).asPath
]
}
}

processTestResources {
Expand All @@ -310,7 +307,7 @@ processTestResources {
task export4anttest(type: Copy) {
dependsOn 'jar'
into "build/libs"
from configurations.java9
from configurations.jpms
}

test {
Expand All @@ -330,7 +327,6 @@ idea {
}

jar {
dependsOn compileJava9
archiveBaseName = "xmlbeans-${XMLBeansVersion}"

from(project.rootDir) {
Expand All @@ -339,7 +335,7 @@ jar {
into 'META-INF'
}

from('build/classes/java9/main')
from(tasks.named('compileModuleInfo'))

from('src/main/maven') {
exclude '**/*.java'
Expand All @@ -350,7 +346,6 @@ jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE

manifest {
attributes('Multi-Release':'true')
attributes([
'Comment': "Apache XmlBeans version ${XMLBeansVersion}",
'Specification-Title': 'Apache XmlBeans',
Expand All @@ -375,6 +370,7 @@ javadocJar {

sourcesJar {
archiveBaseName = "xmlbeans-${XMLBeansVersion}"
from('src/main/jpms')
metaInf {
from("$projectDir/LICENSE.txt")
from("$projectDir/NOTICE.txt")
Expand Down Expand Up @@ -824,6 +820,8 @@ animalsniffer {
//sourceSets = [sourceSets.main]
ignore 'javax.xml.stream.*'
ignore 'javax.xml.namespace.*'
// only used by the maven plugin, which never runs on Android
ignore 'javax.xml.catalog.*'
}

// The Android API signature only makes sense for code we ship. ParseUrlRedirectTest
Expand Down
17 changes: 6 additions & 11 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@
<dependency prefix="maven-model" artifact="org.apache.maven:maven-model:3.9.16" usage="maven-plugin"/>
<dependency prefix="maven-plugin-api" artifact="org.apache.maven:maven-plugin-api:3.9.16" usage="maven-plugin"/>
<dependency prefix="maven-plugin-annotations" artifact="org.apache.maven.plugin-tools:maven-plugin-annotations:3.15.2" usage="maven-plugin"/>
<!-- only necessary to compile against JDK8 internals - for Java9+ there's a mulitmodule implementation -->
<dependency prefix="xml-resolver" artifact="com.sun.org.apache.xml.internal:resolver:20050927" usage="maven-plugin"/>

<path id="maven-plugin">
<pathelement location="${maven-core.jar}"/>
<pathelement location="${maven-model.jar}"/>
<pathelement location="${maven-plugin-api.jar}"/>
<pathelement location="${maven-plugin-annotations.jar}"/>
<pathelement location="${xml-resolver.jar}"/>
</path>

<path id="xmlbeans-test">
Expand Down Expand Up @@ -206,6 +203,7 @@
we often had hard-to-find build/CI-problems because of these! -->
<delete dir="compile-lib"/>
<delete dir="lib/main" includes="javaparser-core-3.1*.jar,javaparser-core-3.23.0.jar,slf4j*.jar,Saxon-HE-10.2.jar"/>
<delete dir="lib/maven-plugin" includes="resolver-20050927.jar"/>
<delete dir="lib/tests" includes="slf4j*.jar"/>
<delete dir="lib/util" includes="forbiddenapis-2.6.jar,forbiddenapis-3.4.jar,apache-rat-0.12.jar"/>
<condition property="jars.present">
Expand All @@ -229,7 +227,6 @@
<available file="${maven-model.jar}"/>
<available file="${maven-plugin-api.jar}"/>
<available file="${maven-plugin-annotations.jar}"/>
<available file="${xml-resolver.jar}"/>
</and>
<isset property="disconnected"/>
</or>
Expand Down Expand Up @@ -267,7 +264,6 @@
<downloadfile dest="${maven-model.jar}" src="${maven-model.url}"/>
<downloadfile dest="${maven-plugin-api.jar}" src="${maven-plugin-api.url}"/>
<downloadfile dest="${maven-plugin-annotations.jar}" src="${maven-plugin-annotations.url}"/>
<downloadfile dest="${xml-resolver.jar}" src="${xml-resolver.url}"/>
</target>

<macrodef name="schemaComp">
Expand Down Expand Up @@ -439,14 +435,14 @@
<classpath refid="maven-plugin"/>
</javac>

<mkdir dir="build/classes-jpms"/>
<javac release="17"
srcdir="${basedir}/src/main/multimodule/java9"
destdir="${basedir}/src/main/multimodule/java9"
srcdir="${basedir}/src/main/jpms"
destdir="build/classes-jpms"
includeantruntime="false"
debug="${compile.debug}"
debuglevel="lines,vars,source"
fork="true"
unless:true="${isJava8}">
fork="true">
<compilerarg line="--patch-module org.apache.xmlbeans=${basedir}/build/classes"/>
<modulepath>
<pathelement path="lib/main"/>
Expand Down Expand Up @@ -660,14 +656,13 @@
<fileset dir="build/classes" excludes="org/apache/xmlbeans/impl/schema/TypeSystemHolder.template"/>
<fileset dir="." includes="LICENSE.txt,NOTICE.txt"/>
<fileset dir="build/generated-resources"/>
<zipfileset dir="src/main/multimodule/java9" prefix="META-INF/versions/9" excludes="**/*.java"/>
<fileset dir="build/classes-jpms"/>
<zipfileset dir="build/maven" prefix="META-INF/maven"/>
<mappedresources>
<fileset dir="src/main/resources" excludes="maven/**"/>
<cutdirsmapper dirs="1"/>
</mappedresources>
<manifest>
<attribute name="Multi-Release" value="true"/>
<section name="org/apache/xmlbeans/">
<attribute name="Comment" value="Apache XmlBeans version ${version.base}"/>
<attribute name="Implementation-Title" value="org.apache.xmlbeans"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@

package org.apache.xmlbeans.impl.tool;

import com.sun.org.apache.xml.internal.resolver.CatalogManager;
import com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver;
import org.apache.xmlbeans.impl.util.SuppressForbidden;
import org.xml.sax.EntityResolver;

import javax.xml.catalog.Catalog;
import javax.xml.catalog.CatalogFeatures;
import javax.xml.catalog.CatalogManager;
import java.io.File;

/**
* Helper class for XML catalogs, which is provided as Java 8 and Java 9+ version (multi release)
* Helper class for XML catalogs, based on the JDK {@code javax.xml.catalog} API
*/
@SuppressForbidden("class is available in Java 8 and multi-release version handles newer official package namespace")
public class MavenPluginResolver {
public static EntityResolver getResolver(String catalogLocation) {
if (catalogLocation == null) {
return null;
}
CatalogManager catalogManager = CatalogManager.getStaticManager();
catalogManager.setCatalogFiles(catalogLocation);
return new CatalogResolver(catalogManager);

CatalogFeatures features = CatalogFeatures.builder()
.with(CatalogFeatures.Feature.PREFER, "system")
.build();
Catalog catalog = CatalogManager.catalog(features, new File(catalogLocation).toURI());
return CatalogManager.catalogResolver(catalog);
}
}

This file was deleted.

File renamed without changes.
6 changes: 0 additions & 6 deletions src/main/maven/org.apache.xmlbeans/xmlbeans/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@
<version>3.28.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.org.apache.xml.internal</groupId>
<artifactId>resolver</artifactId>
<version>20050927</version>
<scope>provided</scope>
</dependency>

<!-- dependencies for xmlbeans maven plugin -->
<dependency>
Expand Down
Loading