The JAXB databinding attaches the jaxb plugin to the generate sources phase and this results in the test code ending up in the output jar:
$ jar tf target/databinding-jaxb-1.0-chianti-SNAPSHOT.jar
META-INF/
META-INF/MANIFEST.MF
com/
com/example/
com/example/ipo/
com/example/ipo/jaxb/
org/
org/apache/
org/apache/tuscany/
org/apache/tuscany/databinding/
org/apache/tuscany/databinding/jaxb/
com/example/ipo/jaxb/Address.class
com/example/ipo/jaxb/Items$Item.class
com/example/ipo/jaxb/Items.class
com/example/ipo/jaxb/ObjectFactory.class
com/example/ipo/jaxb/package-info.class
com/example/ipo/jaxb/PurchaseOrderType.class
com/example/ipo/jaxb/UKAddress.class
com/example/ipo/jaxb/USAddress.class
com/example/ipo/jaxb/USState.class
org/apache/tuscany/databinding/jaxb/JAXB2Node.class
org/apache/tuscany/databinding/jaxb/Node2JAXB.class
org/apache/tuscany/databinding/jaxb/XMLStreamReader2JAXB.class
META-INF/maven/
META-INF/maven/org.apache.tuscany.databinding/
META-INF/maven/org.apache.tuscany.databinding/databinding-jaxb/
META-INF/maven/org.apache.tuscany.databinding/databinding-jaxb/pom.xml
META-INF/maven/org.apache.tuscany.databinding/databinding-jaxb/ pom.properties

If I change the pom to attach this to the generate-test-sources phase:
$ svn diff pom.xml
Index: pom.xml
===================================================================
--- pom.xml     (revision 421082)
+++ pom.xml     (working copy)
@@ -100,7 +100,7 @@
                 <executions>
                     <execution>
                         <id>generate-jaxb</id>
-                        <phase>generate-sources</phase>
+                        <phase>generate-test-sources</phase>
                         <goals>
                             <goal>generate</goal>
                         </goals>

then I get an error running the tests:
$ mvn -o clean test
[INFO]
NOTE: Maven is executing in offline mode. Any artifacts not already in your local
repository will be inaccessible.

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------ ----
[INFO] Building Tuscany JAXB Data Binding
[INFO]    task-segment: [clean, test]
[INFO] ------------------------------------------------------------------------ ----
[INFO] [clean:clean]
[INFO] Deleting directory /Users/jboynes/tuscany/sandbox/chianti/sca/ databinding/databinding-jaxb/target [INFO] Deleting directory /Users/jboynes/tuscany/sandbox/chianti/sca/ databinding/databinding-jaxb/target/classes [INFO] Deleting directory /Users/jboynes/tuscany/sandbox/chianti/sca/ databinding/databinding-jaxb/target/test-classes
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
Compiling 3 source files to /Users/jboynes/tuscany/sandbox/chianti/ sca/databinding/databinding-jaxb/target/classes
[INFO] [jaxb:generate {execution: generate-jaxb}]
[INFO] /Users/jboynes/tuscany/sandbox/chianti/sca/databinding/ databinding-jaxb/target/jaxb-source/com/example/ipo/jaxb is not found and thus excluded from the dependency check [INFO] Compiling file:/Users/jboynes/tuscany/sandbox/chianti/sca/ databinding/databinding-jaxb/src/test/resources/ipo.xsd [INFO] Writing output to /Users/jboynes/tuscany/sandbox/chianti/sca/ databinding/databinding-jaxb/target/jaxb-source
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
Compiling 1 source file to /Users/jboynes/tuscany/sandbox/chianti/sca/ databinding/databinding-jaxb/target/test-classes
[INFO] [surefire:test]
[INFO] Surefire report directory: /Users/jboynes/tuscany/sandbox/ chianti/sca/databinding/databinding-jaxb/target/surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.apache.tuscany.databinding.jaxb.JAXBTestCase
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.083 sec <<< FAILURE! testTransform(org.apache.tuscany.databinding.jaxb.JAXBTestCase) Time elapsed: 0.041 sec <<< ERROR! javax.xml.bind.JAXBException: "com.example.ipo.jaxb" doesnt contain ObjectFactory.class or jaxb.index at com.sun.xml.bind.v2.ContextFactory.createContext (ContextFactory.java:119)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
at javax.xml.bind.ContextFinder.newInstance (ContextFinder.java:132)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:286)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
at org.apache.tuscany.databinding.jaxb.JAXBTestCase.testTransform (JAXBTestCase.java:48)


Results :
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Tue Jul 11 19:29:45 PDT 2006
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------

Could someone more familiar with this plugin tell me what is going wrong and how we can avoid have the test code in the output jar?
Thanks
--
Jeremy


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to