Skip to content

Commit abde140

Browse files
author
jack
committed
https://github.com/KotlinSpringBoot/demo_gradle_plugin_kor
1 parent 98c8ba9 commit abde140

File tree

10 files changed

+881
-0
lines changed

10 files changed

+881
-0
lines changed

build.gradle

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
buildscript {
2+
ext.kotlin_version = '1.2.10'
3+
4+
repositories {
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
9+
}
10+
}
11+
12+
group 'com.easy.springboot'
13+
version '1.0-SNAPSHOT'
14+
15+
apply plugin: 'groovy'
16+
apply plugin: 'java'
17+
apply plugin: 'kotlin'
18+
apply plugin: 'maven'
19+
20+
sourceCompatibility = 1.8
21+
22+
repositories {
23+
mavenCentral()
24+
}
25+
26+
dependencies {
27+
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
28+
// compile 'org.codehaus.groovy:groovy-all:2.3.11'
29+
testCompile group: 'junit', name: 'junit', version: '4.12'
30+
compile gradleApi()
31+
}
32+
33+
compileKotlin {
34+
kotlinOptions.jvmTarget = "1.8"
35+
}
36+
compileTestKotlin {
37+
kotlinOptions.jvmTarget = "1.8"
38+
}
39+
40+
uploadArchives {
41+
repositories {
42+
mavenDeployer {
43+
repository(url: uri('/Users/jack/.m2/repository'))
44+
}
45+
}
46+
}

demo_gradle_plugin_kor.iml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id="demo_gradle_plugin_kor" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.easy.springboot" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
7+
<excludeFolder url="file://$MODULE_DIR$/build" />
8+
<excludeFolder url="file://$MODULE_DIR$/out" />
9+
</content>
10+
<orderEntry type="inheritedJdk" />
11+
<orderEntry type="sourceFolder" forTests="false" />
12+
</component>
13+
</module>

demo_gradle_plugin_kor.ipr

+398
Large diffs are not rendered by default.

demo_gradle_plugin_kor_main.iml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id="demo_gradle_plugin_kor:main" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.easy.springboot" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="kotlin-language" name="Kotlin">
5+
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
6+
<compilerSettings />
7+
<compilerArguments>
8+
<option name="destination" value="$MODULE_DIR$/build/classes/kotlin/main" />
9+
<option name="noStdlib" value="true" />
10+
<option name="noReflect" value="true" />
11+
<option name="moduleName" value="demo_gradle_plugin_kor" />
12+
<option name="jvmTarget" value="1.8" />
13+
<option name="addCompilerBuiltIns" value="true" />
14+
<option name="loadBuiltInsFromDependencies" value="true" />
15+
<option name="languageVersion" value="1.2" />
16+
<option name="apiVersion" value="1.2" />
17+
<option name="pluginOptions">
18+
<array />
19+
</option>
20+
<option name="pluginClasspaths">
21+
<array />
22+
</option>
23+
</compilerArguments>
24+
</configuration>
25+
</facet>
26+
</component>
27+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
28+
<output url="file://$MODULE_DIR$/out/production/classes" />
29+
<exclude-output />
30+
<content url="file://$MODULE_DIR$/src/main">
31+
<sourceFolder url="file://$MODULE_DIR$/src/main/groovy" isTestSource="false" />
32+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
33+
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
34+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
35+
</content>
36+
<orderEntry type="inheritedJdk" />
37+
<orderEntry type="sourceFolder" forTests="false" />
38+
<orderEntry type="module-library">
39+
<library>
40+
<CLASSES>
41+
<root url="jar://$USER_HOME$/.gradle/caches/4.2.1/generated-gradle-jars/gradle-api-4.2.1.jar!/" />
42+
</CLASSES>
43+
<JAVADOC />
44+
<SOURCES />
45+
</library>
46+
</orderEntry>
47+
<orderEntry type="module-library">
48+
<library>
49+
<CLASSES>
50+
<root url="jar://$USER_HOME$/soft/gradle-4.2.1/lib/gradle-installation-beacon-4.2.1.jar!/" />
51+
</CLASSES>
52+
<JAVADOC />
53+
<SOURCES />
54+
</library>
55+
</orderEntry>
56+
<orderEntry type="module-library">
57+
<library>
58+
<CLASSES>
59+
<root url="jar://$USER_HOME$/soft/gradle-4.2.1/lib/groovy-all-2.4.12.jar!/" />
60+
</CLASSES>
61+
<JAVADOC />
62+
<SOURCES />
63+
</library>
64+
</orderEntry>
65+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.10" level="project" />
66+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.10" level="project" />
67+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.2.10" level="project" />
68+
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0" level="project" />
69+
</component>
70+
</module>

