Tomcat二进制分发zip作为maven工件

col*_*ock 12 tomcat maven

是否有公开的maven存储库,它将Apache Tomcat二进制分发ZIP作为maven工件托管(我的意思是可以通过http://tomcat.apache.org下载的文件,例如http://mirror.serversupportforum.de/apache /tomcat/tomcat-7/v7.0.28/bin/apache-tomcat-7.0.28.zip)?

目前我手动下载这些分发拉链并将它们放入我的Nexus仓库,但如果有这样的仓库我可以添加到我的POM中,我会发现它更优雅.是否有人在他们的maven构建中需要Tomcat发行版ZIP,你如何应对这个问题?

Har*_*ann 36

Tomcat 7.0.35及更高版本的发行版在Maven Central下,org.apache.tomcat:tomcat带有type ziptar.gz.

  • 接受的答案现在已经过时,这是有效的答案. (9认同)
  • 但公平地说,这些 zip 只是“纯粹”版本,没有(例如)Windows 特定的“tcnative”和“commons-deamon”二进制文件 (2认同)

car*_*ing 5

不,不存在这样的存储库或工件。

我不久前正在研究这个问题,因为我们有一个标准的 Tomcat,我们预先配置了它并与我们的产品一起提供。

我们最终从官方网站(通过 Maven)下载了 Tomcat zip,然后应用所需的更改,然后将它们推送到我们的 Nexus。

我们或多或少是这样做的:

<?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">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat</artifactId>
    <version>7.0.28-ourbranding-1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>Pre-Configured Tomcat</name>

    <properties>
        <version.tomcat>7.0.28</version.tomcat>
        <tomcat.archive.file>${project.build.directory}/apache-tomcat-${version.tomcat}.zip</tomcat.archive.file>
    </properties>

    <build>    
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.3</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>

                <executions>
                    <execution>
                        <id>repackage-tomcat</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>

                        <configuration>
                            <target>
                                <echo message="Re-packaging ${tomcat.archive.file}..." />

                                <unzip src="${basedir}/src/main/lib/apache-tomcat-${version.tomcat}.zip" dest="${project.build.directory}" />

                                <move file="${project.build.directory}/apache-tomcat-${version.tomcat}" tofile="${project.build.directory}/tomcat" />

                                <!-- Remove the default webapps -->
                                <delete dir="${project.build.directory}/tomcat/webapps/docs" />
                                <delete dir="${project.build.directory}/tomcat/webapps/manager" />
                                <delete dir="${project.build.directory}/tomcat/webapps/host-manager" />
                                <delete dir="${project.build.directory}/tomcat/webapps/examples" />

                                <!-- Patch the bin/catalina* scripts to include some of our jars in the classpath -->

                                <!-- ... Some more magic goes on here ... -->
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${tomcat.archive.file}</file>
                                    <type>zip</type>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

</project>
Run Code Online (Sandbox Code Playgroud)