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

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>



  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值