Skip to content
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

Move license checks back to BuildPlugin #56975

Merged
merged 9 commits into from
May 26, 2020

Conversation

jakelandis
Copy link
Contributor

@jakelandis jakelandis commented May 20, 2020

Some standalone projects such as :distribution:archives:integ-test-zip have Java code
via tests, but are not need license and notice files. Applying the new ElasticsearchJavaPlugin
in favor over the elder Standalone*Plugin can result in these non-jar
projects test projects throwing an error due to the lack of the license or notice file.

This commit moves the license check out of the new ElasticsearchJavaPlugin and applies
only via the elder BuildPlugin

related: #56841

======

I'm not 100% this is the right direction, but seems pretty harmless to allow projects to opt out of the default jar creation. This PR is related to #56841 (comment) ...trying to move away from the conditional checks to that ensure specific plugins are applied.

Some standalone projects such as :distribution:archives:integ-test-zip have tests
but are not intended to ever create a jar. Applying the new ElasticsearchJavaPlugin
in favor over the elder "Standalone*Plugin" or BuildPlugin can result in these non-jar
projects erroring due to the lack of the license or notice file.

To avoid creating more permutations of ElasticsearchJavaPlugin
(i.e. ElasticsearchJavaPluginWithoutJar), the conuming project should be able disable
the jar task (e.g. `jar.enabled = false`) and the license checks should be skipped as
well as the javadoc and sources jars.

related: elastic#56841
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Build)

@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label May 20, 2020
@rjernst
Copy link
Member

rjernst commented May 20, 2020

To me this seems like something that should go in the publish plugin, since that is where we need the jars to contain the license files. However, we don't apply the publish plugin to all projects that go into our distributions (eg under libs). I think there is an argument for another plugin, one for any project that will end up in the distribution but is not published. I can't think of what to call it right now though..

@jakelandis
Copy link
Contributor Author

@rjernst I don't disagree, however would you mind if I logged a follow up issue to address that and proceed with this shorter term solution here ? The change here helps to unblock another PR.

@mark-vieira
Copy link
Contributor

mark-vieira commented May 20, 2020

However, we don't apply the publish plugin to all projects that go into our distributions (eg under libs).

Actually we do since we apply the BuildPlugin plugin to those, which in turn applies the publish plugin.

I'd move the jar license/notice check into BuildPlugin plugin. That plugin might change evolve but it's the best place now as that's applied to stuff we "assemble". I anticipate going forward we'll remove the publish plugin from that, and explicitly apply publishing to specific modules. That way we can apply elasticsearch.build to :libs projects, w/o all the publishing stuff (generate POM) but the build plugin still applies conventions, precommit checks, etc that aren't neccessarily applicable to standalone qa projects (i.e. elasticsearch.java).

@mark-vieira
Copy link
Contributor

@jakelandis discussed with @rjernst and we've agreed to just move this into BuildPlugin instead of ElasticsearchJavaPlugin. We can ditch all the enabled stuff and this still accomplishes what you want, which is the ability to use ElasticsearchJavaPlugin w/o dealing with these strict enforcements.

@jakelandis
Copy link
Contributor Author

thanks @rjernst @mark-vieira - I reverted the original commit(s) and moved the method call out of ElasticsearchJavaPlugin and into BuildPlugin.

@@ -82,6 +82,7 @@ class BuildPlugin implements Plugin<Project> {
)
}
project.pluginManager.apply('elasticsearch.java')
ElasticsearchJavaPlugin.configureJars(project)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be calling these methods statically; that is what we are trying to move away from. Can you please move the notice/license configuration to a new method in BuildPlugin, and leave the other stuff intact?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, however, aren't we also moving away from adding code to the Groovy parts of the build ? (I can move the code to Groovy and keep in the code in idiomatic Java, but isn't it still is going the wrong way ?)

We shouldn't be calling these methods statically

In that case, should these methods not be public static ?

Copy link
Member

@rjernst rjernst May 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will be finishing moving this code to java soon. I'll take care of re-javaizing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK ... I pulled the groovy version from git history and removed the Java version. 908ee17

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that isn't what I meant. Only the notice/license code should be moved. That is the problem you are running into right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pulled only the license and notice parts back to the groovy plugin

Copy link
Contributor

@mark-vieira mark-vieira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM 👍

@jakelandis jakelandis changed the title Allow ElasticsearchJavaPlugin for non-jar based projects Move license checks back to BuildPlugin May 26, 2020
@jakelandis jakelandis merged commit 2e1e33d into elastic:master May 26, 2020
@jakelandis jakelandis deleted the allow_disable_jar branch May 26, 2020 17:42
jakelandis added a commit to jakelandis/elasticsearch that referenced this pull request May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team v7.7.1 v7.8.1 v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants