您的位置:首页 > 其它

gradle项目转换成maven的pom.xml文件

2017-04-28 10:08 411 查看
gradle项目转换成maven的pom.xml文件

这是我build.gradle的文件:

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'spring-boot'
apply plugin: 'maven'

sourceCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'

group = 'com.101tec'
// Options for naming the JAR file
archivesBaseName = 'trackr-backend'
version = '1.0'
if(project.hasProperty('teamcity')) {
version += '-build-' + project.teamcity['build.number']
} else {
version += '-localbuild'
}

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

springBoot {
executable = true
}

dependencies {
compile "org.springframework.boot:spring-boot-starter-data-rest"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-mail"
compile "org.springframework.boot:spring-boot-starter-integration"
compile "org.springframework.boot:spring-boot-starter-security"

// not included in boot
compile "org.springframework.integration:spring-integration-mail:4.2.5.RELEASE"
compile "org.springframework.security.oauth:spring-security-oauth2:2.0.11.RELEASE"

compile "com.h2database:h2"
compile "postgresql:postgresql:9.1-901.jdbc4"
compile "org.flywaydb:flyway-core"

compile("org.xhtmlrenderer:flying-saucer-pdf-itext5:9.0.6")
compile("org.thymeleaf:thymeleaf:2.1.3.RELEASE")

compile "org.projectlombok:lombok:1.12.4"

compile "org.glassfish:javax.json:1.0"

testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile("org.echocat.jomon:testing:1.4.3") {
exclude group: "org.mockito"
}
testCompile "org.mockito:mockito-core:1.9.5"
testCompile "com.jayway.jsonpath:json-path"
testCompile "org.apache.httpcomponents:httpclient"
}

task wrapper(type: Wrapper) {
gradleVersion = '2.2'
}

task createPom << {
pom {
project {
groupId 'com.lockbur'
artifactId 'lockbur-server'
version '1.0.0-SNAPSHOT'
inceptionYear '2008'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}.writeTo("$buildDir/pom.xml")
}


你可把这个createPom的task改成任何你自己喜欢的名字,如createPom、mavenPom、testPom等,然后只需要执行

gradle clean


或者

grale build


甚至更简单的执行

gradle createPom


执行成功如图





生成后的pom文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lockbur</groupId>
<artifactId>lockbur-server</artifactId>
<version>1.0.0</version>
<inceptionYear>2008</inceptionYear>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mail</artifactId>
<version>4.2.5.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>
<version>9.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.echocat.jomon</groupId>
<artifactId>testing</artifactId>
<version>1.4.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.3.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.12.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.0.11.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: