从蚂蚁迁移到Maven生产100+罐子 [英] Migration from ant to Maven producing 100+ jars

查看:172
本文介绍了从蚂蚁迁移到Maven生产100+罐子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正试图将我们的构建从蚂蚁行家。项目我工作的是一个使用蚂蚁因为年龄。脚本是真正复杂的地方打造神器是具有一个明确的目录结构的zip文件。构建创造约108独特的罐子和它们打包到这个zip文件中有许多配置文件和其他第三方jar文件一起。

We are trying to migrate our builds from ant to maven. Project I am working for is using ant since ages. Scripts are real complex where build artifact is a zip file having a definite directory structure. Build creates about 108 unique jars and packages them to this zip file along with many config files and other 3rd party jars.

我们需要这个zip文件,甚至迁移的Maven后是一样的吧。我只是在Maven的学习者截至目前。我对你们的问题是,如果有使用的办法,我可以用一个pom.xml中产生更多的一个jar文件,提供了罐子的清单,包括,不包括包每个

We need this zip file to be same as now even after migration to Maven. I am just a learner on Maven as of now. My question to you guys is that if there is a way using which I can use one pom.xml to produce more that one jar file, providing list of jars and includes, excludes packages for each.

我用Google搜索,发现情况下,我们需要从一个项目,但不同的封装多个罐子,我们可以通过将一个pom.xml的每包(罐将从这个包中创建),并结合使用的所有依赖管理这样做。

I googled and found that in case we need multiple jars from one project but different packages, we can do so by placing one pom.xml at each package (jar will be created from this package) and bonding all using dependency management.

但是,这并不解决我的问题,具有100+ pom.xmls并不似乎是一个不错的主意。

But this does not solves my problem, as having 100+ pom.xmls does not seems to be a good idea.

希望我已经清楚我的问题。请建议,如果有一个出路。

Hope I have made my question clear. Please suggest if there is a way out.

推荐答案

添加到尤杜的回答这里的另一个的 Sonatype的博客上发布用图说明从一个单一的Maven项目生成多个罐子的Maven的反模式。

Adding to Udo's answer here's another Sonatype blog posting with a diagram explaining the Maven anti-pattern of generating multiple jars from a single Maven project.

两篇文章都建议采用模块化结构,你的code而不是脱钩的战斗大项目为一组相互关联的子模块的Maven的做法。

Both articles recommend adopting a modular structure to your code rather than fighting Maven's approach of decoupling large projects into a set of interrelated sub-modules.

先从看着你居然打算共享的arifacts。您的邮件表明,你实际上是发布的唯一文件是包含100+罐子和其他文件的一个大的zip文件?

Start with looking at the arifacts you actually plan to share. Your mail suggests that the only file you're actually publishing is a large zip file containing 100+ jars and other files?

您可以调用的Maven 命令行工具这个ZIP发布到Maven仓库:

You could invoke the Maven command-line tool to publish this zip to the Maven repository:

mvn deploy:deploy-file \
    -Durl=$REPO_URL \
    -DrepositoryId=$REPO_ID \
    -DgroupId=org.myorg \
    -DartifactId=myproj \
    -Dversion=1.2.3  \
    -Dpackaging=zip \
    -Dfile=myproj.zip

此方法还可以用于发布罐子和多金属氧酸盐(含有依赖)。最终你会用多金属氧酸盐的数量保持....那时它会更简单到罐子建设重组为一个子模块所淹没。

This approach can also be used to publish jars and POMs (containing dependencies). Eventually you'll be overwhelmed with the number of POMs to maintain.... AT which time it would be simpler to restructure the building of that jar into a sub-module.

这是非常难走,从一个传统的ANT构建路程。这些通常包含复杂的,定制的,难以重现构建逻辑。对于这样的项目,我建议使用的Apache常春藤来外化的第三方的依赖,并与其他项目共享工件(谁可能可以使用Maven)。

It's very difficult to walk away from a legacy ANT build. These often contain complex, custom and difficult to reproduce build logic. For such projects I recommend using Apache ivy to externalise 3rd party dependencies and share artifacts with other projects (who might be using Maven).

要为此我写了一个用于生成初始常春藤设置的基础上,罐子ant2ivy 脚本已经存在于ANT项目目录(通常致力于旁边的来源)。

To that end I wrote an ant2ivy script for generating an initial ivy setup, based on the jars that already exist in the ANT project's directory (normally committed alongside the source).

使用常春藤不会让你一个事实,即它的创建项目子模块是一个好主意了。然而,它使您能够Ant构建现代化。

Using ivy doesn't get you away from the fact that it's a good idea to create project sub-modules. However it does enable you to modernise your ANT build.

是的,有 Maven的Ant任务使用。因为他们基于Maven的2,我不使用他们,我很失望,我们还在等待他们的Maven 3更换的以太蚂蚁任务(仅可从GitHub)。常春藤仍然是整合非Maven的客户Maven仓库

Yes, there are Maven ANT tasks available. I don't use them because they based on Maven 2. I'm disappointed that we're still waiting for their Maven 3 replacement aether-ant-tasks (Only available from GitHub). Ivy is still the no1 choice for integrating non-Maven clients with a Maven repository

这篇关于从蚂蚁迁移到Maven生产100+罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