views:

524

answers:

2

Hi all,

I have a project that integrates Struts 1 with Spring. I now wish to port it under Maven 2. I have searched for the proper maven archetype but can't seem to find a proper match. Any suggestions?

Thanks!

A: 

I'm not sure of what you're looking for exactly (after all, a Struts + Spring app is just a webapp) but there is a Struts 1 Blank Archetype for Maven 2:

$ mvn archetype:create                                \
      -DarchetypeGroupId=org.apache.struts            \
      -DarchetypeArtifactId=struts-archetype-blank    \
      -DarchetypeVersion=1.3.5                        \
      -DgroupId=com.example                           \
      -DpackageName=com.example.projectname           \
      -DartifactId=my-webapp

I don't think you'll find something for Struts 1 + Spring 2.5 (at least, not to my knowledge).

Pascal Thivent
+1  A: 

Thanks Pascal, though I had finally decided to write my own pom.xml which I had initially based on AppFuse (actually can't remember exactly which of their archetypes I had branched off..)

Here it is, hope it helps someone:

(I have removed proprietary dependencies and such, so I hope that it is, in its present form, unbroken...)

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd"&gt;

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foo.bar</groupId>
    <artifactId>MyProject</artifactId>
    <packaging>war</packaging>
    <version>1.0.0.0-SNAPSHOT</version>
    <name>My Project</name>

    <prerequisites>
        <maven>2.0.6</maven>
    </prerequisites>


    <repositories>
        <repository>
            <id>codehaus-snapshots</id>
            <name>codehaus-snapshots</name>
            <url>http://nexus.codehaus.org/snapshots
          </url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>ignore</checksumPolicy>
            </snapshots>
        </repository>
    </repositories>


    <build>
        <defaultGoal>install</defaultGoal>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                    <wtpversion>1.5</wtpversion>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-idea-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                    <dependenciesAsLibraries>true</dependenciesAsLibraries>
                    <useFullNames>false</useFullNames>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jspc-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>jspc</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <webXml>${basedir}/target/jspweb.xml</webXml>
                            <injectString>&lt;!-- PrecompiledJSP mapping --&gt;</injectString>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.mojo.jspc</groupId>
                        <artifactId>jspc-compiler-tomcat5</artifactId>
                        <version>2.0-alpha-3</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <webXml>${basedir}/target/jspweb.xml</webXml>
                    <dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <property name="project.ant.conf"
                                    value="${project.build.sourceDirectory}/../conf" />
                                <property name="project.ant.resources"
                                    value="${project.build.sourceDirectory}/../resources" />
                                <property name="project.ant.package"
                                    value="${project.build.sourceDirectory}/../package" />
                                <property name="project.ant.deploy"
                                    value="${project.build.sourceDirectory}/../../deployment" />
                                <property name="project.ant.target.deploy" value="${project.build.directory}/deployment" />

                                <copy todir="${project.ant.target.deploy}">
                                    <fileset dir="${project.ant.deploy}">
                                        <include name="**/*" />
                                    </fileset>
                                </copy>

                                <copy todir="${project.ant.target.deploy}/conf">
                                    <fileset dir="${project.ant.conf}">
                                        <include name="**/*.properties" />
                                    </fileset>
                                </copy>

                                <copy todir="${project.ant.target.deploy}/resources">
                                    <fileset dir="${project.ant.resources}">
                                        <include name="**/*" />
                                    </fileset>
                                </copy>

                                <move
                                    file="${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}"
                                    todir="${project.ant.target.deploy}/webapps" />
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin><!-- Thanks due to Pascal Thivent @ http://stackoverflow.com/users/70604/pascal-thivent -->
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-5</version>
                <configuration>
                    <descriptors>
                        <descriptor>${basedir}/src/main/package/zip.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- append to the packaging phase. -->
                    <goals>
                        <goal>single</goal> <!-- goals == mojos -->
                    </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.0-beta-1</version>
                <configuration>
                    <!-- Required -->
                    <path>/MyProject</path>
                    <warDirectory>${project.build.directory}/${project.build.finalName}</warDirectory>

                    <!-- Optional -->
                    <additionalConfigFilesDir>${basedir}/src/main/tomcatconf</additionalConfigFilesDir>
                    <contextFile>${project.build.directory}/${project.build.finalName}/META-INF/context.xml</contextFile>

                    <port>${cargo.port}</port>
                    <systemProperties>
                        <log4j.configuration>file:${basedir}/src/main/conf/log4j.properties.dev</log4j.configuration>
                    </systemProperties>
                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/conf</directory>
                <includes>
                    <include>MessageResources.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/webapp/velocity/templates</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
            <testResource>
                <directory>src/main/webapp</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </testResource>
        </testResources>
    </build>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>${velocity.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-struts</artifactId>
            <version>${spring.struts.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>${org.springframework.spring.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>${taglibs.standard.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
            <version>${xalan.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <reporting>
        <plugins>
            <plugin>
                <artifactId>maven-changes-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-jxr-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-pmd-plugin</artifactId>
                <configuration>
                    <linkXref>true</linkXref>
                    <targetJdk>1.6</targetJdk>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-report-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>


    <properties>
        <!-- Application settings -->
        <copyright.year>2010</copyright.year>

        <web.framework>spring</web.framework>

        <!-- Framework dependency versions -->
        <spring.version>2.5.6</spring.version>
        <spring.struts.version>2.0.6</spring.struts.version>
        <org.springframework.spring.version>2.5</org.springframework.spring.version>
        <velocity.version>1.6.2</velocity.version>

        <!-- 3rd Party dependency version  -->
        <log4j.version>1.2.15</log4j.version>
        <jstl.version>1.1.2</jstl.version>
        <jdom.version>1.1</jdom.version>
        <taglibs.standard.version>1.1.2</taglibs.standard.version>
        <xalan.version>2.7.1</xalan.version>

        <!-- Testing dependency versions -->
        <jsp.version>2.0</jsp.version>
        <junit.version>4.4</junit.version>
        <servlet.version>2.4</servlet.version>

        <!-- Cargo settings -->
        <cargo.container>tomcat6x</cargo.container>
        <cargo.container.home>${env.CATALINA_HOME}</cargo.container.home>
        <cargo.container.url>http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.zip&lt;/cargo.container.url&gt;
        <cargo.host>localhost</cargo.host>
        <cargo.port>8081</cargo.port>
        <cargo.wait>false</cargo.wait>
    </properties>
</project>
Yaneeve
Ah, yes, forgot about appfuse
Pascal Thivent