Closed aanno2 closed 5 years ago
I think the basic problem, is that ph-jaxb-pom POM cannot be resolved. It's a "POM only" project and resides on http://repo2.maven.org/maven2/com/helger/ph-jaxb-pom/1.0.0/ - please try including it from this server and check again. Thanks.
Well, I also asked the question at a gradle discussion. The answer was:
Gradle does not support JDK based profile activation.
The answer also refers to this stackoverflow answer.
For me, it looks like that using ph-schematron from gradle is not that easy currently. The problem is not that http://repo2.maven.org/maven2/com/helger/ph-jaxb-pom/1.0.0/ could not be resolved. The problem is that gradle does not like pom files with the version resolved from a property (${jabx.version}) ...
As addition: Currently, I'm including ph-schematron in my gradle 5.1.1 (kotlin-based) build with the following
api("com.helger", "ph-schematron", "5.0.8") {
exclude("com.helger", "ph-jaxb")
exclude("com.helger", "ph-jaxb-pom")
exclude("org.glassfish.jaxb", "jaxb-bom")
}
Hence, I'm (explicitly) excluding all the jaxb
parent-pom/bom dependency stuff. If I run into something missing, I (also) explicitly add this directly. But this is only a work-around.
@aanno Thanks for pointing out that issue with Gradle. As I'm not using Gradle (and not plans to do so), I'm stuck with the Maven properties files. But what I did is to document the needed artefacts, and maybe you can create a Gradle setup that I could add to the documentation. See https://github.com/phax/ph-jaxb-pom#gradle-usage hth
I assume this works now. If not, please re-open.
Note for future gradle users, this was the only way I could get it working with Gradle 4.10:
buildscript {
repositories {
mavenCentral()
}
dependencies {
....
// https://github.com/phax/ph-schematron/issues/72#issuecomment-453734138
classpath('com.helger:ph-schematron:5.2.0') {
exclude group: 'com.helger', module: 'ph-jaxb'
exclude group: 'com.helger', module: 'ph-jaxb-pom'
exclude group: 'org.glassfish.jaxb', module: 'jaxb-bom'
}
classpath 'org.glassfish.jaxb:jaxb-core:2.2.11'
classpath 'org.glassfish.jaxb:jaxb-runtime:2.2.11'
classpath 'com.sun.istack:istack-commons-runtime:2.21'
}
}
// import ph-schematron classes for pure schematron validation
import com.helger.schematron.ISchematronResource
import com.helger.schematron.pure.SchematronResourcePure
task validateSchematron {
group = 'XXXX'
description 'YYYYY'
doLast {
File xsdSchematron = new File("$projectDir/sch/test.sch");
validationFiles.each{ xml ->
println "Validate $xml"
final ISchematronResource aResPure = SchematronResourcePure.fromFile(xsdSchematron);
if (!aResPure.isValidSchematron()) {
throw new IllegalArgumentException ("Invalid Schematron!");
}
def schRes = aResPure.getSchematronValidity(new StreamSource(xml)).isValid();
if(schRes) {
println "... SCHEMATRON OK"
} else {
println "... SCHEMATRON FAILED"
}
}
}
}
Thanks @tofi86 👍 I assume this is in combination with Java 8? For Java 9+ you should switch to the JAXB 2.3 modules...
I assume this is in combination with Java 8? For Java 9+ you should switch to the JAXB 2.3 modules...
Yes, its for a Java 8 project.
... I encounter the following error:
For me, it looks like that '${jaxb.version}' is not defined when using gradle instead of maven. How can I avoid the problem?