# Java构建管理
# Flag
Maven, Ivy, Grape, Gradle, Buildr, SBT, Leiningen, ant
- https://github.com/kordamp/gm (opens new window)
- https://github.com/gradle/gradle (opens new window)
- https://github.com/johnrengelman/shadow (opens new window)
- 自定义运行时映像 https://github.com/beryx (opens new window)
- 创建支持包重定位 https://github.com/johnrengelman/shadow (opens new window)
- https://github.com/Omico/Gradm (opens new window)
- https://github.com/gdubw/gng (opens new window)
- https://github.com/gmazzo/gradle-buildconfig-plugin (opens new window)
- https://github.com/autonomousapps/dependency-analysis-gradle-plugin (opens new window)
- https://github.com/michel-kraemer/gradle-download-task (opens new window)
- https://github.com/gradle-nexus (opens new window)
- https://github.com/gradlex-org (opens new window)
- https://github.com/package-url (opens new window)
- https://github.com/sbt/sbt (opens new window)
- https://github.com/jbangdev (opens new window)
- https://github.com/sormuras/bach (opens new window)
- https://redmine.z2-environment.net (opens new window)
- 增量构建 https://github.com/sakerbuild/saker.build (opens new window)
- https://github.com/sakerbuild/saker.java.compiler (opens new window)
- 动态编译 https://github.com/janino-compiler/janino (opens new window)
- 打包 https://github.com/shevek/jarjar (opens new window)
- https://github.com/codehaus-plexus/plexus-compiler (opens new window)
- https://github.com/eclipse/eclipse.jdt.core (opens new window)
- https://www.jetbrains.com/help/idea/java-compiler.html (opens new window)
- https://github.com/alwans/code-diff (opens new window)
- https://github.com/policeman-tools/forbidden-apis (opens new window)
- 消除NullPointerException https://github.com/uber/NullAway (opens new window)
- 静态类型检查 https://github.com/google/error-prone (opens new window)
- https://github.com/TouK/sputnik (opens new window)
- https://github.com/soot-oss/soot (opens new window)
- https://github.com/wala (opens new window)
- https://github.com/plast-lab/doop-mirror (opens new window)
- https://github.com/souffle-lang/souffle (opens new window)
- https://github.com/spotbugs (opens new window)
- https://github.com/pascal-lab/Tai-e (opens new window)
- https://github.com/find-sec-bugs/find-sec-bugs (opens new window)
- https://github.com/jimbethancourt/RefactorFirst (opens new window)
- JAR文件分析 https://github.com/kordamp/jarviz (opens new window)
- 持续交付事件的通用规范 https://github.com/cdevents (opens new window)
- https://github.com/topics/classloader (opens new window)
- https://github.com/technomancy/leiningen (opens new window)
- https://java-source.net (opens new window)
可执行文件打包
- https://jar-download.com (opens new window)
- https://github.com/izpack/izpack (opens new window)
- https://sourceforge.net/projects/launch4j (opens new window)
- https://github.com/poidasmith/winrun4j (opens new window)
- https://sourceforge.net/projects/vainstall (opens new window)
- https://github.com/BrunoReX/jsmooth (opens new window)
- https://sourceforge.net/projects/packlet (opens new window)
- https://sourceforge.net/projects/jpackit (opens new window)
- https://sourceforge.net/projects/one-jar (opens new window)
- https://sourceforge.net/projects/autojar (opens new window)
- https://sourceforge.net/projects/mjar (opens new window)
- 把Java应用程序安装成一个Windows NT服务或Unix Daemon (opens new window)
- https://exe4j.apponic.com (opens new window)
- JavaFx应用打包 (opens new window)
- 如何将 JavaFX 的程序打包成 exe,更进一步制作一个windows 安装程序? (opens new window)
持续集成
- https://github.com/jenkinsci (opens new window)
- Jenkins前身 https://github.com/hudson (opens new window)
- https://www.jetbrains.com/zh-cn/teamcity (opens new window)
- https://www.atlassian.com/zh/software/bamboo (opens new window)
- https://github.com/technomancy/leiningen (opens new window)
- https://github.com/ansible/ansible (opens new window)
- 自动化部署 https://github.com/dreamans/syncd (opens new window)
- https://github.com/jitpack/jitpack.io (opens new window)
- https://github.com/jreleaser (opens new window)
# Ant
Apache Ant核心
包 | 描述 |
---|---|
org.apache.tools.ant | 它是一个核心程序包, 其中包含核心类和接口。 |
org.apache.tools.ant.attribute | 该程序包包含用于处理属性的类。 |
org.apache.tools.ant.dispatch | 它包含调度的类和接口。 |
org.apache.tools.ant.filters | 它由过滤器类和接口组成。 |
org.apache.tools.ant.filters.util | 它包含用于过滤器的实用程序类。 |
org.apache.tools.ant.helper | 包含帮助程序类。 |
org.apache.tools.ant.input | 包含输入类和接口。 |
org.apache.tools.ant.launch | 包含类。 |
org.apache.tools.ant.loader | 包含类和接口。 |
org.apache.tools.ant.property | 包含用于ant属性的辅助类。 |
Apache Ant核心任务
包 | 描述 |
---|---|
org.apache.tools.ant.taskdefs | 它包含核心任务类和接口。 |
org.apache.tools.ant.taskdefs.compilers | 它包含用于编译器的类和接口。 |
org.apache.tools.ant.taskdefs.condition | 它包含条件的类和接口。 |
org.apache.tools.ant.taskdefs.cvslib | 包含cvs的类。 |
org.apache.tools.ant.taskdefs.email | 电子邮件任务类和界面组。 |
org.apache.tools.ant.taskdefs.launcher | 与启动器相关的类。 |
org.apache.tools.ant.taskdefs.rmic | 远程方法编译器类。 |
Apache Ant核心类型
包 | 描述 |
---|---|
org.apache.tools.ant.types | 核心类型的根包。 |
org.apache.tools.ant.types.mappers | 包含映射器类和接口。 |
org.apache.tools.ant.types.resolver | 包含解析器类和接口。 |
org.apache.tools.ant.types.resources | 资源类组。 |
org.apache.tools.ant.types.resources.comparator | 资源比较器类和接口。 |
org.apache.tools.ant.types.resources.selectors | 它包含资源选择器类和接口。 |
org.apache.tools.ant.types.selectors | 它是选择器的根目录。 |
org.apache.tools.ant.types.selectors.modifiedselector | 它包含修改后的选择器类和接口。 |
org.apache.tools.ant.types.spi | 与串行外围设备接口有关的类。 |
Apache Ant可选任务
包 | 描述 |
---|---|
org.apache.tools.ant.taskdefs.optional | 它包含可选任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.ccm | 它包含ccm任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.clearcase | 它包含clearcase任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.depend | 它包含依赖任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.depend.constantpool | 它包含constaint任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.ejb | 它包含ejb任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.extension | 它包含扩展任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.extension.resolvers | 它包含解析程序任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.i18n | 它包含i18n任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.image | 它包含图像任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.j2ee | 它包含j2ee任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.javacc | 它包含javacc task的类和接口。 |
org.apache.tools.ant.taskdefs.optional.javah | 它包含javah任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.jdepend | 它包含jdepend任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.jlink | 它包含jlink任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.jsp | 它包含jsp任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.jsp.compilers | 它包含编译器任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.junit | 它包含junit任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.junitlauncher | 它包含junitlauncher任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.native2ascii | 它包含native2ascii任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.net | 它包含网络任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.pvcs | 它包含pvcs任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.script | 它包含脚本任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.sos | 与SourceOffSite源代码控制系统一起使用的Ant任务。 |
org.apache.tools.ant.taskdefs.optional.sound | 它包含声音任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.splash | 它包含启动任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.ssh | 它包含ssh任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.testing | 它包含测试任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.unix | 它包含Unix任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.vss | 它包含vss task的类和接口。 |
org.apache.tools.ant.taskdefs.optional.windows | 它包含Windows任务的类和接口。 |
org.apache.tools.ant.taskdefs.optional.xz | 它包含xz任务的类和接口。 |
Apache Ant可选类型
包 | 描述 |
---|---|
org.apache.tools.ant.types.optional | 可选的类型类和接口。 |
org.apache.tools.ant.types.optional.depend | 依赖类型类和接口。 |
org.apache.tools.ant.types.optional.image | 包含图像类型类和接口。 |
org.apache.tools.ant.types.optional.xz | 包含xz类型类。 |
Apache Ant实用程序
包 | 描述 |
---|---|
org.apache.tools.ant.util | 组织util类和接口。 |
org.apache.tools.ant.util.depend | 一组依赖类。 |
org.apache.tools.ant.util.depend.bcel | Bcel实用程序类和接口。 |
org.apache.tools.ant.util.facade | 外观类和接口。 |
org.apache.tools.ant.util.java15 | Java15类。 |
org.apache.tools.ant.util.optional | 可选的类和接口。 |
org.apache.tools.ant.util.regexp | 处理正则表达式的类。 |
其他
包 | 描述 |
---|---|
org.apache.tools.bzip2 | 由bzip类和接口组成。 |
org.apache.tools.mail | 包含邮件类。 |
org.apache.tools.tar | 组织课程以处理tar。 |
org.apache.tools.zip | 邮编类和子类。 |
# Maven
- https://maven.apache.org (opens new window)
- https://github.com/ibofine/mavenbook (opens new window)
- Maven详细教程 (opens new window)
- 史上最全的maven的pom.xml文件详解 (opens new window)
- Maven - 花落花开 (opens new window)
- maven手册 https://github.com/inuter/Maven-Notebook (opens new window)
仓库
- http://mvnrepository.com (opens new window)
- https://central.sonatype.com (opens new window)
- https://search.maven.org (opens new window)
- https://www.mvncenter.com (opens new window)
- https://nexus.pentaho.org (opens new window)
- https://public.nexus.pentaho.org (opens new window)
- JFrog Bintray https://github.com/bintray (opens new window)
- https://packages.aliyun.com (opens new window)
- https://www.codeyyy.com (opens new window)
插件
- maven-jar-plugin 默认的打包插件,用来打普通的project JAR包;
- maven-shade-plugin 用来打可执行JAR包,也就是所谓的fat JAR包;
- maven-assembly-plugin 支持自定义的打包结构,也可以定制依赖项等。
- 插件大全 https://github.com/mojohaus (opens new window)
- https://github.com/apache/maven-wagon (opens new window)
- https://github.com/takari/maven-wrapper (opens new window)
- https://github.com/mathieucarbou/license-maven-plugin (opens new window)
- https://github.com/pentaho/maven-parent-poms (opens new window)
- https://github.com/mojohaus/build-helper-maven-plugin (opens new window)
- https://github.com/maven-download-plugin (opens new window)
- 构建自动清理 https://github.com/castor-software/depclean (opens new window)
- 模块化 https://github.com/moditect/layrry (opens new window)
- https://github.com/sormuras/modules (opens new window)
- 检测旧版API https://github.com/gaul/modernizer-maven-plugin (opens new window)
- https://github.com/mojohaus/build-helper-maven-plugin (opens new window)
- 排序 https://github.com/Ekryd/sortpom (opens new window)
- 格式化 https://github.com/revelc/formatter-maven-plugin (opens new window)
- https://github.com/maveniverse/mima (opens new window)
- 集成Rust https://github.com/questdb/rust-maven-plugin (opens new window)
Maven镜像
打包编译到Docker部署
- https://github.com/spotify/docker-maven-plugin (opens new window)
- https://github.com/spotify/dockerfile-maven (opens new window)
- https://github.com/khanhas/spicetify-cli (opens new window)
- https://github.com/fabric8io/docker-maven-plugin (opens new window)
- https://github.com/GoogleContainerTools/jib (opens new window)
- https://github.com/lazyboyl/docker-develop-maven-plugin (opens new window)
- 利用Maven打包docker镜像上传docker容器 (opens new window)
- Maven插件构建Docker镜像 (opens new window)
- dockerfile-maven-plugin构建Docker镜像 (opens new window)
- 使用maven插件dockerfile-maven-plugin进行镜像的build和push (opens new window)
- 如何构建SpringBoot应用的Docker镜像 (opens new window)
- https://github.com/hariko1991/docker-demo (opens new window)
- https://github.com/gaochao-ncp/spring-boot-docker-example (opens new window)
打包部署到服务器
- https://github.com/apache/tomcat-maven-plugin (opens new window)
- https://mvnrepository.com/artifact/org.apache.tomcat.maven (opens new window)
- https://github.com/codehaus-cargo (opens new window)
- 使用Maven插件wagon-maven-plugin自动化部署 (opens new window)
- java项目自动部署方案(1):wagon-maven-plugin (opens new window)
- Jenkins+Maven+GitHub自动部署项目到远程服务器 (opens new window)
- idea部署maven项目到远程tomcat (opens new window)
- maven远程部署war包到tomcat8服务器 (opens new window)
- 如何利用maven插件部署项目到远程运行环境 (opens new window)
- 使用site-maven-plugin在github上搭建公有仓库 (opens new window)
- Maven中央仓库项目上传指南 (opens new window)
# Maven命令
maven 命令的格式为 mvn [plugin-name]:[goal-name]
-D
指定参数,如 -Dmaven.test.skip=true 跳过单元测试;`-P
指定 Profile 配置,可以用于区分环境;`-e
显示maven运行出错的信息-o
离线执行命令,即不去远程仓库更新包-X
显示maven允许的debug信息-U
强制去远程更新snapshot的插件或依赖,默认每天只更新一次
- 创建maven项目:
mvn archetype:create
- 指定 group:
-DgroupId=packageName
- 指定 artifact:
-DartifactId=projectName
- 创建web项目:
-DarchetypeArtifactId=maven-archetype-webapp
- 创建maven项目:
mvn archetype:generate
- 验证项目是否正确:
mvn validate
- maven 打包:
mvn package
- 只打jar包:
mvn jar:jar
- 生成源码jar包:
mvn source:jar
- 产生应用需要的任何额外的源代码:
mvn generate-sources
- 编译源代码:
mvn compile
- 编译测试代码:
mvn test-compile
- 运行测试:
mvn test
- 运行检查:
mvn verify
- 清理maven项目:
mvn clean
- 生成eclipse项目:
mvn eclipse:eclipse
- 清理eclipse配置:
mvn eclipse:clean
删除.settings
、.project
、.classpath
、.factorypath
- 生成idea项目:
mvn idea:idea
- 安装项目到本地仓库:
mvn install
- 发布项目到远程仓库:
mvn:deploy
- 在集成测试可以运行的环境中处理和发布包:
mvn integration-test
- 显示maven依赖树:
mvn dependency:tree
- 显示maven依赖列表:
mvn dependency:list
- 下载依赖包的源码:
mvn dependency:sources
web项目相关命令
- 启动tomcat:
mvn tomcat:run
- 启动jetty:
mvn jetty:run
- 运行打包部署:
mvn tomcat:deploy
- 撤销部署:
mvn tomcat:undeploy
- 启动web应用:
mvn tomcat:start
- 停止web应用:
mvn tomcat:stop
- 重新部署:
mvn tomcat:redeploy
- 部署展开的war文件:
mvn war:exploded tomcat:exploded
# 使用本地jar包
将jar包安装到本地Maven仓库中
mvn install:install-file -Dfile=C:\Users\xx\Desktop\test-1.0-SNAPSHOT.jar -DgroupId=com.bajins -DartifactId=test -Dversion=1.0 -Dpackaging=jar
-Dfile
:指定要安装的文件的路径。-DgroupId
:指定项目的groupId。-DartifactId
:指定项目的artifactId。-Dversion
:指定项目的版本号。-Dpackaging
:指定项目的打包类型。
- Eclipse ->
File
->Import
->Maven
->Install or deply an artifact to a Maven reposeitory
->Next
->Install artifact
- Eclipse -> 项目右键 ->
Maven
->Update Project
引用本地jar包,非引用本地Maven仓库
<dependency>
<groupId>com.xxx</groupId>
<artifactId>xxx-sdk</artifactId>
<version>${xxxSDK.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/xxxSDK.jar</systemPath>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 加以下配置 打包时包括引用的本地jar -->
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<!-- 拷贝指定文件夹下的文件到指定目录 -->
<directory>${project.basedir}/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
<filtering>false</filtering>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
<version>2.1.1</version>
</plugin>
# Maven私服搭建
- https://github.com/sonatype (opens new window)
- https://github.com/sonatype-nexus-community (opens new window)
- https://help.sonatype.com/repomanager3/download (opens new window)
- docker 快速搭建maven私服并上传jar包 (opens new window)
- Maven部署jar包到远程仓库 (opens new window)
- 在 Docker 搭建 Maven 私有库 (opens new window)
- 利用 Docker 搭建 Nexus 仓库私服 (opens new window)
- docker 安装 maven 私有库 nexus3 (opens new window)
- https://github.com/apache/archiva (opens new window)
- https://github.com/jfrog (opens new window)
- Artifactory https://jfrog.com/open-source (opens new window)
- 私有仓库maven-pulic代理的远程仓库: