34
34
import org .gradle .api .plugins .JavaPlugin ;
35
35
import org .gradle .api .plugins .JavaPluginExtension ;
36
36
import org .gradle .api .provider .Provider ;
37
- import org .gradle .api .publish .PublishingExtension ;
38
- import org .gradle .api .publish .maven .MavenPublication ;
39
- import org .gradle .api .publish .maven .plugins .MavenPublishPlugin ;
40
37
import org .gradle .api .tasks .Copy ;
41
38
import org .gradle .api .tasks .SourceSetContainer ;
42
39
import org .gradle .api .tasks .Sync ;
@@ -74,42 +71,6 @@ public void apply(final Project project) {
74
71
configureDependencies (project );
75
72
76
73
final var bundleTask = createBundleTasks (project , extension );
77
- project .afterEvaluate (project1 -> {
78
- configurePublishing (project1 , extension );
79
- String name = extension .getName ();
80
- project1 .setProperty ("archivesBaseName" , name );
81
- project1 .setDescription (extension .getDescription ());
82
-
83
- if (extension .getName () == null ) {
84
- throw new InvalidUserDataException ("name is a required setting for esplugin" );
85
- }
86
-
87
- if (extension .getDescription () == null ) {
88
- throw new InvalidUserDataException ("description is a required setting for esplugin" );
89
- }
90
-
91
- if (extension .getType ().equals (PluginType .BOOTSTRAP ) == false && extension .getClassname () == null ) {
92
- throw new InvalidUserDataException ("classname is a required setting for esplugin" );
93
- }
94
-
95
- Map <String , Object > map = new LinkedHashMap <>(12 );
96
- map .put ("name" , extension .getName ());
97
- map .put ("description" , extension .getDescription ());
98
- map .put ("version" , extension .getVersion ());
99
- map .put ("elasticsearchVersion" , Version .fromString (VersionProperties .getElasticsearch ()).toString ());
100
- map .put ("javaVersion" , project1 .getExtensions ().getByType (JavaPluginExtension .class ).getTargetCompatibility ().toString ());
101
- map .put ("classname" , extension .getType ().equals (PluginType .BOOTSTRAP ) ? "" : extension .getClassname ());
102
- map .put ("extendedPlugins" , extension .getExtendedPlugins ().stream ().collect (Collectors .joining ("," )));
103
- map .put ("hasNativeController" , extension .isHasNativeController ());
104
- map .put ("requiresKeystore" , extension .isRequiresKeystore ());
105
- map .put ("type" , extension .getType ().toString ());
106
- map .put ("javaOpts" , extension .getJavaOpts ());
107
- map .put ("licensed" , extension .isLicensed ());
108
- project1 .getTasks ().withType (Copy .class ).named ("pluginProperties" ).configure (copy -> {
109
- copy .expand (map );
110
- copy .getInputs ().properties (map );
111
- });
112
- });
113
74
project .getConfigurations ().getByName ("default" ).extendsFrom (project .getConfigurations ().getByName ("runtimeClasspath" ));
114
75
115
76
// allow running ES with this plugin in the foreground of a build
@@ -134,14 +95,6 @@ private static NamedDomainObjectContainer<ElasticsearchCluster> testClusters(Pro
134
95
return (NamedDomainObjectContainer <ElasticsearchCluster >) project .getExtensions ().getByName (extensionName );
135
96
}
136
97
137
- private static void configurePublishing (Project project , PluginPropertiesExtension extension ) {
138
- if (project .getPlugins ().hasPlugin (MavenPublishPlugin .class )) {
139
- PublishingExtension publishingExtension = project .getExtensions ().getByType (PublishingExtension .class );
140
- MavenPublication elastic = publishingExtension .getPublications ().maybeCreate ("elastic" , MavenPublication .class );
141
- elastic .setArtifactId (extension .getName ());
142
- }
143
- }
144
-
145
98
private static void configureDependencies (final Project project ) {
146
99
var dependencies = project .getDependencies ();
147
100
dependencies .add ("compileOnly" , "org.elasticsearch:elasticsearch:" + VersionProperties .getElasticsearch ());
@@ -189,6 +142,35 @@ public void execute(Task task) {
189
142
copy .dependsOn (copyPluginPropertiesTemplate );
190
143
copy .from (templateFile );
191
144
copy .into (new File (project .getBuildDir (), "generated-resources" ));
145
+
146
+ if (extension .getName () == null ) {
147
+ throw new InvalidUserDataException ("name is a required setting for esplugin" );
148
+ }
149
+
150
+ if (extension .getDescription () == null ) {
151
+ throw new InvalidUserDataException ("description is a required setting for esplugin" );
152
+ }
153
+
154
+ if (extension .getType ().equals (PluginType .BOOTSTRAP ) == false && extension .getClassname () == null ) {
155
+ throw new InvalidUserDataException ("classname is a required setting for esplugin" );
156
+ }
157
+
158
+ Map <String , Object > map = new LinkedHashMap <>(12 );
159
+ map .put ("name" , extension .getName ());
160
+ map .put ("description" , extension .getDescription ());
161
+ map .put ("version" , extension .getVersion ());
162
+ map .put ("elasticsearchVersion" , Version .fromString (VersionProperties .getElasticsearch ()).toString ());
163
+ map .put ("javaVersion" , project .getExtensions ().getByType (JavaPluginExtension .class ).getTargetCompatibility ().toString ());
164
+ map .put ("classname" , extension .getType ().equals (PluginType .BOOTSTRAP ) ? "" : extension .getClassname ());
165
+ map .put ("extendedPlugins" , extension .getExtendedPlugins ().stream ().collect (Collectors .joining ("," )));
166
+ map .put ("hasNativeController" , extension .isHasNativeController ());
167
+ map .put ("requiresKeystore" , extension .isRequiresKeystore ());
168
+ map .put ("type" , extension .getType ().toString ());
169
+ map .put ("javaOpts" , extension .getJavaOpts ());
170
+ map .put ("licensed" , extension .isLicensed ());
171
+
172
+ copy .expand (map );
173
+ copy .getInputs ().properties (map );
192
174
});
193
175
// add the plugin properties and metadata to test resources, so unit tests can
194
176
// know about the plugin (used by test security code to statically initialize the plugin in unit tests)
0 commit comments