Announcement Announcement Module
Collapse
No announcement yet.
Migrate Maven 2.0.9 to 3.0.4 problems in STS Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Migrate Maven 2.0.9 to 3.0.4 problems in STS

    I have existing projects that were built using Maven 2.0.9. Our development tools is the Helios distribution of Eclipse. Our projects use a nested POM approach. We build from the command line mvn clean install using an archetype (see below). All of our projects point to a <parent> pom that is in a global project called "BuildStandards". BuildStandards is built and located in the .m2/repository along with all other dependencies defined in both BuildStandards, the root POM of a specific project, and, all of the POMs in all of the project's sub-folders. This all works.

    We want to upgrade from Helios to the latest STS, which means migrating to Maven 3.0.4. I have modified the POMs to reference the Maven installation installed with STS as well as configured my system's environmental variables to target the same installation.

    Here are the steps I've taken so far:
    1. Point to Maven 3.0.4
    2. delete classpath reference to maven 2 in the .classpath file
    3. run mvn clean install (Maven 3.0.4) - BUILD SUCCESS
    4. import project into STS
    5. convert project to Maven project
    6. update maven dependencies

    After doing this, and many other variations in the process, none of the dependencies outside of the project itself (Spring, BuildStandards, etc) are seen.

    It appears that STS does not work with nested POMs even though Maven does. It seems that if I put each module (as defined in the POM) as separate projects, then it can work; however, then the problem seems to be that if you use one of the modules by another project and, that module has a dependency on another Module that is not needed by the external project, then there can be conflicts in classpath resolution.

    Does anyone have experience in migrating from large, nested-POM based projects to STS's Juno distribution, and, migration from Maven 2 to Maven 3 as it pertains to STS?

    BuildStandards pom.xml
    Code:
    <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">
        <modelVersion>4.0.0</modelVersion>
    
       <groupId>com.fitness</groupId>
       <artifactId>build-standards</artifactId>
       <version>2.5</version>
       <packaging>pom</packaging>
    
       <name>Build Standards - 24 Hour Fitness Master POM</name>
       <description>Master POM for 24 Hour Fitness</description>
        <inceptionYear>2006</inceptionYear>
    
       
       <properties>
        ...
          <com.fitness.maven.version>3.0.4</com.fitness.maven.version>
          <com.fitness.spring.version>3.1.2</com.fitness.spring.version>
          <com.fitness.architecture-common.version>1.1.0-SNAPSHOT</com.fitness.architecture-common.version>
          <com.fitness.domain-objects.version>1.1.0-SNAPSHOT</com.fitness.domain-objects.version>
          <com.fitness.framework-architecture.version>1.0.1-SNAPSHOT</com.fitness.framework-architecture.version>
          <com.fitness.framework-error.version>1.3.0-SNAPSHOT</com.fitness.framework-error.version>
          <com.fitness.framework-persistence.version>1.1.0-SNAPSHOT</com.fitness.framework-persistence.version>
          <com.fitness.manifest-reader.version>1.1.0</com.fitness.manifest-reader.version>
          ...
    
       </properties>
    
       <profiles>
          <profile>
                <id>com.fitness.env.buildserver</id>
             <activation>
                <os>
                   <name>Linux</name>
                </os>
             </activation>
             <properties>
                <com.fitness.dist.base.url>file:///var/www/localhost/htdocs/maven</com.fitness.dist.base.url>
                <com.fitness.site.base.url>http://${com.fitness.buildServer}/maven/site</com.fitness.site.base.url>
              ...
             </properties>
          </profile>
                   ...
    
       </profiles>
    
       <prerequisites>
          <maven>${com.fitness.maven.version}</maven>
       </prerequisites>
    
          <dependencyManagement>
          <dependencies>
            
             <dependency>
                <groupId>com.fitness.architecture</groupId>
                <artifactId>architecture-error</artifactId>
                <version>${com.fitness.framework-architecture.version}</version>
             </dependency>
             <dependency>
                <groupId>com.fitness.architecture</groupId>
                <artifactId>architecture-common</artifactId>
                <version>${com.fitness.architecture-common.version}</version>
             </dependency>
             <dependency>
                <groupId>com.fitness.architecture.persistence</groupId>
                <artifactId>architecture-persistence</artifactId>
                <version>${com.fitness.framework-persistence.version}</version>
             </dependency>
             <dependency>
                <groupId>com.fitness.domain</groupId>
                <artifactId>domain-objects</artifactId>
                <version>${com.fitness.domain-objects.version}</version>
             </dependency>
             <dependency>
                <groupId>com.fitness.framework.util</groupId>
                <artifactId>ManifestReader</artifactId>
                <version>${com.fitness.manifest-reader.version}</version>
             </dependency>
            
             <!-- Spring Framework -->
             <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${com.fitness.spring.version}</version>
             </dependency>
    
              ....
    
          </dependencies>
       </dependencyManagement>
    
          ...
    
       <build>
          <plugins>
             <plugin>
                <groupId>com.keyboardsamurais.maven</groupId>
                <artifactId>maven-timestamp-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                   <propertyName>com.fitness.build.timestamp</propertyName>
                   <timestampPattern>MM.dd.yyyy HH:mm</timestampPattern>
                </configuration>
                <executions>
                   <execution>
                      <goals>
                         <goal>create</goal>
                      </goals>
                   </execution>
                </executions>
             </plugin>
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                   <execution>
                      <id>enforce-versions</id>
                      <goals>
                         <goal>enforce</goal>
                      </goals>
                      <configuration>
                         <rules>
                            <requireMavenVersion>
                               <version>${com.fitness.maven.version}</version>
                            </requireMavenVersion>
                            <requireJavaVersion>
                               <version>${com.fitness.java.version}</version>
                            </requireJavaVersion>
                         </rules>
                      </configuration>
                   </execution>
                  
                </executions>
             </plugin>
            
          </plugins>
    
       </build>
    </project>

    Root pom.xml in project that uses the BuildStandards pom.xml declared in <parent>
    Code:
    <?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">
       <parent>
          <groupId>com.fitness</groupId>
          <artifactId>build-standards</artifactId>
          <version>2.5</version>
       </parent>
    
       <modelVersion>4.0.0</modelVersion>
    
       <groupId>com.fitness.order</groupId>
       <artifactId>order-services</artifactId>
       <version>1.1.0-SNAPSHOT</version>
       <packaging>pom</packaging>
    
       <name>OrderServices - ${project.version}</name>
       <description>${name}</description>
    
    
       <properties>
          <com.fitness.base.project.id>OrderServices</com.fitness.base.project.id>
       </properties>
    
    
       <scm>
          <connection>scm:svn:http://sequoia/itdev/applications/OrderServices/branches/1.1.0</connection>
          <developerConnection>scm:svn:http://sequoia/itdev/applications/OrderServices/branches/1.1.0</developerConnection>
          <url>http://sequoia/itdev/applications/OrderServices/branches/1.1.0</url>
       </scm>
    
       <modules>
          <module>Common</module>
          <module>Domain</module>
          <module>Services</module>
          <module>IntegrationTests</module>
       </modules>
    
       <dependencyManagement>
          <dependencies>
             <!-- ********************************** * Intra-Project Dependencies * ********************************** -->
    
             <dependency>
                <groupId>com.fitness.order</groupId>
                <artifactId>order-common-test-util</artifactId>
                <version>${project.version}</version>
             </dependency>
    
             <dependency>
                <groupId>com.fitness.order</groupId>
                <artifactId>order-common-exceptions</artifactId>
                <version>${project.version}</version>
             </dependency>
    
    ...
    Last edited by jpgaber; Oct 31st, 2012, 04:44 PM.

  • #2
    Here is the archetype.

    Code:
    <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">
       <!--
          Note this is not included as a module of build standards on purpose. There is no need for 
          all projects to depend on this archetype 
       -->
       <modelVersion>4.0.0</modelVersion>
    
       <groupId>com.fitness.archetype</groupId>
       <artifactId>server-archetype</artifactId>
       <version>1.4-SNAPSHOT</version>
       <packaging>maven-archetype</packaging>
    
       <name>Server Archetype Project</name>
       <description>
          An archetype that creates a project shell that conforms to the 24 Hour Fitness standard project directory
          structure for a server projects. It configures the sub projects with common and expected dependencies. 
          Once the shell is generated, run "mvn clean install" and the project will:
          1) Compile the sample code
          2) Run unit tests
          3) Create various artifacts of sub-projects, including container artifacts.
          4) Create and start an instance of the container
          5) Deploy the container artifacts to the container
          6) Take the unit tests from step 2 and run them as local integration test (It can do the same with remote integration tests)
          7) Stop the container
          8) Install the artifacts in the local repository.
       </description>
       <url>http://${com.fitness.buildServer}maven/site/${artifactId}/${version}</url>
       <inceptionYear>2008</inceptionYear>
    
    
       <build>
          <extensions>
             <extension>
                <groupId>org.apache.maven.archetype</groupId>
                <artifactId>archetype-packaging</artifactId>
                <version>2.0-alpha-4</version>
             </extension>
          </extensions>
          <plugins>
             <plugin>
                <artifactId>maven-archetype-plugin</artifactId>
                <version>2.0-alpha-4</version>
                <extensions>true</extensions>
             </plugin>
          </plugins>
       </build>
    
       <distributionManagement>
          <repository>
             <uniqueVersion>false</uniqueVersion>
             <id>repo</id>
             <name>24 Hour Fitness Repository</name>
             <url>file:///var/www/localhost/htdocs/maven/repository</url>
          </repository>
          <snapshotRepository>
             <uniqueVersion>false</uniqueVersion>
             <id>repo-snap</id>
             <name>24 Hour Fitness Snapshot Repository</name>
             <url>file:///var/www/localhost/htdocs/maven/repository</url>
          </snapshotRepository>
          <site>
             <id>website</id>
             <name>24 Hour Fitness Build Site</name>
             <url>file:///var/www/localhost/htdocs/maven/site/${artifactId}/${version}</url>
          </site>
       </distributionManagement>
    </project>

    Comment


    • #3
      Hey!

      Did you try to import the projects into STS using the Maven Import (rather than converting the projects to a Maven project after you imported them)? As far as I know the Maven Import takes care of these nested structures and creates some kind of workarounds for that setting in Eclipse/STS.

      HTH,
      Martin

      Comment

      Working...
      X