Java web application development for two clients

I am developing a web project based on Spring (MVC), Hibernate, PostgreSQL (using Maven). Now I am trying to get a new client that requires some differences in several parts of the application. I read the Maven Definitive Guide from Sonatype to get an idea of ​​Maven Multi-modules projects, but there was no answer to one of my most important questions: how can I share common view components across several modules / projects and integrate them depending on the customer for whom I want to build? The level of service is pretty clear, but I can’t understand how to share jsp / jspf files and combine them with user files when creating a specific client module (which then depends on a common module).

How do you try to avoid just cloning commonly used code?

+5
source share
2 answers

I can not understand how to share jsp / jspf files and combine them with user files when creating a specific client module (which then depends on the general module).

This looks like a good use case for Overlays .

+4
source

You can put common components in the library project and unpack them as needed using the dependency: unpack or dependency: unpack-dependencies

eg. you plan the project this way:

root
 |____ common-lib (jar, contains common java code)
 |____ common-gui (jar, contains only non-java stuff like js, jsp, css etc) 
 |____ client1    (war)
 |____ client2    (war)

client1 client2 compile common-lib, provided common-gui ( dependency:unpack, )

-:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>unpack-common-gui-elements</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>com.yourcompany</groupId>
                        <artifactId>common-gui</artifactId>
                        <version>${project.version}</version>
                        <type>jar</type>
                        <!--  war assembly directory -->
                        <outputDirectory>
                            ${project.build.directory}/${project.build.finalName}
                        </outputDirectory>
                        <includes>**/*.jsp,**/*.css,**/*.js</includes>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

, , , .

+3

All Articles