27
27
import org .asciidoctor .gradle .jvm .AsciidoctorJPlugin ;
28
28
import org .asciidoctor .gradle .jvm .AsciidoctorTask ;
29
29
import org .gradle .api .Project ;
30
- import org .gradle .api .artifacts .Configuration ;
31
- import org .gradle .api .artifacts .ConfigurationContainer ;
32
30
import org .gradle .api .tasks .PathSensitivity ;
33
31
import org .gradle .api .tasks .Sync ;
34
32
40
38
* the plugin is applied:
41
39
*
42
40
* <ul>
41
+ * <li>The {@code https://repo.spring.io/release} Maven repository is configured and
42
+ * limited to dependencies in the following groups:
43
+ * <ul>
44
+ * <li>{@code io.spring.asciidoctor}
45
+ * <li>{@code io.spring.asciidoctor.backends}
46
+ * <li>{@code io.spring.docresources}
47
+ * </ul>
43
48
* <li>All warnings are made fatal.
44
49
* <li>The version of AsciidoctorJ is upgraded to 2.4.3.
45
- * <li>A {@code asciidoctorExtensions} configuration is created.
50
+ * <li>An {@code asciidoctorExtensions} configuration is created.
46
51
* <li>For each {@link AsciidoctorTask} (HTML only):
47
52
* <ul>
48
53
* <li>A task is created to sync the documentation resources to its output directory.
56
61
* the current version, etc.
57
62
* <li>{@link AbstractAsciidoctorTask#baseDirFollowsSourceDir() baseDirFollowsSourceDir()}
58
63
* is enabled.
64
+ * <li>{@code asciidoctorExtensions} is added to the task's configurations.
59
65
* </ul>
60
66
* </ul>
61
67
*
62
68
* @author Andy Wilkinson
63
69
*/
64
70
class AsciidoctorConventions {
65
71
66
- private static final String EXTENSIONS_CONFIGURATION = "asciidoctorExtensions" ;
67
-
68
72
private static final String ASCIIDOCTORJ_VERSION = "2.4.3" ;
69
73
74
+ private static final String EXTENSIONS_CONFIGURATION_NAME = "asciidoctorExtensions" ;
75
+
70
76
void apply (Project project ) {
71
77
project .getPlugins ().withType (AsciidoctorJPlugin .class , (asciidoctorPlugin ) -> {
72
- configureDocResourcesRepository (project );
78
+ configureDocumentationDependenciesRepository (project );
73
79
makeAllWarningsFatal (project );
74
80
upgradeAsciidoctorJVersion (project );
75
81
createAsciidoctorExtensionsConfiguration (project );
@@ -78,10 +84,14 @@ void apply(Project project) {
78
84
});
79
85
}
80
86
81
- private void configureDocResourcesRepository (Project project ) {
87
+ private void configureDocumentationDependenciesRepository (Project project ) {
82
88
project .getRepositories ().maven ((mavenRepo ) -> {
83
- mavenRepo .setUrl (URI .create ("https://repo.spring.io/snapshot" ));
84
- mavenRepo .mavenContent ((mavenContent ) -> mavenContent .includeGroup ("io.spring.asciidoctor.backends" ));
89
+ mavenRepo .setUrl (URI .create ("https://repo.spring.io/release" ));
90
+ mavenRepo .mavenContent ((mavenContent ) -> {
91
+ mavenContent .includeGroup ("io.spring.asciidoctor" );
92
+ mavenContent .includeGroup ("io.spring.asciidoctor.backends" );
93
+ mavenContent .includeGroup ("io.spring.docresources" );
94
+ });
85
95
});
86
96
}
87
97
@@ -94,20 +104,18 @@ private void upgradeAsciidoctorJVersion(Project project) {
94
104
}
95
105
96
106
private void createAsciidoctorExtensionsConfiguration (Project project ) {
97
- ConfigurationContainer configurations = project .getConfigurations ();
98
- Configuration asciidoctorExtensions = configurations .maybeCreate (EXTENSIONS_CONFIGURATION );
99
- asciidoctorExtensions .getDependencies ().add (
100
- project .getDependencies ().create ("io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.1" ));
101
- asciidoctorExtensions .getDependencies ()
102
- .add (project .getDependencies ().create ("org.asciidoctor:asciidoctorj-pdf:1.5.3" ));
103
- Configuration dependencyManagement = configurations .findByName ("dependencyManagement" );
104
- if (dependencyManagement != null ) {
105
- asciidoctorExtensions .extendsFrom (dependencyManagement );
106
- }
107
+ project .getConfigurations ().create (EXTENSIONS_CONFIGURATION_NAME , (configuration ) -> {
108
+ project .getConfigurations ().matching ((candidate ) -> "dependencyManagement" .equals (candidate .getName ()))
109
+ .all ((dependencyManagement ) -> configuration .extendsFrom (dependencyManagement ));
110
+ configuration .getDependencies ().add (project .getDependencies ()
111
+ .create ("io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.1" ));
112
+ configuration .getDependencies ()
113
+ .add (project .getDependencies ().create ("org.asciidoctor:asciidoctorj-pdf:1.5.3" ));
114
+ });
107
115
}
108
116
109
117
private void configureAsciidoctorTask (Project project , AbstractAsciidoctorTask asciidoctorTask ) {
110
- asciidoctorTask .configurations (EXTENSIONS_CONFIGURATION );
118
+ asciidoctorTask .configurations (EXTENSIONS_CONFIGURATION_NAME );
111
119
configureCommonAttributes (project , asciidoctorTask );
112
120
configureOptions (asciidoctorTask );
113
121
asciidoctorTask .baseDirFollowsSourceDir ();
0 commit comments