简体   繁体   English

我如何使用 Maven 加快构建过程

[英]How I can speed up the build process using Maven

I am using Maven as build tool.我使用 Maven 作为构建工具。 Presently I am building using this command.目前我正在使用此命令进行构建。

Right click on the project > Maven clean .右键单击项目> Maven clean

After this:在这之后:

Right click on the project > Maven install右键单击项目> Maven 安装

It is taking 3 minutes for me.对我来说需要 3 分钟。 Is there any way to speed up my process?有什么办法可以加快我的进程吗?

I have already looked at this .我已经看过这个 But I did not understand this.但我不明白这一点。 Can any one hep me?有谁能帮帮我吗?

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.test.test:TEST:war:1.0.0-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.metaparadigm:json-rpc:jar -> duplicate declaration of version 1.0 @ line 323, column 15
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:tomcat-maven-plugin is missing. @ line 39, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 25, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-war-plugin is missing. @ line 18, column 11
[WARNING] 'dependencies.dependency.exclusions.exclusion.groupId' for log4j:log4j:jar is missing. @ line 356, column 18
[WARNING] 'dependencies.dependency.exclusions.exclusion.artifactId' for log4j:log4j:jar is missing. @ line 356, column 18
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Web 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] Could not transfer metadata com.Test.Test:Test:1.0.0-SNAPSHOT/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Failure to transfer com.Test.Test:Test:1.0.0-SNAPSHOT/maven-metadata.xml from scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of wso2-maven2-repository has elapsed or updates are forced. Original error: Could not transfer metadata com.Test.Test:Test:1.0.0-SNAPSHOT/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
Downloading: http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/commons-collections/commons-collections/maven-metadata.xml
[WARNING] Could not transfer metadata commons-collections:commons-collections/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Could not transfer metadata commons-collections:commons-collections/maven-metadata.xml from/to jasperreports (http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal): connection timed out to http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/commons-collections/commons-collections/maven-metadata.xml
[WARNING] The metadata C:\Documents and Settings\ITGRIDS\.m2\repository\commons-collections\commons-collections\maven-metadata-jaspersoft.xml is invalid: entity reference name can not contain character =' (position: START_TAG seen ...www.sermonillustrationlibrary.org/blocked/nospiders?mod=8819&qlvc=... @467:198) 
Downloading: http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/commons-digester/commons-digester/maven-metadata.xml
[WARNING] Could not transfer metadata commons-digester:commons-digester/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Could not transfer metadata commons-digester:commons-digester/maven-metadata.xml from/to jasperreports (http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal): connection timed out to http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/commons-digester/commons-digester/maven-metadata.xml
[WARNING] The metadata C:\Documents and Settings\ITGRIDS\.m2\repository\commons-digester\commons-digester\maven-metadata-jaspersoft.xml is invalid: entity reference name can not contain character =' (position: START_TAG seen ...www.sermonillustrationlibrary.org/blocked/nospiders?mod=8819&qlvc=... @425:221) 
Downloading: http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/commons-logging/commons-logging/maven-metadata.xml
[WARNING] Could not transfer metadata commons-logging:commons-logging/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Could not transfer metadata commons-logging:commons-logging/maven-metadata.xml from/to jasperreports (http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal): connection timed out to http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/commons-logging/commons-logging/maven-metadata.xml
[WARNING] The metadata C:\Documents and Settings\ITGRIDS\.m2\repository\commons-logging\commons-logging\maven-metadata-jaspersoft.xml is invalid: entity reference name can not contain character =' (position: START_TAG seen ...www.sermonillustrationlibrary.org/blocked/nospiders?mod=8819&qlvc=... @446:198) 
Downloading: http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/com/lowagie/itext/maven-metadata.xml
[WARNING] Could not transfer metadata com.lowagie:itext/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Could not transfer metadata com.lowagie:itext/maven-metadata.xml from/to jasperreports (http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal): connection timed out to http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/com/lowagie/itext/maven-metadata.xml
[WARNING] The metadata C:\Documents and Settings\ITGRIDS\.m2\repository\com\lowagie\itext\maven-metadata-jaspersoft.xml is invalid: entity reference name can not contain character =' (position: START_TAG seen ...www.sermonillustrationlibrary.org/blocked/nospiders?mod=8819&qlvc=... @425:221) 
Downloading: http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/jfree/jcommon/maven-metadata.xml
[WARNING] Could not transfer metadata jfree:jcommon/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Could not transfer metadata jfree:jcommon/maven-metadata.xml from/to jasperreports (http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal): connection timed out to http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/jfree/jcommon/maven-metadata.xml
[WARNING] The metadata C:\Documents and Settings\ITGRIDS\.m2\repository\jfree\jcommon\maven-metadata-jaspersoft.xml is invalid: entity reference name can not contain character =' (position: START_TAG seen ...www.sermonillustrationlibrary.org/blocked/nospiders?mod=8819&qlvc=... @443:198) 
Downloading: http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/jfree/jfreechart/maven-metadata.xml
[WARNING] Could not transfer metadata jfree:jfreechart/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Could not transfer metadata jfree:jfreechart/maven-metadata.xml from/to jasperreports (http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal): connection timed out to http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/jfree/jfreechart/maven-metadata.xml
Downloading: http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/eclipse/jdtcore/maven-metadata.xml
[WARNING] Could not transfer metadata eclipse:jdtcore/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Could not transfer metadata eclipse:jdtcore/maven-metadata.xml from/to jasperreports (http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal): connection timed out to http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/eclipse/jdtcore/maven-metadata.xml
[WARNING] The metadata C:\Documents and Settings\ITGRIDS\.m2\repository\eclipse\jdtcore\maven-metadata-jaspersoft.xml is invalid: entity reference name can not contain character =' (position: START_TAG seen ...www.sermonillustrationlibrary.org/blocked/nospiders?mod=8819&qlvc=... @435:198) 
Downloading: http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/javax/servlet/servlet-api/maven-metadata.xml
[WARNING] Could not transfer metadata javax.servlet:servlet-api/maven-metadata.xml from/to wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/): No connector available to access repository wso2-maven2-repository (scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/) of type default using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
[WARNING] Could not transfer metadata javax.servlet:servlet-api/maven-metadata.xml from/to jasperreports (http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal): connection timed out to http://escidoc1.escidoc.mpg.de:8888/archiva/repository/internal/javax/servlet/servlet-api/maven-metadata.xml
[WARNING] The artifact jstl:jstl:jar:1.1.2 has been relocated to javax.servlet:jstl:jar:1.1.2
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ Test ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 23 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ Test ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 384 source files to D:\TEST\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ Test ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Test ---
[INFO] Nothing to compile - all classes are up to date

