Skip to content

Commit e1c1215

Browse files
init documentation
1 parent 7ae124f commit e1c1215

File tree

5 files changed

+100
-8
lines changed

5 files changed

+100
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $> ./gradlew build
4848
```
4949

5050
### *Step 4: Use your module.* <a id="start-4"></a>
51-
Take the built module and put it in the *modules* file of your HomeTracker server.
51+
Take the built module and put it in the *modules* file of your Modulo server.
5252

5353
> Enjoy 🍻 🌶🧀
5454

src/main/groovy/com/chillycheesy/modulo/ModuloApplicationPlugin.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ import com.chillycheesy.modulo.tasks.GenerateModuleYmlTask
55
import org.gradle.api.Project
66
import org.gradle.api.Plugin
77

8+
/**
9+
* The plugin class with the apply method.
10+
*/
811
class ModuloApplicationPlugin implements Plugin<Project> {
912

13+
/**
14+
* Init the plugin with the project.
15+
* @param project The project who apply the plugin.
16+
*/
1017
@Override
1118
void apply(Project project) {
1219
project.pluginManager.apply 'java-library'

src/main/groovy/com/chillycheesy/modulo/extensions/ModuleExtension.groovy

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,107 @@ package com.chillycheesy.modulo.extensions
22

33
import org.gradle.api.Project
44

5+
/**
6+
* The ModuleExtension store plugin.yml data.
7+
*/
58
class ModuleExtension {
69

10+
/**
11+
* Define name.
12+
* **Default: the project name.**
13+
*/
714
String moduleName
15+
/**
16+
* Define main.
17+
* **Default: {the project group}.{the project name}**
18+
*/
819
String main
20+
/**
21+
* Define version.
22+
* **Default: the project version.**
23+
*/
924
String version
25+
/**
26+
* Define the path where generate the plugin.yml file
27+
*/
1028
String target
29+
/**
30+
* Define authors.
31+
* **Default: src/main/resources**
32+
*/
1133
List<String> authors = ['ChillyCheesy']
34+
/**
35+
* Define dependencies.
36+
*/
1237
List<String> dependencies = []
38+
/**
39+
* Define softDependencies
40+
*/
1341
List<String> softDependencies = []
1442

43+
/**
44+
* Init the extension with default values.
45+
* @param project The target project.
46+
*/
1547
ModuleExtension(Project project) {
1648
moduleName = project.name
1749
version = project.version
1850
main = "${project.group.toString()}.${moduleName}"
1951
target = "${project.projectDir.path}/src/main/resources"
2052
}
2153

54+
/**
55+
* Set the name.
56+
* @param moduleName The new name.
57+
*/
2258
void moduleName(String moduleName) {
2359
this.moduleName = moduleName
2460
}
2561

62+
/**
63+
* Set the main.
64+
* @param main The new main.
65+
*/
2666
void main(String main) {
2767
this.main = main
2868
}
2969

70+
/**
71+
* Set the version.
72+
* @param version The new Version.
73+
*/
3074
void version(String version) {
3175
this.version = version
3276
}
3377

78+
/**
79+
* Set the path where generate the plugin.yml file.
80+
* @param target The new path
81+
*/
3482
void target(String target) {
3583
this.target = target
3684
}
3785

38-
void mainPageName(String mainPageName) {
39-
this.mainPageName = mainPageName
40-
}
41-
86+
/**
87+
* Set the authors.
88+
* @param authors The new authors List.
89+
*/
4290
void authors(List<String> authors) {
4391
this.authors = authors
4492
}
4593

94+
/**
95+
* Set the dependencies
96+
* @param dependencies The new dependencies List.
97+
*/
4698
void dependencies(List<String> dependencies) {
4799
this.dependencies = dependencies
48100
}
49101

102+
/**
103+
* Set the soft dependencies
104+
* @param softDependencies The new soft dependencies List.
105+
*/
50106
void softDependencies(List<String> softDependencies) {
51107
this.softDependencies = softDependencies
52108
}

src/main/groovy/com/chillycheesy/modulo/tasks/GenerateModuleYmlTask.groovy

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
11
package com.chillycheesy.modulo.tasks
22

3-
3+
import com.chillycheesy.modulo.extensions.ModuleExtension
44
import org.gradle.api.Project
55
import org.yaml.snakeyaml.Yaml
66

7+
/**
8+
* The GenerateModuleYmlTask generate the module.yml file before the Plugin build.
9+
* The task use the {@link ModuleExtension} information to generate it.
10+
*/
711
class GenerateModuleYmlTask implements ModuloTask {
812

9-
private com.chillycheesy.modulo.extensions.ModuleExtension moduleExtension
13+
/**
14+
* The ModuleExtension store plugin.yml data.
15+
*/
16+
private ModuleExtension moduleExtension
1017

11-
GenerateModuleYmlTask(com.chillycheesy.modulo.extensions.ModuleExtension moduleExtension) {
18+
/**
19+
* Create the Task
20+
* @param moduleExtension The module extention who store plugin.yml data
21+
*/
22+
GenerateModuleYmlTask(ModuleExtension moduleExtension) {
1223
this.moduleExtension = moduleExtension
1324
}
1425

26+
/**
27+
* Create the task.
28+
* @param project Target project.
29+
* @return The new task
30+
*/
1531
@Override
1632
def generate(Project project) {
1733
return project.task('generateModuleYml') {
@@ -32,6 +48,10 @@ class GenerateModuleYmlTask implements ModuloTask {
3248
}
3349
}
3450

51+
/**
52+
* Get the module.yml file and create it if doesn't exist.
53+
* @return The file.
54+
*/
3555
private def getModuleConfigFile() {
3656
final resources = new File("${moduleExtension.target}")
3757
resources.mkdirs()

src/main/groovy/com/chillycheesy/modulo/tasks/ModuloTask.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ package com.chillycheesy.modulo.tasks
22

33
import org.gradle.api.Project
44

5+
/**
6+
* Define a custom Modulo Task.
7+
*/
58
interface ModuloTask {
9+
10+
/**
11+
* Generate the custom task and return it.
12+
* @param project The target project where add the task.
13+
* @return The created task.
14+
*/
615
def generate(Project project)
716
}

0 commit comments

Comments
 (0)