[JIRA] (JENKINS-60290) Maven Archetypes "Hello World Plugin" Generates Broken Code

12 views
Skip to first unread message

kylie.a@protonmail.com (JIRA)

unread,
Nov 26, 2019, 1:11:03 PM11/26/19
to jenkinsc...@googlegroups.com
Kylie Auld created an issue
 
Jenkins / Bug JENKINS-60290
Maven Archetypes "Hello World Plugin" Generates Broken Code
Issue Type: Bug Bug
Assignee: Unassigned
Components: archetypes
Created: 2019-11-26 18:10
Priority: Minor Minor
Reporter: Kylie Auld

When generating a "Hello World" plugin using the maven archetypes the CLI generates broken code. On a line 60 an undeclared symbol is referenced, `Messages` (also on line 62, 64 and 76). Combined with the lack of useful documentation around Jenkins and its ecosystem this lead to a lot of wasted time for me the other day. 

Corrected code:

@Extension public static final class DescriptorImpl extends BuildStepDescriptor<Builder> { public FormValidation doCheckName(@QueryParameter String value, @QueryParameter boolean useFrench) throws IOException, ServletException { ResourceBundle messages = ResourceBundle.getBundle("HelloWorldBuilder.Messages"); if (value.length() == 0) return FormValidation.error(messages.getString("HelloWorldBuilder.DescriptorImpl.errors.missingName")); if (value.length() < 4) return FormValidation.warning(messages.getString("HelloWorldBuilder.DescriptorImpl.warnings.tooShort")); if (!useFrench && value.matches(".*[éáàç].*")) { return FormValidation.warning(messages.getString("HelloWorldBuilder.DescriptorImpl.warnings.reallyFrench")); } return FormValidation.ok(); } @Override public boolean isApplicable(Class<? extends AbstractProject> aClass) { return true; } @Override public String getDisplayName() { ResourceBundle nessages = ResourceBundle.getBundle("HelloWorldBuilder.Messages"); return nessages.getString("HelloWorldBuilder.DescriptorImpl.DisplayName"); } }
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

kylie.a@protonmail.com (JIRA)

unread,
Nov 26, 2019, 1:12:04 PM11/26/19
to jenkinsc...@googlegroups.com
Kylie Auld updated an issue
Change By: Kylie Auld
When generating a "Hello World" plugin using the maven archetypes the CLI generates broken code. On a[ line 60|#L60] an undeclared symbol is referenced, `Messages` (also on line 62, 64 and 76). Combined with the lack of useful documentation around Jenkins and its ecosystem this lead to a lot of wasted time for me the other day. 

Corrected code:
{code:java}
@Extension

public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {

public FormValidation doCheckName(@QueryParameter String value, @QueryParameter boolean useFrench)
throws IOException, ServletException {
ResourceBundle messages = ResourceBundle.getBundle("HelloWorldBuilder.Messages");
if (value.length() == 0)
return FormValidation.error(messages.getString("HelloWorldBuilder.DescriptorImpl.errors.missingName"));
if (value.length() < 4)
return FormValidation.warning(messages.getString("HelloWorldBuilder.DescriptorImpl.warnings.tooShort"));
if (!useFrench && value.matches(".*[éáàç].*")) {
return FormValidation.warning(messages.getString("HelloWorldBuilder.DescriptorImpl.warnings.reallyFrench"));
}
return FormValidation.ok();
}

@Override
public boolean isApplicable(Class<? extends AbstractProject> aClass) {
return true;
}

@Override
public String getDisplayName() {
ResourceBundle nessages = ResourceBundle.getBundle("HelloWorldBuilder.Messages");
return nessages.getString("HelloWorldBuilder.DescriptorImpl.DisplayName");
}

}
{code}

timjacomb1@gmail.com (JIRA)

unread,
Apr 13, 2020, 5:39:06 AM4/13/20
to jenkinsc...@googlegroups.com
Change By: Tim Jacomb
Status: Fixed but Unreleased Resolved
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

timjacomb1@gmail.com (JIRA)

unread,
Apr 13, 2020, 5:39:06 AM4/13/20
to jenkinsc...@googlegroups.com
Tim Jacomb commented on Bug JENKINS-60290
 
Re: Maven Archetypes "Hello World Plugin" Generates Broken Code

Kylie Auld you need to run mvn install once, that you generate the class, it's used for localisation, https://jenkins.io/doc/developer/internationalization/i18n-source-code/

I've just generated this via archetype and it compiled fine for me

timjacomb1@gmail.com (JIRA)

unread,
Apr 13, 2020, 5:39:06 AM4/13/20
to jenkinsc...@googlegroups.com
Tim Jacomb edited a comment on Bug JENKINS-60290
[~kylie_a] you need to run mvn install once, that you will generate the class, it's used for localisation, https://jenkins.io/doc/developer/internationalization/i18n-source-code/


I've just generated this via archetype and it compiled fine for me

timjacomb1@gmail.com (JIRA)

unread,
Apr 13, 2020, 5:39:07 AM4/13/20
to jenkinsc...@googlegroups.com
Tim Jacomb closed an issue as Not A Defect
 
Change By: Tim Jacomb
Status: Resolved Closed

timjacomb1@gmail.com (JIRA)

unread,
Apr 13, 2020, 5:39:07 AM4/13/20
to jenkinsc...@googlegroups.com
Change By: Tim Jacomb
Status: Open Fixed but Unreleased
Resolution: Not A Defect
Reply all
Reply to author
Forward
0 new messages