46
46
* the plugin is applied:
47
47
*
48
48
* <ul>
49
+ * <li>The {@code https://repo.spring.io/release} Maven repository is configured and
50
+ * limited to dependencies in the following groups:
51
+ * <ul>
52
+ * <li>{@code io.spring.asciidoctor}
53
+ * <li>{@code io.spring.docresources}
54
+ * </ul>
49
55
* <li>All warnings are made fatal.
50
56
* <li>The version of AsciidoctorJ is upgraded to 2.4.1.
57
+ * <li>An {@code asciidoctorExtensions} configuration is created.
51
58
* <li>A task is created to resolve and unzip our documentation resources (CSS and
52
59
* Javascript).
53
60
* <li>For each {@link AsciidoctorTask} (HTML only):
64
71
* the current version, etc.
65
72
* <li>{@link AbstractAsciidoctorTask#baseDirFollowsSourceDir() baseDirFollowsSourceDir()}
66
73
* is enabled.
74
+ * <li>{@code asciidoctorExtensions} is added to the task's configurations.
67
75
* </ul>
68
76
* </ul>
69
77
*
@@ -73,16 +81,20 @@ class AsciidoctorConventions {
73
81
74
82
private static final String ASCIIDOCTORJ_VERSION = "2.4.1" ;
75
83
84
+ private static final String EXTENSIONS_CONFIGURATION_NAME = "asciidoctorExtensions" ;
85
+
76
86
void apply (Project project ) {
77
87
project .getPlugins ().withType (AsciidoctorJPlugin .class , (asciidoctorPlugin ) -> {
78
- configureDocResourcesRepository (project );
88
+ configureDocumentationDependenciesRepository (project );
79
89
makeAllWarningsFatal (project );
80
90
upgradeAsciidoctorJVersion (project );
91
+ Configuration asciidoctorExtensions = createAsciidoctorExtensionsConfiguration (project );
81
92
UnzipDocumentationResources unzipResources = createUnzipDocumentationResourcesTask (project );
82
93
project .getTasks ().withType (AbstractAsciidoctorTask .class , (asciidoctorTask ) -> {
83
94
configureCommonAttributes (project , asciidoctorTask );
84
95
configureOptions (asciidoctorTask );
85
96
asciidoctorTask .baseDirFollowsSourceDir ();
97
+ asciidoctorTask .configurations (asciidoctorExtensions );
86
98
Sync syncSource = createSyncDocumentationSourceTask (project , asciidoctorTask );
87
99
if (asciidoctorTask instanceof AsciidoctorTask ) {
88
100
configureHtmlOnlyAttributes (asciidoctorTask );
@@ -104,10 +116,13 @@ public void execute(Task task) {
104
116
});
105
117
}
106
118
107
- private void configureDocResourcesRepository (Project project ) {
119
+ private void configureDocumentationDependenciesRepository (Project project ) {
108
120
project .getRepositories ().maven ((mavenRepo ) -> {
109
121
mavenRepo .setUrl (URI .create ("https://repo.spring.io/release" ));
110
- mavenRepo .mavenContent ((mavenContent ) -> mavenContent .includeGroup ("io.spring.docresources" ));
122
+ mavenRepo .mavenContent ((mavenContent ) -> {
123
+ mavenContent .includeGroup ("io.spring.asciidoctor" );
124
+ mavenContent .includeGroup ("io.spring.docresources" );
125
+ });
111
126
});
112
127
}
113
128
@@ -119,6 +134,13 @@ private void upgradeAsciidoctorJVersion(Project project) {
119
134
project .getExtensions ().getByType (AsciidoctorJExtension .class ).setVersion (ASCIIDOCTORJ_VERSION );
120
135
}
121
136
137
+ private Configuration createAsciidoctorExtensionsConfiguration (Project project ) {
138
+ return project .getConfigurations ().create (EXTENSIONS_CONFIGURATION_NAME ,
139
+ (configuration ) -> project .getConfigurations ()
140
+ .matching ((candidate ) -> "dependencyManagement" .equals (candidate .getName ()))
141
+ .all ((dependencyManagement ) -> configuration .extendsFrom (dependencyManagement )));
142
+ }
143
+
122
144
private UnzipDocumentationResources createUnzipDocumentationResourcesTask (Project project ) {
123
145
Configuration documentationResources = project .getConfigurations ().maybeCreate ("documentationResources" );
124
146
documentationResources .getDependencies ()
0 commit comments