是否有maven插件来安装项目?

时间:2013-08-22 14:10:09

标签: maven plugins installer install

我是Maven的新手,我刚刚阅读了Sonatype指南,我对maven提供的功能非常满意。我创建了一个应用程序分发(.zip)包,我想知道是否有一种方法可以将maven用作安装程序。 我不是指maven在本地存储库中进行的安装,我的意思通过以下示例解释:

我有一个包含jar文件,.sql脚本,/ lib和一个pom.xml文件的文件夹。 我希望maven在执行“mvn”命令时为我安装这个项目。 所以maven应该:      - 将jar文件复制到$ {TOMCAT_HOME} \ webapps目录中。      - 在postgresql数据库上执行sql脚本      - 复制c:\ myLibs中的\ lib目录      - 等等 在这个过程中它还应该进行一些检查(例如在系统上设置TOMCAT_HOME?打开Postgres?等等)并向用户询问一些参数(例如“安装将重置数据库你想继续吗?”或者“请插入数据库密码:”。

是否有maven插件有助于这样做?如果没有,是否有专门的应用程序maven专门创建“安装程序”?它是标准的,广泛的应用吗? 非常感谢你的帮助!

1 个答案:

答案 0 :(得分:0)

添加到您的pom

 <distributionManagement>
                <repository>
                        <id>sonatype.internal</id>
                        <name>Internal Release Repository</name>
                        <url>http://sonatypeAddress:sonatypePort/context</url>
                </repository>
 </distributionManagement>

插件部分:

              <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-scm-plugin</artifactId>
                        <configuration>
                                <tag>${build.tag}</tag>
                                <username>${scm.username}</username>
                                <password>${scm.password}</password>
                        </configuration>
               </plugin>
  • antrun plugin - 制作你想要的东西。

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <dependencies>
                    ...
                </dependencies>
                <executions>                    
    
                    <execution>
                        <id>install</id>
                        <phase>install</phase>
                        <configuration>
                            <target>
                                                         <delete dir="mylocalization" />
                                <copy file="target/out/my.jar" tofile="mylocalication" />
    
                                <copy todir="mylocalization/doc">
                                    <fileset dir="target/doc" />
                                </copy>
                                <copy todir="mylocalization/somethingMore">
                                    <fileset dir="target/more">
                                        <include name="a.txt" />
                                        <include name="b*.txt" />
                                    </fileset>
                                </copy>
    
    
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
    
                </executions>
            </plugin>
    
  • 另请参阅maven-wagon