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

refactor: convert NoticeTask to java #34769

Conversation

baptistemesta
Copy link

Relates to #34459

I was not sure about tests. Would it be interesting here to test taskInput/output?

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I left a few comments. @atorok may have more.

*/
public class NoticeTask extends DefaultTask {

private static final Charset UTF8 = Charset.forName("UTF-8");
Copy link
Member

Choose a reason for hiding this comment

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

no need for a constant here, you can use StandardCharsets.UTF_8.

public class NoticeTask extends DefaultTask {

private static final Charset UTF8 = Charset.forName("UTF-8");
@InputFile
Copy link
Member

Choose a reason for hiding this comment

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

For java, there needs to be setters/getters, as the annotation will not automatically create them as it does in groovy. The annotations then go on the getters/settings.

/**
* Add notices from the specified directory.
*/
public void setLicensesDir(File licensesDir) {
Copy link
Member

Choose a reason for hiding this comment

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

The method was not named as a setter in groovy so this could be DSL-like. ie, usage looks like (notice the lack of equals sign):

noticeTask {
  licensesDir 'foo'
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this is different than setting a single property as it adds the inputs to the list.

String name = file.getName().substring(0, file.getName().length() - "-NOTICE.txt".length());
if (seen.containsKey(name)) {
File prevFile = seen.get(name);
if (!read(prevFile).equals(read(file))) {
Copy link
Member

Choose a reason for hiding this comment

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

We use == False throughout the codebase instead of ! because the former is easier to spot visually.

@rjernst rjernst added :Delivery/Build Build or test infrastructure >refactoring labels Oct 23, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@danielmitterdorfer
Copy link
Member

@baptistemesta thank you for your PR! Are you still interested to get it in? If yes, it would be great if you can address the review comments; then we can proceed.

@alpar-t
Copy link
Contributor

alpar-t commented Mar 7, 2019

@baptistemesta I'm going to close this due to lack of response, please re-open it if you plan to work on it.

@alpar-t alpar-t closed this Mar 7, 2019
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 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 feedback_needed >refactoring Team:Delivery Meta label for Delivery team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants