繁体   English   中英

Maven父构建无法找到本地构建的子工件

[英]Maven parent build unable to find locally built child artifact

我有一个类似于以下的目录结构(遵循这里的建议:

parent-dir
   pom.xml
   core-dir
       |
       ------pom.xml
   web-service-dir
       |
       ------pom.xml

这是我的主要(parent-dir)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>ca.ubc</groupId>
    <artifactId>iamWebServices</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <name>${project.artifactId}</name>
    <url>http://maven.apache.org</url>
    <properties>
    <project_home>${project.dir}</project_home>
    </properties>


<modules>
        <module>core</module>
        <module>webService</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <!-- Inter-Module dependencies -->
            <dependency>
                <groupId>ca.ubc.iam.core</groupId>
                <artifactId>iamCore</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

这是我的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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>ca.ubc</groupId>
        <artifactId>iamWebServices</artifactId>
        <version>1.0</version>
        <relativePath>..</relativePath>
    </parent>

    <artifactId>iamCore</artifactId>
    <groupId>ca.ubc.iam.core</groupId>
    <packaging>jar</packaging>
    <name>${project.artifactId}</name>
    <version>1.0</version>
    <properties>
        <target.dir>target</target.dir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>cryptix</groupId>
            <artifactId>cryptix</artifactId>
            <version>3.2.0</version>
            <scope>provided</scope>
        </dependency>
<!--        <dependency>
            <groupId>libmd5</groupId>
            <artifactId>md5tools</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>libojdbc6</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>1.0.0</version>
        </dependency> -->

    <dependency>
        <groupId>local.jcrypt</groupId>
        <artifactId>jcrypt</artifactId>
        <scope>system</scope>
        <version>xx</version>
        <systemPath>${project.basedir}/src/lib/jcrypt.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>local.md5tools</groupId>
        <artifactId>md5tools</artifactId>
        <version>xx</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/src/lib/md5tools.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>local.randomPasswordGenerator</groupId>
        <artifactId>randomPasswordGenerator</artifactId>
        <version>1.0.1</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/src/lib/RandomPasswordGenerator.jar</systemPath>
    </dependency> 
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.4.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.0</version>
        </dependency>
        <!-- <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> 
            <version>11.2.0.3</version> <scope>system</scope> <systemPath>${project.basedir}/src/lib/ojdbc6.jar</systemPath> 
            </dependency> -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>iamcore</finalName>
        <outputDirectory>${basedir}/${target.dir}/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
            </plugin>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <!-- copy-dependency plugin -->
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-dependency-plugin</artifactId>
                                    <versionRange>[1.0.0,)</versionRange>
                                    <goals>
                                        <goal>copy-dependencies</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

最后,这是我的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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>ca.ubc</groupId>
        <artifactId>iamWebServices</artifactId>
        <version>1.0</version>
        <relativePath>..</relativePath>
    </parent>

    <groupId>ca.ubc.iamws</groupId>
    <artifactId>iamws</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>
    <name>${project.artifactId}</name>


    <properties>
        <jersey.version>2.5.1</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
        <codi.version>1.0.5</codi.version>
        <target.dir>target</target.dir>
    </properties>

    <repositories>
        <repository>
            <id>codelds</id>
            <url>https://code.lds.org/nexus/content/groups/main-repo</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>ca.ubc.iam.core</groupId>
            <artifactId>iamCore</artifactId>
            <version>1.0</version>
            </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope></scope>
        </dependency>
        <dependency>
            <groupId>cryptix</groupId>
            <artifactId>cryptix</artifactId>
            <version>3.2.0</version>
        </dependency>
        <dependency>
            <groupId>local.jcrypt</groupId>
            <artifactId>jcrypt</artifactId>
            <version>1.0.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/jcrypt.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>local.md5tools</groupId>
            <artifactId>md5tools</artifactId>
            <version>1.0.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/md5tools.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>local.randomPasswordGenerator</groupId>
            <artifactId>randomPasswordGenerator</artifactId>
            <version>1.0.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/RandomPasswordGenerator.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.1</version>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <!-- jackson dependencies for pojo/json support -->
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <!-- end jackson deps -->
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-processing</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.0</version>
        </dependency>
        <!-- junit test and jersey client features -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
        <!-- Weld/CDI Begin -->
        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core</artifactId>
            <version>2.1.2.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>iamws</finalName>
        <outputDirectory>${basedir}/${target.dir}/classes</outputDirectory>
        <testOutputDirectory>${basedir}/${target.dir}/test-classes</testOutputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <packagingExcludes>src/test/*</packagingExcludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <!-- copy-dependency plugin -->
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-dependency-plugin</artifactId>
                                    <versionRange>[1.0.0,)</versionRange>
                                    <goals>
                                        <goal>copy-dependencies</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

    <profiles>
        <profile>
            <id>eclipse-folders</id>
            <properties>
                <target.dir>target-eclipse</target.dir>
            </properties>
        </profile>
    </profiles>
</project>

当我从父目录构建并发出如下命令行时:

mvn install

我收到一个找不到该jar文件的错误。 我究竟做错了什么?

[ERROR] Failed to execute goal on project iamws: Could not resolve dependencies for project ca.ubc.iamws:iamws:war:1.0: Could not find artifact ca.ubc.iam.core:iamCore:jar:1.0 in jboss-public-repository-group (https://repository.jboss.org/nexus/content/repositories/releases/) -> [Help 1]

看起来它正在尝试从外部存储库下载本地构建的jar文件,但我不知道如何解决该问题?

首先,您似乎具有与模块名称不同的artifactId。 虽然不是问题,但它使事情看起来有点困难:)

发行mvn install ,它将首先尝试解析pom文件以为项目生成一些有效的POM文件,这意味着在构建任何模块之前,都需要解析父pom。

在父级中,您依赖于iamcore模块,但尚未构建它,这就是它失败的原因。

从父级删除依赖项,然后将其放入iamwebservice

暂无
暂无

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

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