Groovy 打包
时间: 2023-06-21 18:11:47 浏览: 72
打包 Groovy 项目可以使用 Maven 或 Gradle。
使用 Maven 打包:
1. 在项目根目录下创建一个 pom.xml 文件。
2. 在 pom.xml 文件中添加以下代码:
```
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example-project</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<dependencies>
<!-- add your dependencies here -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.2-01</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
```
3. 在命令行中进入项目根目录,执行以下命令:
```
mvn clean package
```
4. Maven 将会打包生成 jar 文件,位于 target 目录下。
使用 Gradle 打包:
1. 在项目根目录下创建一个 build.gradle 文件。
2. 在 build.gradle 文件中添加以下代码:
```
plugins {
id 'groovy'
}
repositories {
mavenCentral()
}
dependencies {
// add your dependencies here
}
jar {
manifest {
attributes 'Main-Class': 'com.example.Main'
}
}
```
3. 在命令行中进入项目根目录,执行以下命令:
```
gradle build
```
4. Gradle 将会打包生成 jar 文件,位于 build/libs 目录下。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)