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

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

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

    Details

    • 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.

        Attachments

          Activity

            People

            Assignee:
            rbattenfeld Ralf Battenfeld (Inactive)
            Reporter:
            ringerc Craig Ringer (Inactive)
            Archiver:
            samahaja Sagar Mahajan

              Dates

              Created:
              Updated:
              Resolved:
              Archived: