-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Convert PluginPropertiesExtension Groovy to Java #39605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alpar-t
merged 14 commits into
elastic:master
from
rhamedy:plugin-properties-task-tojava
Jun 13, 2019
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8f16ea0
Convert PluginPropertiesExtension & PluginPropertiesTask Groovy to Java
rhamedy 8874a69
Addressed review comments
rhamedy d376c1e
Refactored the code with regards to code review comments
rhamedy 66e4a93
Added plugin-descriptor.proerties along with unit tests for new java …
rhamedy 3b35c96
Removed unnecessary properties file
rhamedy cdb746a
Changed the implmentation and addressed code review
rhamedy d01e612
Fixed the tests and verified its working
rhamedy d144e6a
Register extension in PluginBuildPlugin, Refactore PluginPropertiesTa…
rhamedy a9aca3b
Wrap the inputstream in try-with-resource
rhamedy f00f100
Use StandardCopyOption.REPLACE_EXISTING when File.copy, unchain the m…
rhamedy 03fa92f
Delete previously converted PluginPropertiesTask and it's tests, rena…
rhamedy 8a0c6e3
removed apply plugin and updated hasNativeController getter name
rhamedy 441680d
set license and notice file on extensions extra properties
rhamedy 4affbf5
Merge master and make version lazy
alpar-t File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
90 changes: 0 additions & 90 deletions
90
buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesExtension.groovy
This file was deleted.
Oops, something went wrong.
141 changes: 141 additions & 0 deletions
141
buildSrc/src/main/java/org/elasticsearch/gradle/plugin/PluginPropertiesExtension.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.elasticsearch.gradle.plugin; | ||
|
|
||
| import org.gradle.api.Project; | ||
|
|
||
| import java.io.File; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A container for plugin properties that will be written to the plugin descriptor, for easy | ||
| * manipulation in the gradle DSL. | ||
| */ | ||
| public class PluginPropertiesExtension { | ||
| private String name; | ||
|
|
||
| private String version; | ||
|
|
||
| private String description; | ||
|
|
||
| private String classname; | ||
|
|
||
| /** Other plugins this plugin extends through SPI */ | ||
| private List<String> extendedPlugins = new ArrayList<>(); | ||
|
|
||
| private boolean hasNativeController; | ||
|
|
||
| /** True if the plugin requires the elasticsearch keystore to exist, false otherwise. */ | ||
| private boolean requiresKeystore; | ||
|
|
||
| /** A license file that should be included in the built plugin zip. */ | ||
| private File licenseFile; | ||
|
|
||
| /** | ||
| * A notice file that should be included in the built plugin zip. This will be | ||
| * extended with notices from the {@code licenses/} directory. | ||
| */ | ||
| private File noticeFile; | ||
|
|
||
| private final Project project; | ||
|
|
||
| public PluginPropertiesExtension(Project project) { | ||
| this.project = project; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name == null ? project.getName() : name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getVersion() { | ||
| return version == null ? project.getVersion().toString() : version; | ||
| } | ||
|
|
||
| public void setVersion(String version) { | ||
| this.version = version; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public void setDescription(String description) { | ||
| this.description = description; | ||
| } | ||
|
|
||
| public String getClassname() { | ||
| return classname; | ||
| } | ||
|
|
||
| public void setClassname(String classname) { | ||
| this.classname = classname; | ||
| } | ||
|
|
||
| public List<String> getExtendedPlugins() { | ||
| return this.extendedPlugins; | ||
| } | ||
|
|
||
| public boolean isHasNativeController() { | ||
rhamedy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return hasNativeController; | ||
| } | ||
|
|
||
| public void setHasNativeController(boolean hasNativeController) { | ||
| this.hasNativeController = hasNativeController; | ||
| } | ||
|
|
||
| public boolean isRequiresKeystore() { | ||
| return requiresKeystore; | ||
| } | ||
|
|
||
| public void setRequiresKeystore(boolean requiresKeystore) { | ||
| this.requiresKeystore = requiresKeystore; | ||
| } | ||
|
|
||
| public File getLicenseFile() { | ||
| return licenseFile; | ||
| } | ||
|
|
||
| public void setLicenseFile(File licenseFile) { | ||
| this.project.getExtensions().getExtraProperties().set("licenseFile", licenseFile); | ||
| this.licenseFile = licenseFile; | ||
| } | ||
|
|
||
| public File getNoticeFile() { | ||
| return noticeFile; | ||
| } | ||
|
|
||
| public void setNoticeFile(File noticeFile) { | ||
| this.project.getExtensions().getExtraProperties().set("noticeFile", noticeFile); | ||
| this.noticeFile = noticeFile; | ||
| } | ||
|
|
||
| public Project getProject() { | ||
| return project; | ||
| } | ||
|
|
||
| public void setExtendedPlugins(List<String> extendedPlugins) { | ||
| this.extendedPlugins = extendedPlugins; | ||
| } | ||
| } | ||
58 changes: 58 additions & 0 deletions
58
buildSrc/src/test/java/org/elasticsearch/gradle/plugin/PluginPropertiesExtensionTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.elasticsearch.gradle.plugin; | ||
|
|
||
| import org.elasticsearch.gradle.test.GradleUnitTestCase; | ||
| import org.gradle.api.Project; | ||
| import org.gradle.api.plugins.JavaPlugin; | ||
| import org.gradle.testfixtures.ProjectBuilder; | ||
|
|
||
| public class PluginPropertiesExtensionTests extends GradleUnitTestCase { | ||
|
|
||
| public void testCreatingPluginPropertiesExtensionWithNameAndVersion() { | ||
| String projectName = "Test"; | ||
| String projectVersion = "5.0"; | ||
|
|
||
| PluginPropertiesExtension pluginPropertiesExtension = | ||
| new PluginPropertiesExtension(this.createProject(projectName, projectVersion)); | ||
|
|
||
| assertEquals(projectName, pluginPropertiesExtension.getName()); | ||
| assertEquals(projectVersion, pluginPropertiesExtension.getVersion()); | ||
| } | ||
|
|
||
| public void testCreatingPluginPropertiesExtensionWithNameWithoutVersion() { | ||
| String projectName = "Test"; | ||
|
|
||
| PluginPropertiesExtension pluginPropertiesExtension = | ||
| new PluginPropertiesExtension(this.createProject(projectName, null)); | ||
|
|
||
| assertEquals(projectName, pluginPropertiesExtension.getName()); | ||
| assertEquals("unspecified", pluginPropertiesExtension.getVersion()); | ||
| } | ||
|
|
||
| private Project createProject(String projectName, String version) { | ||
| Project project = ProjectBuilder.builder().withName(projectName).build(); | ||
| project.setVersion(version); | ||
|
|
||
| project.getPlugins().apply(JavaPlugin.class); | ||
|
|
||
| return project; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.