Uploaded image for project: 'Apache Tomcat Maven Plugin'
  1. Apache Tomcat Maven Plugin
  2. MTOMCAT-72

Tomcat plugin can not access variables in tomcat:deploy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • None

    Description

      I am using the maven buildnumber plugin to generate timestamp specific artifact versions when building. However, it is not possible to deploy such artifacts with tomcat:deploy because of the forced lifecycle.

      Some excerpts from my pom:

      <?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/xsd/maven-4.0.0.xsd">
      <build>
      <finalName>--</finalName>
      <plugins>
      <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>buildnumber-maven-plugin</artifactId>
      <version>1.0-beta-3</version>
      <executions>
      <execution>
      <phase>validate</phase>
      <goals>
      <goal>create</goal>
      </goals>
      </execution>
      </executions>
      <configuration>
      <doCheck>false</doCheck>
      <doUpdate>false</doUpdate>
      <format>

      {0,date,yyyyMMdd-HHmmss}

      _

      {1}

      </format>
      <items>
      <item>timestamp</item>
      <item>tomcat</item>
      </items>
      </configuration>
      </plugin>
      <plugin>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.1</version>
      <configuration>
      <attachClasses>true</attachClasses>
      <archive>
      <manifest>
      <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
      </manifest>
      <manifestEntries>
      <Implementation-Build></Implementation-Build>
      </manifestEntries>
      </archive>
      </configuration>
      </plugin>
      <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>tomcat-maven-plugin</artifactId>
      <version>1.1</version>
      <configuration>
      <update>true</update>
      </configuration>
      </plugin>
      </plugins>
      </build>
      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.build.targetJdk>1.6</project.build.targetJdk>
      <project.xyz></project.xyz>
      </properties>
      </project>

      If I run a full build:

      % mvn clean package tomcat:deploy

      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [INFO] Building mywebapp Maven Webapp
      [INFO] task-segment: [clean, package, tomcat:deploy]
      [INFO] ------------------------------------------------------------------------
      [INFO] [clean:clean

      {execution: default-clean}

      ]
      [INFO] Deleting directory /buildfolder/mywebapp/target
      [INFO] [buildnumber:create

      {execution: default}

      ]
      [INFO] Storing buildNumber: 20101027-132408_henning at timestamp: 1288211048293
      [INFO] Compiling 1 source file to /buildfolder/mywebapp/target/classes
      [INFO] [war:war

      {execution: default-war}

      ]
      [INFO] Packaging webapp
      [INFO] Assembling webapp [mywebapp] in [/buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-20101027-132408_henning]
      [INFO] Processing war project
      [INFO] Copying webapp resources [/buildfolder/mywebapp/src/main/webapp]
      [INFO] Webapp assembled in [87 msecs]
      [INFO] Building war: /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-20101027-132408_henning.war
      [INFO] WEB-INF/web.xml already added, skipping
      [...]
      [INFO] [tomcat:deploy

      {execution: default-cli}

      ]
      [INFO] Deploying war to http://localhost:8080/mywebapp
      [INFO] OK - Undeployed application at context path /mywebapp
      [INFO] OK - Deployed application at context path /mywebapp
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESSFUL
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 12 seconds
      [INFO] Finished at: Wed Oct 27 13:24:18 PDT 2010
      [INFO] Final Memory: 65M/267M
      [INFO] ------------------------------------------------------------------------

      running with -X shows, that it actually deploys the war built in regular build, not the one in the forked lifecycle:

      Regular Lifecycle:

      [INFO] Building war: /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-20101027-132750_henning.war
      [...]

      Forked Lifecycle:

      [INFO] Building war: /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-20101027-132757_henning.war

      Deploys the first one:

      [DEBUG] Configuring mojo 'org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy' -->
      [DEBUG] (f) charset = ISO-8859-1
      [DEBUG] (f) contextFile = /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-20101027-132750_henning/META-INF/context.xml
      [DEBUG] (f) ignorePackaging = false
      [DEBUG] (f) mode = war
      [DEBUG] (f) packaging = war
      [DEBUG] (f) path = /mywebapp
      [DEBUG] (f) update = true
      [DEBUG] (f) url = http://localhost:8080/manager
      [DEBUG] (f) version = 1.1
      [DEBUG] (f) warFile = /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-20101027-132750_henning.war
      [DEBUG] – end configuration –
      [INFO] [tomcat:deploy

      {execution: default-cli}

      ]
      [INFO] Deploying war to http://localhost:8080/mywebapp
      [DEBUG] No server specified for authentication - using defaults
      [INFO] OK - Undeployed application at context path /mywebapp
      [INFO] OK - Deployed application at context path /mywebapp

      This is awkward but works ok.

      However, if running this without explicitly building the package:

      % mvn clean tomcat:deploy

      From the forked lifecycle:

      [INFO] Building war: /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-20101027-133052_henning.war
      [...]
      [DEBUG] Configuring mojo 'org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy' -->
      [DEBUG] (f) charset = ISO-8859-1
      [DEBUG] (f) contextFile = /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-null/META-INF/context.xml
      [DEBUG] (f) ignorePackaging = false
      [DEBUG] (f) mode = war
      [DEBUG] (f) packaging = war
      [DEBUG] (f) path = /mywebapp
      [DEBUG] (f) update = true
      [DEBUG] (f) url = http://localhost:8080/manager
      [DEBUG] (f) version = 1.1
      [DEBUG] (f) warFile = /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-null.war
      [DEBUG] – end configuration –
      [INFO] [tomcat:deploy

      {execution: default-cli}

      ]
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Cannot find war file: /buildfolder/mywebapp/target/mywebapp-1.0-SNAPSHOT-null.war
      [INFO] ------------------------------------------------------------------------
      [DEBUG] Trace

      So the actual deploy never picks up the information created by the buildnumber plugin in the forked lifecycle. This is supposed to be available through .

      Attachments

        Activity

          People

            olamy Olivier Lamy
            henning Henning Schmiedehausen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: