Uploaded image for project: 'ShrinkWrap Descriptors'
  1. ShrinkWrap Descriptors
  2. SHRINKDESC-115

Descriptors 2.0 module creates duplicate <alternatives/> entries (test case attached)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 2.0.0-alpha-4
    • Component/s: None
    • Environment:
    • Steps to Reproduce:
      Hide

      "mvn test"

      Show
      "mvn test"

      Description

      Using: org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-impl-javaee:jar:2.0.0-alpha-2

      The attached test case produces an invalid beans.xml with a duplicate <alternatives/> entry with the code:

              BeansDescriptor beansXml = Descriptors.importAs(BeansDescriptor.class)
                      .from(new File("src/main/webapp/WEB-INF/beans.xml"))
                      .getOrCreateAlternatives();
      

      'getOrCreate' is in fact always creating an alternatives entry, so the following beans.xml is produced in the example:

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
      <alternatives>
                 <alternative>com.example.shrinkwraptestskeleton.Production</alternative>
        </alternatives>
        <alternatives/>
      </beans>
      

      The produced beans.xml descriptor fails at deployment time with:

      org.jboss.weld.exceptions.DefinitionException: WELD-001203 <alternatives> can only be specified once, but appears multiple times: vfs:/content/demo.jar/META-INF/beans.xml@6

      Also: Since there can only ever be one <alternatives/> block, it's not clear what the difference between getOrCreateAlternatives() and createAlternatives() is. Is the latter supposed to replace any existing block?

      The API for managing alternatives is in Descriptors 2.0 is IMO difficult to use and understand. Issues with examples pending.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                rbattenfeld Ralf Battenfeld
                Reporter:
                ringerc Craig Ringer
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: