Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-8990

When adding the JSF facet to a maven project having filtered web resources, faces-config.xml is created in target/m2e/web-resources/WEB-INF

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.3.0.M2
    • 3.2.0.Final
    • maven
    • None
    • Hide
      • create a new maven project
      • check "Create a simple project (skip archetype selection)"
      • fill in the GAV (Group ArtifactId Version) coordinates : org.jboss:simple-jsf:0.0.1-SNAPSHOT
      • select war packaging
      • click finish
      • copy the following content inside the generated pom.xml :
        <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        	<modelVersion>4.0.0</modelVersion>
        	<groupId>foo.bar</groupId>
        	<artifactId>simple-jsf</artifactId>
        	<version>0.0.1-SNAPSHOT</version>
        	<packaging>war</packaging>
        
        	<dependencies>
        		<dependency>
        			<groupId>javax.faces</groupId>
        			<artifactId>jsf-api</artifactId>
        			<version>1.2_02</version>
        		</dependency>
        	</dependencies>
        	<build>
        		<plugins>
        			<plugin>
        				<groupId>org.apache.maven.plugins</groupId>
        				<artifactId>maven-war-plugin</artifactId>
        				<configuration>
        					<webResources>
        						<webResource>
        							<directory>${basedir}/src/main/webapp/WEB-INF
        							</directory>
        							<includes>
        								<include>web.xml</include>
        							</includes>
        							<targetPath>WEB-INF</targetPath>
        							<filtering>true</filtering>
        						</webResource>
        					</webResources>
        				</configuration>
        			</plugin>
        		</plugins>
        	</build>
        </project>
        
      • right click on the project, Maven > Update Project Configuration

      ASSERT WEB-INF/faces-config.xml is generated under src/main/webapp
      ASSERT WEB-INF/faces-config.xml is not generated under target/m2e-wtp/web-resources/

      Show
      create a new maven project check "Create a simple project (skip archetype selection)" fill in the GAV (Group ArtifactId Version) coordinates : org.jboss:simple-jsf:0.0.1-SNAPSHOT select war packaging click finish copy the following content inside the generated pom.xml : <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>foo.bar</groupId> <artifactId>simple-jsf</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <dependencies> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-api</artifactId> <version>1.2_02</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <webResource> <directory>${basedir}/src/main/webapp/WEB-INF </directory> <includes> <include>web.xml</include> </includes> <targetPath>WEB-INF</targetPath> <filtering>true</filtering> </webResource> </webResources> </configuration> </plugin> </plugins> </build> </project> right click on the project, Maven > Update Project Configuration ASSERT WEB-INF/faces-config.xml is generated under src/main/webapp ASSERT WEB-INF/faces-config.xml is not generated under target/m2e-wtp/web-resources/

    Description

      If a maven project uses web resource filtering and is referencing JSF libraries, then, during the JSF Facet installation, org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDelegate will create the faces-config.xml file in the first resource folder found in .settings/org.eclipse.wst.common.component, for instance :

       
      <?xml version="1.0" encoding="UTF-8"?>
      <project-modules id="moduleCoreId" project-version="1.5.0">
          <wb-module deploy-name="simple-jsf">
              <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
              <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
              <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
              <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
              <property name="context-root" value="simple-jsf"/>
              <property name="java-output-path" value="/simple-jsf/target/classes"/>
          </wb-module>
      </project-modules>
      

      -> target/m2e-wtp/web-resources/WEB-INF/faces-config.xml

      target/ is a derived folder (at least in m2e-core 0.13), and faces-config.xml belongs to the source folders.

      The code responsible for this is

      private IPath resolveConfigPath(final IProject project, final String jsfConfigPath) {
        return ComponentCore.createComponent(project).getRootFolder()
      			.getUnderlyingFolder().getRawLocation().append(
      						new Path(jsfConfigPath));
      }
      

      Obviously, we'd need to fix it upstream. Until that happens, if it happens one day, we can take the WDD (Workaround Driven Development) route :

      • either we try putting the correct source folder first, if needed, before adding the facet, then reverting the change once the JSF facet is added.
      • check if the faces-config.xml file has been created under target/m2e-wtp/web-resources/WEB-INF/ and move it back to src/main/webapp/WEB-INF/

      First solution seems really gross. I'm inclined to implement the 2nd one.

      Attachments

        Issue Links

          Activity

            People

              fbricon@redhat.com Fred Bricon
              fbricon@redhat.com Fred Bricon
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: