gradle initでpom.xmlをbuild.gradleに変換

```gradle init``` するディレクトリに ```pom.xml``` が存在するとこれを基に```build.gradle```や```settings.xml```に変換できる。ただログに```Maven to Gradle conversion is an incubating feature.```とある通り過信は禁物の機能だろうと思われる。


# 環境
Gradle v8.3

# ソースコードなど

[Spring Initializr](https://start.spring.io/) でベースとなる適当な```pom.xml```を作成する。

```xml:pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.1.3</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>17</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

```

```gradle init```を実行する。実行時のログは以下の通り。

```
>gradle init
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

Found a Maven build. Generate a Gradle build from this? (default: yes) [yes, no] yes

Select build script DSL:
  1: Kotlin
  2: Groovy
Enter selection (default: Kotlin) [1..2] 2

Generate build using new APIs and behavior (some features may change in the next minor release)? (default: no) [yes, no]



> Task :init
Maven to Gradle conversion is an incubating feature.
For more information, please refer to https://docs.gradle.org/8.3/userguide/migrating_from_maven.html in the Gradle documentation.

BUILD SUCCESSFUL in 24s
2 actionable tasks: 2 executed
```

以下は生成された```settings.xml```

```gradle:settings.xml
/*
 * This file was generated by the Gradle 'init' task.
 */

rootProject.name = 'demo'

```

以下は```build.gradle```

```gradle:build.gradle
/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    id 'java-library'
    id 'maven-publish'
}

repositories {
    mavenLocal()
    maven {
        url = uri('https://repo.maven.apache.org/maven2/')
    }
}

dependencies {
    api 'org.springframework.boot:spring-boot-starter:3.1.3'
    testImplementation 'org.springframework.boot:spring-boot-starter-test:3.1.3'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
description = 'demo'
java.sourceCompatibility = JavaVersion.VERSION_1_8

publishing {
    publications {
        maven(MavenPublication) {
            from(components.java)
        }
    }
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

tasks.withType(Javadoc) {
    options.encoding = 'UTF-8'
}

```

gradleと無関係なspring-bootのプラグインを使うようにはさすがに変換されない。変換後に手動修正が必須とはいえ、もしMavan -> Gradle移行をする場合の取っ掛かりとして使う分には有用かもしれない。