parent
decc6277f9
commit
41629b7bfd
|
@ -29,14 +29,8 @@ import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
|
|||
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
|
||||
import org.elasticsearch.gradle.testclusters.TestDistribution
|
||||
import org.elasticsearch.gradle.util.GradleUtils
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.InvalidUserDataException
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.ModuleDependency
|
||||
|
@ -48,8 +42,10 @@ import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout
|
|||
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
|
||||
import org.gradle.api.credentials.HttpHeaderCredentials
|
||||
import org.gradle.api.execution.TaskActionListener
|
||||
import org.gradle.api.file.CopySpec
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension
|
||||
import org.gradle.api.plugins.JavaPlugin
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.authentication.http.HttpHeaderAuthentication
|
||||
import org.gradle.util.GradleVersion
|
||||
|
@ -85,6 +81,7 @@ class BuildPlugin implements Plugin<Project> {
|
|||
)
|
||||
}
|
||||
project.pluginManager.apply('elasticsearch.java')
|
||||
configureLicenseAndNotice(project)
|
||||
project.pluginManager.apply('elasticsearch.publish')
|
||||
project.pluginManager.apply(DependenciesInfoPlugin)
|
||||
|
||||
|
@ -273,6 +270,7 @@ class BuildPlugin implements Plugin<Project> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestFailureReportingPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
void apply(Project project) {
|
||||
|
@ -305,4 +303,32 @@ class BuildPlugin implements Plugin<Project> {
|
|||
private static inFipsJvm(){
|
||||
return Boolean.parseBoolean(System.getProperty("tests.fips.enabled"));
|
||||
}
|
||||
|
||||
static void configureLicenseAndNotice(Project project) {
|
||||
ExtraPropertiesExtension ext = project.extensions.getByType(ExtraPropertiesExtension)
|
||||
ext.set('licenseFile', null)
|
||||
ext.set('noticeFile', null)
|
||||
// add license/notice files
|
||||
project.afterEvaluate {
|
||||
project.tasks.withType(Jar).configureEach { Jar jarTask ->
|
||||
if (ext.has('licenseFile') == false || ext.get('licenseFile') == null || ext.has('noticeFile') == false || ext.get('noticeFile') == null) {
|
||||
throw new GradleException("Must specify license and notice file for project ${project.path}")
|
||||
}
|
||||
|
||||
File licenseFile = ext.get('licenseFile') as File
|
||||
File noticeFile = ext.get('noticeFile') as File
|
||||
|
||||
jarTask.metaInf { CopySpec spec ->
|
||||
spec.from(licenseFile.parent) { CopySpec from ->
|
||||
from.include licenseFile.name
|
||||
from.rename { 'LICENSE.txt' }
|
||||
}
|
||||
spec.from(noticeFile.parent) { CopySpec from ->
|
||||
from.include noticeFile.name
|
||||
from.rename { 'NOTICE.txt' }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.gradle.api.artifacts.ProjectDependency;
|
|||
import org.gradle.api.artifacts.ResolutionStrategy;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.plugins.BasePlugin;
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
|
@ -398,11 +397,10 @@ public class ElasticsearchJavaPlugin implements Plugin<Project> {
|
|||
});
|
||||
}
|
||||
|
||||
/** Adds additional manifest info to jars */
|
||||
/**
|
||||
* Adds additional manifest info to jars
|
||||
*/
|
||||
static void configureJars(Project project) {
|
||||
ExtraPropertiesExtension ext = project.getExtensions().getExtraProperties();
|
||||
ext.set("licenseFile", null);
|
||||
ext.set("noticeFile", null);
|
||||
project.getTasks()
|
||||
.withType(Jar.class)
|
||||
.configureEach(
|
||||
|
@ -427,25 +425,6 @@ public class ElasticsearchJavaPlugin implements Plugin<Project> {
|
|||
);
|
||||
}
|
||||
);
|
||||
// add license/notice files
|
||||
project.afterEvaluate(p -> project.getTasks().withType(Jar.class).configureEach(jarTask -> {
|
||||
File licenseFile = (File) ext.get("licenseFile");
|
||||
File noticeFile = (File) ext.get("noticeFile");
|
||||
if (licenseFile == null || noticeFile == null) {
|
||||
throw new GradleException("Must specify license and notice file for project");
|
||||
}
|
||||
|
||||
jarTask.metaInf(spec -> {
|
||||
spec.from(licenseFile.getParent(), from -> {
|
||||
from.include(licenseFile.getName());
|
||||
from.rename(s -> "LICENSE.txt");
|
||||
});
|
||||
spec.from(noticeFile.getParent(), from -> {
|
||||
from.include(noticeFile.getName());
|
||||
from.rename(s -> "NOTICE.txt");
|
||||
});
|
||||
});
|
||||
}));
|
||||
project.getPluginManager().withPlugin("com.github.johnrengelman.shadow", p -> {
|
||||
project.getTasks()
|
||||
.withType(ShadowJar.class)
|
||||
|
|
Loading…
Reference in New Issue