Given the three POM files:
- C depends on B.
- B inherits from A.
- I can build A and B
- C cannot be built due to its dependence on B.
The full source code and assembly output are provided below for your review.
Here is the POM:
<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>com.foo</groupId> <artifactId>A</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <name>A</name> <repositories> <repository> <id>foo releases</id> <name>libs-releases-local</name> <layout>default</layout> <url>http://foo.net/artifactory/libs-releases-local</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.eclipse.swt</groupId> <artifactId>swt</artifactId> <classifier>${swt.classifier}</classifier> <version>3.6.1</version> </dependency> </dependencies> <profiles> <profile> <id>windows-x86</id> <properties> <swt.classifier>win32-x86</swt.classifier> </properties> </profile> </profiles> </project>
Here is the B POM:
<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> <parent> <groupId>com.foo</groupId> <artifactId>A</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../A</relativePath> </parent> <artifactId>B</artifactId> <packaging>jar</packaging> <name>B</name> <profiles> <profile> <id>windows-x86</id> <properties> <swt.classifier>win32-x86</swt.classifier> </properties> </profile> </profiles> </project>
Here is the C POM:
<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>com.foo</groupId> <artifactId>C</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>C</name> <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>B</artifactId> <version>${project.version}</version> </dependency> </dependencies> </project>
Here is the build result from C:
------------------------------------------------------------------------ Building C task-segment: [install] ------------------------------------------------------------------------ [compiler:compile] Nothing to compile - all classes are up to date Downloading: http://foo.net/artifactory/libs-releases-local/org/eclipse/swt/swt/3.6.1/swt-3.6.1-${swt.classifier}.jar [WARNING] Unable to get resource 'org.eclipse.swt:swt:jar:${swt.classifier}:3.6.1' from repository foo releases (http://foo.net/artifactory/libs-releases-local): Error transferring file: foo.net Downloading: http://repo1.maven.org/maven2/org/eclipse/swt/swt/3.6.1/swt-3.6.1-${swt.classifier}.jar Unable to find resource 'org.eclipse.swt:swt:jar:${swt.classifier}:3.6.1' in repository central (http://repo1.maven.org/maven2) ------------------------------------------------------------------------ [ERROR]BUILD ERROR ------------------------------------------------------------------------ Failed to resolve artifact. Missing: ---------- 1) org.eclipse.swt:swt:jar:${swt.classifier}:3.6.1
I know this problem is related to https://issues.apache.org/jira/browse/MNG-3228 , but I'm not sure how to fix it. Please, help!
UPDATE
It helped to add a classifier to B. Now C builds while the repository contains only the B jar file. If I upload the B POM file along with the JAR to the repository, C will fail with the error above ( ${swt.classifier }). Any ideas?
source share