maven build with my local-module artifactory (library)



我创建了一个名为app-service的项目,它使用核心模块(app-core(。我通过驻留在项目基目录中的<systemPath>将此核心模块作为 maven 依赖项包含在我的项目中。

<dependency>
    <groupId>app-group</groupId>
    <artifactId>app-core</artifactId>
    <version>${project.version}</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/app-core-0.1.1-SNAPSHOT.jar</systemPath>
</dependency>

我配置专家并运行目标

mvn clean package install
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.733 s
[INFO] Finished at: 2017-04-05T12:27:46+05:30
[INFO] Final Memory: 29M/533M
[INFO] ------------------------------------------------------------------------

BUILD SUCCESS $CLASSPATH不包含 app-core.jar 文件后,预计它包括 maven <dependencies> 中列出的所有依赖项

我想将此应用核心模块用作compile范围。当我尝试这个时,它会提示错误

[ERROR] 'dependencies.dependency.systemPath' for app-group:app-core:jar must be omitted. This field may only be specified for a dependency with system scope. @ line 71, column 25

注意:出于安全目的,我不在公共存储库上传此app-core。我想通过项目基目录使用,因为我需要在Heroku上部署相同的内容。


更新

我用谷歌搜索了一个安装本地存储库的插件。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.5.2</version>
    <executions>
        <execution>
            <id>install-external</id>
            <phase>clean</phase>
            <configuration>
                <file>${project.basedir}/app-core-0.1.1-SNAPSHOT.jar</file>
                <repositoryLayout>default</repositoryLayout>
                <groupId>app-group</groupId>
                <artifactId>app-core</artifactId>
                <version>${project.version}</version>
                <packaging>jar</packaging>
                <generatePom>true</generatePom>
            </configuration>
            <goals>
                <goal>install-file</goal>
            </goals>
        </execution>
    </executions>
</plugin>

但结果是一样的...

您应该按照本指南将非托管依赖项添加到 Heroku 上的 Maven 项目。要总结指南,请运行:

mvn deploy:deploy-file -Durl=file:///path/to/app-group/app-core/ -Dfile=app-core-1.0.jar -DgroupId=app-group -DartifactId=app-core -Dpackaging=jar -Dversion=1.0

然后将此存储库添加到您的pom.xml

<repository>
  <id>project.local</id>
  <name>project</name>
  <url>file:${project.basedir}/repo</url>
</repository>

然后使用依赖项 i 你的pom.xml

<dependency>
  <groupId>app-group</groupId>
  <artifactId>app-core</artifactId>
  <version>1.0</version>
</dependency>
我认为

错误是告诉您删除设置依赖项的部分内容。尝试省略其中的某些部分,例如:

<systemPath>${project.basedir}</systemPath>

..并从那里开始工作。

编辑:

我也会尝试最有限的信息量。

<dependency>
    <groupId>app-group</groupId>
    <artifactId>app-core</artifactId>
    <version>${project.version}</version>
</dependency>

尝试更改项目版本。 我遇到了 maven 依赖项无法从存储库中提取的问题,因为 pom.xml 编写不正确。我最终解决它们的方法是不断尝试不同的方法来编写依赖项,直到它真正正确地拉出它。

最新更新