这必须主要是一个新手 Maven 问题。
自从 SwingX 迁移到 Kenai,网站上到处都是警告说许多链接已损坏.. 所以这是我最好的尝试。
- 我去了https://java.net/projects/swingx/downloads/directory/releases
- 点击“SwingX 1.6.4 All - Sources”(对我来说真的是一个非直觉的、偶然的选择,但也许这是其他人理解的命名约定?)
- 这会下载 swingx-all-1.6.4-sources.jar(为什么它甚至是 jar 而不是 zip?)
但是,此源 jar 不包含 POM.XML。
所以,我从同一个链接下载了 swingx-all-1.6.4.jar,将其重命名为 .zip,膨胀了。它确实包含 META-INF\maven\org.swinglabs.swingx\swingx-all\POM.XML:
<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>
<parent>
<artifactId>swingx-project</artifactId>
<groupId>org.swinglabs.swingx</groupId>
<version>1.6.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>swingx-all</artifactId>
<packaging>jar</packaging>
<name>SwingX Complete</name>
<description>A Maven project to aggregate all modules into a single artifact.</description>
<properties>
<project.generatedDependencies>${project.generatedSourcesDirectoy}/dependencies</project.generatedDependencies>
</properties>
<!-- make the dependent swingx modules optional, since we're aggregating -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-graphics</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-core</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-mavensupport</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
<profiles>
<profile>
<id>jvnet-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>src-dependencies</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<classifier>sources</classifier>
<includeGroupIds>${project.groupId}</includeGroupIds>
<excludeArtifactIds>swingx-mavensupport</excludeArtifactIds>
<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
<outputDirectory>${project.generatedDependencies}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>add-dependencies-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.generatedDependencies}</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-dependencies-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.generatedDependencies}</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.generatedAnnotations}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
当我切换到 POM.XML 所在的上述目录并执行 mvn 安装时,它肯定会构建很多东西.. 但也说:
[INFO] 跳过不存在的资源目录 F:\swingx\swingx-all-1.6.4\META-INF\m Maven\org.swinglabs.swingx\swingx-all\src\main\resources
那是因为 src 目录不存在。这是有道理的,因为有问题的 .jar 文件据说只是二进制文件,但我希望一些 Maven 目标会下载源代码或其他东西......如果它只是二进制文件,为什么需要构建它?使困惑。
那时,我可能可以将 src 目录从第一个 zip 文件复制到第二个,或者将 pom.xml 从第二个文件复制到第一个.. 但我感觉我错过了一些东西,并且有成为一种更直接的方式。
顺便说一句,同一网页上还有第三个文件,swingx-mavensupport-1.6.4.jar
于是我下载了那个,重命名为.zip,膨胀了,找到了这个文件:META-INF\maven\org.swinglabs.swingx\swingx-mavensupport\POM.XML:
<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>
<parent>
<artifactId>swingx-project</artifactId>
<groupId>org.swinglabs.swingx</groupId>
<version>1.6.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>swingx-mavensupport</artifactId>
<name>SwingX Maven Support</name>
</project>
更改到它的目录并运行 mvn.install
但是,这抱怨缺少大量文件。
我一定是搞错了。什么是正确的方法?