开发者

Maven Plugin error

Im a new user in maven. I have few doubts.

  1. I have some BAT files that has to executed via maven

  2. While executing my default commands, I need to echo the status like "Started first task"

  3. When the task gets failed user should get error message popup etc.,

    1. Automatic repository update through maven
    2. Maven calling ant to build *.war
    3. Copying the new created build file(*.war) to local folder with date/time
    4. Auto upload/deploy from build machine to server
    5. Testing particular URLs/products to test the site flow
    6. Sending mail regarding deployment status

Below is my example pom.xml, which trying only (a)

<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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example.maven</groupId>
  <artifactId>test&l开发者_运维知识库t;/artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>test</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.1.1</version>
        <executions>
          <execution>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <!--echo>Starting CVS Update</echo-->
        <configuration>
          <tasks>
            <exec>
              <directory>D:\</directory>
              <executable>"D:\test.bat"</executable>
              <!--failonerror="true" -->
              <!-- optional -->
              <!--workingDirectory>"cd C:\repo\projects\mcsandbox"</workingDirectory-->   
            </exec>
          </tasks>
        </configuration>
      </plugin>
    </plugins>
  </build> 
</project>


I guess this is not the expected answer but I don't think that you're on the right path and I don't see the point of using Maven the way you'd like to use it. From your description, my impression is that you aren't really adopting Maven but rather trying to insert something existing into it and, believe me, this isn't the easiest way to get started with Maven:

  • This is going to add an extra layer of complexity.
  • This requires a deeper understanding of the way maven works than "just" adopting it.
  • You're going to fight against the tool (and there are good chances that the tool will win).
  • This will generate more troubles than benefits.

I don't really know where to start so I'll just try to quickly cover your points first:

I have some BAT files that has to executed via maven

This is possible but this is not really the Maven way (depending on the logic, you should move it to Maven or keep it outside maven), and I don't think this is going to be very robust (might be wrong though). On top of that, this already requires some knowledge of the build lifecycle (where to hook things) and of plugin configuration. And from what I've seen (I do not mean to be rude), you don't have it.

While executing my default commands, I need to echo the status like "Started first task"

This is not how things work with Maven. Maven isn't procedural like Ant, Maven has conventions, Maven is declarative, Maven has a lifecycle.

When the task gets failed user should get error message popup etc.,

User? Popup? Maven is not really targeted at end users, Maven is a developer tool and what you get in case of an error is a message in a console.

Automatic repository update through maven

Do you mean a CVS update? This is not impossible but is usually not Maven's job (it's more a Continuous Integration engine task).

Maven calling ant to build *.war

This is possible using the Maven Antrun Plugin but that's not the spirit and may go against some maven rules (like one artifact per project). Also, Maven will not magically be aware of things built by Ant. Why don't you just stick with Ant?

Copying the new created build file(*.war) to local folder with date/time

Possible. But that's not how things work by default.

Auto upload/deploy from build machine to server

Maven has plugins (e.g. Cargo) that can help at doing this but you have to tell him to.

Testing particular URLs/products to test the site flow

Maven itself won't do that. But it can run (integration) tests doing that.

Sending mail regarding deployment status

That's not maven's responsibility (more a Continuous Integration engine task).


My global feeling is that you are thinking too much Ant oriented and maybe expecting too much from Maven. Maven is different, it doesn't really work the way you described, it doesn't work like Ant. My recommendation would be to either fully migrate to Maven and adopt its philosophy or to stick with your current Ant solution (and maybe consider using the Maven Ant Tasks or Ivy to leverage things such as dependency management, artifact deployment).

See also

  • How to convert from Ant to Maven (...)
  • Differences between Ant and Maven
  • Maven: The Definitive Guide
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