简体   繁体   English

为公司环境设置内部Maven存储库

[英]Setting up an Internal Maven Repository for a corporate environment

First off, I am new to build automation and dependency management tools, so please go easy on me! 首先,我是构建自动化和依赖管理工具的新手,所以请放轻松!

I am currently working on a proof of concept project using the following assets: 我目前正在使用以下资产进行概念验证项目:

  • Spring Framework 4.0.6 Spring框架4.0.6
  • Spring Security 3.2.4 Spring Security 3.2.4
  • Spring LDAP 2.0.2 春季LDAP 2.0.2
  • Spring Batch 3.0.1 Spring Batch 3.0.1
  • Spring Security 3.2.4 Spring Security 3.2.4
  • Thymeleaf 2.1.3 胸腺2.1.3
  • Server is JBoss AS 7.2 (EAP Tech Preview) 服务器是JBoss AS 7.2(EAP技术预览)

At first I started the project by manually downloading all JARs myself from mvnrepository.com, but after a while it became very complicated and overwhelming to manage all transitive dependencies myself, so here comes the next requirement for the proof of concept: a build automation and dependency management tool. 最初,我是通过从mvnrepository.com手动下载所有JAR来启动该项目的,但是过了一会儿,我自己管理所有可传递依赖项变得非常复杂且不堪重负,因此提出了概念验证的下一个要求:构建自动化和依赖管理工具。

I work in a corporate environment, so connecting to the internet to download dependencies all the time is not an option. 我在公司环境中工作,因此无法始终连接到Internet以下载依赖项。 We have to have something internal, and then developers across the enterprise would get their dependencies from it. 我们必须有一些内部的东西,然后整个企业的开发人员都可以从中获取依赖。

We have not yet established our choice between Maven or Gradle yet. 我们尚未在Maven或Gradle之间建立选择。 Our goal is to use them both and then pick the one we prefer. 我们的目标是同时使用它们,然后选择我们喜欢的一种。 I know Gradle uses/supports Maven repositories so that's why I have added the Gradle tag in order to get Gradle users attention. 我知道Gradle使用/支持Maven存储库,所以这就是为什么我添加Gradle标签以引起Gradle用户的关注。

So, I would like to know how to set-up an internal maven repository without a repository manager like Archiva or Artifactory. 因此,我想知道如何在没有Archiva或Artifactory这样的存储库管理器的情况下建立内部Maven存储库。 Every single asset used in my corporate environment must go through a rigorous approval process so I would really like to save some time and focus on Spring and Maven or Gradle. 公司环境中使用的每一项资产都必须经过严格的批准流程,因此我真的想节省一些时间,专注于Spring和Maven或Gradle。

My proof of concept must run on a Windows environment, so my first idea is to get it to work on a Windows Server with HTTP capability (IIS?). 我的概念证明必须在Windows环境中运行,所以我的第一个想法是使它在具有HTTP功能(IIS?)的Windows Server上运行。 In my pom.xml/build.gradle, I could point to that repository instead of the Maven Central. 在我的pom.xml / build.gradle中,我可以指向该存储库而不是Maven Central。

Basically, I need to clone the Maven Central structure on my internal repository for everything related to assets listed above. 基本上,我需要在内部存储库中克隆与上面列出的资产相关的所有Maven Central结构。 Then, I would convert some internal librairies into Maven or Gradle projects and then publish them to that same repository. 然后,我将一些内部库转换为Maven或Gradle项目,然后将它们发布到同一存储库。

I tried starting a simple Maven project, and then add Spring dependencies to it, followed by the mvn compile command, but I must admit I find it quite difficult to figure out dependencies/folders I need to get from the .m2/repository folder on my local drive. 我尝试启动一个简单的Maven项目,然后向其中添加Spring依赖项,然后添加mvn compile命令,但是我必须承认,我很难弄清楚我需要从.m2 / repository文件夹中获取的依赖项/文件夹。我的本地驱动器。 Maven seems to put his own dependencies in that folder so I don't want to bring them uselessly on my internal repository. Maven似乎将自己的依赖项放在该文件夹中,所以我不想将它们无用地放在我的内部存储库中。 There is probably a better way to achieve my goal. 可能有更好的方法可以实现我的目标。

Your help and guidance would be much appreciated. 您的帮助和指导将不胜感激。

Thank you 谢谢

Charles 查尔斯

Your .m2/repository folder is a Maven repository. 您的.m2/repository文件夹一个Maven存储库。 If you're just working out a proof of concept then you can stick to that local Maven cache. 如果您只是在进行概念验证,则可以坚持使用本地Maven缓存。 It won't download anything from Maven Central unless it encounters a dependency which it can't find in the cache repo. 它不会从Maven Central下载任何内容,除非它遇到在缓存存储库中找不到的依赖项。

If it's important that you have a shareable repository, but it's just for testing/evaluation purposes, then you could even copy that cache repo to a shared drive or something and declare the repository in your pom.xml using a file:// URL. 如果拥有一个可共享的存储库很重要,但仅用于测试/评估,那么您甚至可以将该缓存存储库复制到共享驱动器或其他内容,然后使用file:// URL在pom.xml声明该存储库。

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

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