Gradle project to Maven project
1 Open the file in the root directory of the Gradle project and build.gradle
add 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.properties
file (skipable)
Usually gradle projects are gradle\wrapper\gradle-wrapper.properties
configured 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.properties
configuration 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
#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 build
folder will be generated in the root directory, find build/poms
the pom-default.xml
files 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.xml
file content appropriately