我想知道,如何创建自己的依赖关系,以便在其他项目中使用我的代码。
我在听教程。我尝试用Maven项目创建简单类的项目。我做了干净的包装。创建了github存储库。添加了我的项目与“目标”包。在pom.xml中,我添加了
<properties>
<java.version>1.8</java.version>
<github.global.server>github</github.global.server>
<github.maven-plugin>0.12</github.maven-plugin>
</properties>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>${github.maven-plugin}</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<branch>refs/heads/mvn-repo</branch>
<includes><include>**/*</include></includes>
<repositoryName>GITHUB_NAME_REPOSITORY</repositoryName>
<repositoryOwner>MY_GITHUB_NICKNAME</repositoryOwner>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>在.m2目录根目录中创建settings.xml之后:
<settings>
<servers>
<server>
<id>github</id>
<username>[username]</username>
<password>[password]</password>
</server>
</servers>
</settings>再次做了clean+package和推到github。
在尝试使用依赖项之后-没有找到。在github回购公司没有mvn-回购分支机构
发布于 2019-08-23 14:44:26
我还没有使用新的GitHub存储库,但是到目前为止,什么工作得很好:
mvn install ->工件将安装在本地Maven存储库中,并且可以由同一台机器上的任何其他项目引用。mvn deploy到Maven Central。有关配置和所涉步骤的更多信息,请参见文档。mvn deploy到您自己的Maven Repository管理器(如尼克斯 )(相应地配置distributionManagement )也就是说,在所有3种情况下使用您自己的Maven Repository并定义一个最佳做法是一个单群。
来自Maven默认生命周期文档:
package :将编译后的代码打包成可发行的格式,例如JAR。 install :将包安装到本地存储库中,以便在本地其他项目中用作依赖项。 deploy:在集成或发布环境中完成,将最终包复制到远程存储库,以便与其他开发人员和项目共享。
https://stackoverflow.com/questions/57628417
复制相似问题