Gradle project to Maven project

Gradle project to Maven project

1 Open the file in the root directory of the Gradle project and build.gradleadd the following at the beginning of the file:

apply plugin:'java'
apply plugin:'maven'
// 即指定maven项目的groupId(artifactId默认为目录名称)
group = 'com.cas'
// 即指定maven项目的版本号
version = '3.1'
// 指定JDK(可选)
sourceCompatibility=1.8

2 Modify the gradle-wrapper.propertiesfile (skipable)
Usually gradle projects are gradle\wrapper\gradle-wrapper.propertiesconfigured in online gradle by default. When compiling, the zip file will be downloaded to the local directory first C:\Users\Administrator\.gradle\wrapper\dists, and then decompressed.

#Thu Jan 28 09:47:03 EST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
  • In order to save time, we can first download the corresponding version of the zip file from the gradle official website and put it locally, and modify the gradle-wrapper.propertiesconfiguration file
  • The default location of GRADLE_USER_HOME is the C drive user directory. In order to avoid the zip file being decompressed C:\Users\Administrator\.gradle\wrapper\dists, we can configure a location specified by ourselves in the environment variable

write picture description here

#Thu Jan 28 09:47:03 EST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=file:///D:/gradle-2.10-all.zip

3 Command prompt operation gradlew install
- open the command prompt, switch to the gradle project root directory, execute the command gradlew install
- after compilation, a buildfolder will be generated in the root directory, find build/pomsthe pom-default.xmlfiles in the directory, rename it pom.xml, and move to the project root directory Next
4 Import the project into eclipse as a maven project, and adjust the pom.xmlfile content appropriately

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325794626&siteId=291194637