简体   繁体   English

从从远程存储库下载的Maven War工件开始码头

[英]Start jetty with a maven war artifact downloaded from remote repository

I am trying to figgure out if it is possible to use maven to download a war artifact from a repository and start that using the jetty plugin. 我试图弄清楚是否有可能使用maven从存储库中下载战争神器,并使用码头插件来启动它。

The reason is that I would like one of my customers to automatically use the latest version of one of my projects, by fetching the build my CI server uploaded to my companies Maven repo. 原因是我希望我的一位客户通过提取上传到我的公司Maven回购库中的CI服务器来自动使用我的项目之一的最新版本。

Is this possible? 这可能吗? If yes ... how? 如果可以,怎么办?

I don't know if it's possible with the jetty plugin, but it's definitely possible with the cargo plugin. 我不知道码头插件是否可行,但货运插件绝对可行。

You can configure cargo to download a version of jetty and the war file you want to run. 您可以将货物配置为下载要运行的码头版本和战争文件。 This is the configuration that I'm using to deploy to tomcat, but it shouldn't be too different from the one needed for jetty. 这是我用来部署到tomcat的配置,但它与码头所需的配置应该没有太大不同。 We even use this way to deploy several wars in the same tomcat. 我们甚至使用这种方式在同一个tomcat中部署多个战争。

What I do is first download the war and tomcat (as dependencies), then use the dependency plugin to decompress the war file (this is just because I add some configuration files), and then tell cargo to start the web app from the folder where I have decompressed the war. 我要做的是先下载war和tomcat(作为依赖项),然后使用依赖项插件解压缩war文件(这是因为我添加了一些配置文件),然后告诉货物从该文件夹中启动Web应用程序。我解压缩了战争。

  <dependency>
     <groupId>org.apache</groupId>
     <artifactId>tomcat</artifactId>
     <version>${tomcat.version}</version>
     <type>zip</type>
  </dependency>
[...]
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>unpack war and configuration</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>war-group-id</groupId>
                        <artifactId>war-artifact-id</artifactId>
                        <version>version</version>
                        <type>war</type>
                        <overWrite>true</overWrite>
                        <outputDirectory>${project.build.directory}/war
                        </outputDirectory>
                    </artifactItem>
                </artifactItems>
                <includes>**/*</includes>
            </configuration>
        </execution>
    </executions>
</plugin>

<pluginManagement>
         <plugins>
            <plugin>
               <groupId>org.codehaus.cargo</groupId>
               <artifactId>cargo-maven2-plugin</artifactId>
               <configuration>

                  <container>
                     <containerId>tomcat6x</containerId>
                     <output>${project.build.directory}/logs/container.log</output>
                     <log>${project.build.directory}/logs/cargo.log</log>
                     <append>false</append>
                     <zipUrlInstaller>
                        <url>file:///${settings.localRepository}/org/apache/tomcat/${tomcat.version}/tomcat-${tomcat.version}.zip
                        </url>
                     </zipUrlInstaller>

                     <dependencies>
                        <dependency>
                           <groupId>com.oracle</groupId>
                           <artifactId>ojdbc6</artifactId>
                           <classpath>shared</classpath>
                        </dependency>
                     </dependencies>
                  </container>

                  <configuration>
                     <type>standalone</type>
                     <home>${project.build.directory}/tomcat6x</home>

                     <deployables>
                        <deployable>
                           <location>${project.build.directory}/war</location>
                           <type>war</type>
                           <properties>
                              <context>/context</context>
                           </properties>
                        </deployable>
                     </deployables>

                     <properties>
                        <cargo.servlet.port>${cargo.servlet.port}</cargo.servlet.port>
                        <cargo.rmi.port>${cargo.rmi.port}</cargo.rmi.port>
                        <cargo.tomcat.ajp.port>${cargo.tomcat.ajp.port}</cargo.tomcat.ajp.port>
                      </properties>

                  </configuration>
               </configuration>
            </plugin>
         </plugins>
      </pluginManagement>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM