Thursday, May 5, 2011

maven, jsp files in dependency

Hi

I'm using maven2 for dependency management. I have one project that contains some java files and some jsp files and another project, a web project, that depends on the first project. How do I access the jsp files from the web project? I can see that the jsp files are added to 1-0-SNAPSHOT-sources.jar and not 1-0-SNAPSHOT.jar ( which is added as a dependency in the web projects pom.xml) ... Any suggestions would be appreciated..

From stackoverflow
  • Hi

    I think the correct Maven-way to do it would be to put the JSP files in your web project under /src/main/webapp. If that for some reason is not possible, you could use the Maven Dependency Plugin to copy the needed files into your webapp. Or, if you have a WAR project anyway, you could use an Overlay to copy the JSP-Files. The second option (which I'd recommend), would look something like this:

        <build>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-war-plugin</artifactId>
              <configuration>
                <overlays>
                  <overlay>
                    <groupId>myGroupId</groupId>
                    <artifactId>myArtifactId</artifactId>
                    <type>jar</type>
                    <includes>
                      <include>**/*.jsp</include>
                    </includes>
                    <targetPath>WEB-INF/pages</targetPath>
                  </overlay>
                </overlays>
              </configuration>
            </plugin>
          </plugins>
        </build>
    
    vpalle : thank you for the answer. WAR overlay was the right solution for the project.
    Thomas Marti : Glad to help. How about an upvote then... ;)
  • The problem with that solution is that when developping with Eclipse, the project doesn't handle the overlay ... so the jsp are not accessible ...

0 comments:

Post a Comment