demo_gradle_plugin_kor_test.iml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id="demo_gradle_plugin_kor:test" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.easy.springboot" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="kotlin-language" name="Kotlin">
5+
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
6+
<compilerSettings />
7+
<compilerArguments>
8+
<option name="destination" value="$MODULE_DIR$/build/classes/kotlin/test" />
9+
<option name="noStdlib" value="true" />
10+
<option name="noReflect" value="true" />
11+
<option name="moduleName" value="demo_gradle_plugin_kor" />
12+
<option name="jvmTarget" value="1.8" />
13+
<option name="addCompilerBuiltIns" value="true" />
14+
<option name="loadBuiltInsFromDependencies" value="true" />
15+
<option name="languageVersion" value="1.2" />
16+
<option name="apiVersion" value="1.2" />
17+
<option name="pluginOptions">
18+
<array />
19+
</option>
20+
<option name="pluginClasspaths">
21+
<array />
22+
</option>
23+
</compilerArguments>
24+
</configuration>
25+
</facet>
26+
</component>
27+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
28+
<output-test url="file://$MODULE_DIR$/out/test/classes" />
29+
<exclude-output />
30+
<content url="file://$MODULE_DIR$/src/test">
31+
<sourceFolder url="file://$MODULE_DIR$/src/test/groovy" isTestSource="true" />
32+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
33+
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
34+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
35+
</content>
36+
<orderEntry type="inheritedJdk" />
37+
<orderEntry type="sourceFolder" forTests="false" />
38+
<orderEntry type="module" module-name="demo_gradle_plugin_kor_main" />
39+
<orderEntry type="module-library">
40+
<library>
41+
<CLASSES>
42+
<root url="jar://$USER_HOME$/soft/gradle-4.2.1/lib/gradle-installation-beacon-4.2.1.jar!/" />
43+
</CLASSES>
44+
<JAVADOC />
45+
<SOURCES />
46+
</library>
47+
</orderEntry>
48+
<orderEntry type="module-library">
49+
<library>
50+
<CLASSES>
51+
<root url="jar://$USER_HOME$/soft/gradle-4.2.1/lib/groovy-all-2.4.12.jar!/" />
52+
</CLASSES>
53+
<JAVADOC />
54+
<SOURCES />
55+
</library>
56+
</orderEntry>
57+
<orderEntry type="module-library">
58+
<library>
59+
<CLASSES>
60+
<root url="jar://$USER_HOME$/.gradle/caches/4.2.1/generated-gradle-jars/gradle-api-4.2.1.jar!/" />
61+
</CLASSES>
62+
<JAVADOC />
63+
<SOURCES />
64+
</library>
65+
</orderEntry>
66+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.10" level="project" />
67+
<orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" />
68+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.10" level="project" />
69+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.2.10" level="project" />
70+
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
71+
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0" level="project" />
72+
</component>
73+
<component name="TestModuleProperties" production-module="demo_gradle_plugin_kor_main" />
74+
</module>

settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = 'demo_gradle_plugin_kor'
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.easy.springboot.kor
2+
3+
import org.gradle.api.Plugin
4+
import org.gradle.api.Project
5+
6+
class KorPlugin implements Plugin<Project> {
7+
8+
9+
@Override
10+
void apply(Project project) {
11+
String projectDir = project.projectDir.absolutePath
12+
13+
project.extensions.create('korArgs', KorPluginExtension)
14+
15+
project.task("korGenerate") << {
16+
println("Hello, Kor !")
17+
println("Group: $project.group")
18+
println("Name: $project.name")
19+
println("korArgs: $project.korArgs.entity")
20+
String packageName = "$project.group.$project.name"
21+
String entityName = project.korArgs.entity
22+
23+
KorGenerateJava korGenerateJava = new KorGenerateJava()
24+
korGenerateJava.doGenerate(
25+
projectDir,
26+
packageName,
27+
entityName
28+
)
29+
}
30+
}
31+
}
32+
33+
class KorPluginExtension {
34+
def entity = "Kor"
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.easy.springboot.kor;
2+
3+
public class KorGenerateJava {
4+
public void doGenerate(String projectDir, String packageName,String entityName){
5+
6+
KorGenerateKotlin korGenerateKotlin = new KorGenerateKotlin();
7+
korGenerateKotlin.doGenerate(projectDir,packageName,entityName);
8+
9+
}
10+
}

0 commit comments

Comments
 (0)