-
Notifications
You must be signed in to change notification settings - Fork 58
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
Convert Groovy views to Jelly | use Jenkins.get() #33
Conversation
<!-- | ||
The MIT License | ||
|
||
Copyright (c) 2016, CloudBees, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright (c) 2016, CloudBees, Inc. | |
Copyright (c) 2018, CloudBees, Inc. |
Or maybe add 2018 to the list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
pom.xml
Outdated
</repository> | ||
</repositories> | ||
<properties> | ||
<jenkins.version>2.107.3</jenkins.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note, this bumps the new min baseline pretty aggressively, but fine by me. Anyway old instances never update or close to it.
@@ -79,10 +80,10 @@ public void setJdk(String jdk) { | |||
@Override | |||
public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener, EnvVars initialEnvironment) throws IOException, InterruptedException { | |||
if (installation != null) { | |||
toolEnv(context, installation, Jenkins.getActiveInstance().getDescriptorByType(Ant.DescriptorImpl.class).getInstallations(), workspace, listener, initialEnvironment); | |||
toolEnv(context, installation, Jenkins.get().getDescriptorByType(Ant.DescriptorImpl.class).getInstallations(), workspace, listener, initialEnvironment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\o/
</table> | ||
</l:ajax> | ||
</j:jelly> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/me not convinced about this kind of change: IMO though tempting, we should refrein from reformating unrelated code to make code archeology easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to see what is actually being changed here and why. Anyway #32 probably covers most of what this was doing.
pom.xml
Outdated
<relativePath /> | ||
</parent> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not reformat existing lines of code.
src/main/java/hudson/tasks/Ant.java
Outdated
@@ -1,18 +1,18 @@ | |||
/* | |||
* The MIT License | |||
* | |||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
- convert groovy view to jelly - reformat code to follow Java convention - reorder pom file to follow convention https://maven.apache.org/developers/conventions/code.html - rename test variables to follow Jenkins standard - use Jenkins.get()
3d9a0d4
to
a3bb68f
Compare
I rebase the PR after the merge of #32. Also remove some of the pure tab/space reformat to keep mostly the relevant one that increase readability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer all formatting changes to be reverted. Use of nondeprecated methods, Groovy → Jelly switch, etc. are actual code changes which sound right, if I could find them.
@@ -23,7 +23,8 @@ | |||
public class AntTargetAnnotationTest { | |||
|
|||
@Rule | |||
public JenkinsRule r = new JenkinsRule(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have actually been preferring the name r
, since j
is too easily confused with the Jenkins
instance itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern here was essentially because the same name is used for RestartableJenkinsRule r
. No worries I revert them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My style (FWIW!) is to use RestartableJenkinsRule rr
.
@@ -5,7 +5,7 @@ | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
|
|||
import static org.junit.Assert.*; | |||
import static org.junit.Assert.assertEquals; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Common style for static imports in tests is to use wildcards.
src/main/java/hudson/tasks/Ant.java
Outdated
@@ -104,7 +104,7 @@ | |||
private final String properties; | |||
|
|||
@DataBoundConstructor | |||
public Ant(String targets,String antName, String antOpts, String buildFile, String properties) { | |||
public Ant(String targets, String antName, String antOpts, String buildFile, String properties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately https://github.com/jenkinsci/ant-plugin/pull/33/files?w still does not ignore this, making this diff too long to be read.
Anyway I am done “maintaining” this—just needed to deliver #32 urgently. |
- keep convert groovy view to jelly - keep use Jenkins.get()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-Approved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience!
--> | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form"> | ||
<j:if test="${size(descriptor.installations) != 0}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You tested this logic interactively, right? (Cannot recall if there is a functional test for it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(There are actually good reasons to discards the if
block and show this dropdown unconditionally, but that would be out of scope for this PR.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You tested this logic interactively, right?
I tested with and without installations but not sure to have cover all other potential cases there.
<select class="setting-input" name="ant.antName"> | ||
<option value="(Default)">${%Default}</option> | ||
<j:forEach var="install" items="${descriptor.installations}"> | ||
<f:option selected="${install.name == instance.ant.name}" value="${install.name}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW we ought to have a standard control in core for selecting a tool installation.
reformat code to follow Java conventionreorder pom file parts to follow conventionrename test variables to follow Jenkins standard@cloudbees/team-foundation @reviewbybees