If you're using multiple maven modules within a project, this might work for you: I'm using Maven mostly via console, so I have no experience with this under eclipse, but as of Maven 3, Maven supports parallel builds.如果您在一个项目中使用多个 Maven 模块,这可能对您有用:我主要通过控制台使用 Maven,所以我在 Eclipse 下没有这方面的经验,但从 Maven 3 开始,Maven 支持并行构建。 This feature works out of the box, but its success depends a lot on the plugins you use, as 3rd party plugins might not be designed to work that way.此功能开箱即用,但其成功在很大程度上取决于您使用的插件,因为 3rd 方插件可能并非设计为以这种方式工作。

To activate parallel builds, start maven with the -T parameter:要激活并行构建,请使用-T参数启动 maven:

mvn clean install -T 2

builds with 2 threads.用 2 个线程构建。

mvn clean install -T 2C

builds with 2 threads per CPU.每个 CPU 使用 2 个线程构建。

Maven will determine a build order and parallelize as much as possible. Maven 将确定构建顺序并尽可能并行化。

Sadly, if your project module structure is very linear, ie project A --> project B --> project C, this won't do you any good.遗憾的是,如果您的项目模块结构非常线性,即项目 A --> 项目 B --> 项目 C,这对您没有任何好处。

如果您的项目有测试用例,您可以通过以下命令跳过测试。

mvn clean install -Dmaven.test.skip=true 

just try to avoid downloading every time Execute Maven in offline mode to avoid downloading of dependencies everytime your build is run.尽量避免每次在离线模式下执行 Maven 时都下载,以避免每次构建运行时都下载依赖项。

If you are using command line you can use -o as an argument.如果您使用命令行,则可以使用 -o 作为参数。

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

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