| @@ -6,6 +6,9 plugins { | |||||
| 6 | java { |
|
6 | java { | |
| 7 | withJavadocJar() |
|
7 | withJavadocJar() | |
| 8 | withSourcesJar() |
|
8 | withSourcesJar() | |
|
|
9 | toolchain { | |||
|
|
10 | languageVersion = JavaLanguageVersion.of(17) | |||
|
|
11 | } | |||
| 9 | } |
|
12 | } | |
| 10 |
|
13 | |||
| 11 | dependencies { |
|
14 | dependencies { | |
| @@ -14,7 +17,7 dependencies { | |||||
| 14 |
|
17 | |||
| 15 | task printVersion{ |
|
18 | task printVersion{ | |
| 16 | doLast { |
|
19 | doLast { | |
| 17 |
println "project: $project.group |
|
20 | println "project: $project.group:$project.name:$project.version" | |
| 18 | println "jar: ${->jar.archiveFileName.get()}" |
|
21 | println "jar: ${->jar.archiveFileName.get()}" | |
| 19 | } |
|
22 | } | |
| 20 | } |
|
23 | } | |
| @@ -25,4 +28,12 publishing { | |||||
| 25 | url "${System.properties["user.home"]}/ivy-repo" |
|
28 | url "${System.properties["user.home"]}/ivy-repo" | |
| 26 | } |
|
29 | } | |
| 27 | } |
|
30 | } | |
|
|
31 | publications { | |||
|
|
32 | ivy(IvyPublication) { | |||
|
|
33 | from components.java | |||
|
|
34 | descriptor.description { | |||
|
|
35 | text = providers.provider({ description }) | |||
|
|
36 | } | |||
|
|
37 | } | |||
|
|
38 | } | |||
| 28 | } No newline at end of file |
|
39 | } | |
| @@ -10,6 +10,7 import org.gradle.api.Task; | |||||
| 10 | import org.gradle.api.artifacts.Configuration; |
|
10 | import org.gradle.api.artifacts.Configuration; | |
| 11 | import org.gradle.api.file.Directory; |
|
11 | import org.gradle.api.file.Directory; | |
| 12 | import org.gradle.api.tasks.TaskProvider; |
|
12 | import org.gradle.api.tasks.TaskProvider; | |
|
|
13 | import org.implab.gradle.common.utils.ExtraProps; | |||
| 13 |
|
14 | |||
| 14 | /** Project configuration traits */ |
|
15 | /** Project configuration traits */ | |
| 15 | public interface ProjectMixin { |
|
16 | public interface ProjectMixin { | |
| @@ -37,6 +38,15 public interface ProjectMixin { | |||||
| 37 | return getProject().getPlugins().findPlugin(clazz); |
|
38 | return getProject().getPlugins().findPlugin(clazz); | |
| 38 | } |
|
39 | } | |
| 39 |
|
40 | |||
|
|
41 | /** | |||
|
|
42 | * @param classes The list of classes to register as extensions | |||
|
|
43 | */ | |||
|
|
44 | default void exportClasses(Class<?>... classes) { | |||
|
|
45 | var props = ExtraProps.of(getProject()); | |||
|
|
46 | for (var clazz : classes) | |||
|
|
47 | props.put(clazz.getSimpleName(), clazz); | |||
|
|
48 | } | |||
|
|
49 | ||||
| 40 | /** Creates and register a new project extension. |
|
50 | /** Creates and register a new project extension. | |
| 41 | * |
|
51 | * | |
| 42 | * @param <T> The type of the extension |
|
52 | * @param <T> The type of the extension | |
| @@ -7,10 +7,10 import org.gradle.api.plugins.ExtensionA | |||||
| 7 | public class ExtraProps { |
|
7 | public class ExtraProps { | |
| 8 |
|
8 | |||
| 9 | public static Map<String, Object> of(Object target) { |
|
9 | public static Map<String, Object> of(Object target) { | |
| 10 | return switch (target) { |
|
10 | if (target instanceof ExtensionAware ext) | |
| 11 |
|
|
11 | return ext.getExtensions().getExtraProperties().getProperties(); | |
| 12 | default -> Map.of(); |
|
12 | else | |
| 13 | }; |
|
13 | return Map.of(); | |
| 14 | } |
|
14 | } | |
| 15 |
|
15 | |||
| 16 | } |
|
16 | } | |
General Comments 0
You need to be logged in to leave comments.
Login now
