|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.elasticsearch.gradle.plugin; |
| 21 | + |
| 22 | +import org.gradle.api.Project; |
| 23 | + |
| 24 | +import java.io.File; |
| 25 | +import java.util.ArrayList; |
| 26 | +import java.util.List; |
| 27 | + |
| 28 | +/** |
| 29 | + * A container for plugin properties that will be written to the plugin descriptor, for easy |
| 30 | + * manipulation in the gradle DSL. |
| 31 | + */ |
| 32 | +public class PluginPropertiesExtension { |
| 33 | + private String name; |
| 34 | + |
| 35 | + private String version; |
| 36 | + |
| 37 | + private String description; |
| 38 | + |
| 39 | + private String classname; |
| 40 | + |
| 41 | + /** Other plugins this plugin extends through SPI */ |
| 42 | + private List<String> extendedPlugins = new ArrayList<>(); |
| 43 | + |
| 44 | + private boolean hasNativeController; |
| 45 | + |
| 46 | + /** True if the plugin requires the elasticsearch keystore to exist, false otherwise. */ |
| 47 | + private boolean requiresKeystore; |
| 48 | + |
| 49 | + /** A license file that should be included in the built plugin zip. */ |
| 50 | + private File licenseFile; |
| 51 | + |
| 52 | + /** |
| 53 | + * A notice file that should be included in the built plugin zip. This will be |
| 54 | + * extended with notices from the {@code licenses/} directory. |
| 55 | + */ |
| 56 | + private File noticeFile; |
| 57 | + |
| 58 | + private final Project project; |
| 59 | + |
| 60 | + public PluginPropertiesExtension(Project project) { |
| 61 | + this.project = project; |
| 62 | + } |
| 63 | + |
| 64 | + public String getName() { |
| 65 | + return name == null ? project.getName() : name; |
| 66 | + } |
| 67 | + |
| 68 | + public void setName(String name) { |
| 69 | + this.name = name; |
| 70 | + } |
| 71 | + |
| 72 | + public String getVersion() { |
| 73 | + return version == null ? project.getVersion().toString() : version; |
| 74 | + } |
| 75 | + |
| 76 | + public void setVersion(String version) { |
| 77 | + this.version = version; |
| 78 | + } |
| 79 | + |
| 80 | + public String getDescription() { |
| 81 | + return description; |
| 82 | + } |
| 83 | + |
| 84 | + public void setDescription(String description) { |
| 85 | + this.description = description; |
| 86 | + } |
| 87 | + |
| 88 | + public String getClassname() { |
| 89 | + return classname; |
| 90 | + } |
| 91 | + |
| 92 | + public void setClassname(String classname) { |
| 93 | + this.classname = classname; |
| 94 | + } |
| 95 | + |
| 96 | + public List<String> getExtendedPlugins() { |
| 97 | + return this.extendedPlugins; |
| 98 | + } |
| 99 | + |
| 100 | + public boolean isHasNativeController() { |
| 101 | + return hasNativeController; |
| 102 | + } |
| 103 | + |
| 104 | + public void setHasNativeController(boolean hasNativeController) { |
| 105 | + this.hasNativeController = hasNativeController; |
| 106 | + } |
| 107 | + |
| 108 | + public boolean isRequiresKeystore() { |
| 109 | + return requiresKeystore; |
| 110 | + } |
| 111 | + |
| 112 | + public void setRequiresKeystore(boolean requiresKeystore) { |
| 113 | + this.requiresKeystore = requiresKeystore; |
| 114 | + } |
| 115 | + |
| 116 | + public File getLicenseFile() { |
| 117 | + return licenseFile; |
| 118 | + } |
| 119 | + |
| 120 | + public void setLicenseFile(File licenseFile) { |
| 121 | + this.project.getExtensions().getExtraProperties().set("licenseFile", licenseFile); |
| 122 | + this.licenseFile = licenseFile; |
| 123 | + } |
| 124 | + |
| 125 | + public File getNoticeFile() { |
| 126 | + return noticeFile; |
| 127 | + } |
| 128 | + |
| 129 | + public void setNoticeFile(File noticeFile) { |
| 130 | + this.project.getExtensions().getExtraProperties().set("noticeFile", noticeFile); |
| 131 | + this.noticeFile = noticeFile; |
| 132 | + } |
| 133 | + |
| 134 | + public Project getProject() { |
| 135 | + return project; |
| 136 | + } |
| 137 | + |
| 138 | + public void setExtendedPlugins(List<String> extendedPlugins) { |
| 139 | + this.extendedPlugins = extendedPlugins; |
| 140 | + } |
| 141 | +} |
0 commit comments