Reputation: 1458
I have an SBT project which uses the sbt-xjc plugin to create JAXB Java classes from the QTI XSD (this one in particular). My XSD has a dependency on MathML and it creates MathML classes as well as QTI ones as expected. The only xjc flags I am currently using are -verbose -extension
.
Here's my directory tree:
- src/main/resources/imsqti_v2p1.xsd
- target
- classes/org
- imsglobal/... - Contains QTI .class files
- w3_1998/math/mathml/... - Contains MathML .class files
- src_managed/main/org
- imsglobal/... - Contains generated QTI .java files
- w3/_1998/math/mathml/... - Contains MathML .java files
However, I have another JAXB project with a dependency on MathML and that one also generates MathML classes. I want to get rid of the duplicate classes. I created a MathML JAXB project and added it as a dependency to the other 2 projects. How can I tell SBT to create a QTI autogen JAR which does not include the MathML classes?
I tried something similar to this answer, but it's not working. The MathML classes are still being included in the JAR. Here's my attempt that I added to my build.sbt:
val mathmlPath = "org/w3/_1998/math/mathml"
def isInPath(path: String, file: File) = file.getCanonicalPath.startsWith(mathmlPath)
(managedSources in Compile) := managedSources.value.filterNot(file => isInPath(mathmlPath,file))
I'll accept any of the below to get this to work:
Upvotes: 2
Views: 706
Reputation: 1806
You use the mappings
key to define the content of jar. See: http://www.scala-sbt.org/0.13/docs/Howto-Package.html
In your case, you can exclude MathML files (assume they all starts with org/w3_1998/math/mathml
in jar) by the following settings in build.sbt
:
mappings in (Compile, packageBin) ~= { _.filterNot {
case (filePath, pathInJar) => pathInJar.startsWith("org/w3_1998/math/mathml")
}}
or less verbose (& less readable to some):
mappings in (Compile, packageBin) ~= { _.filterNot(_._2.startsWith("org/w3_1998/math/mathml")) }
Upvotes: 1