Skip to content

Commit

Permalink
JENKINS-37738 - Update dependency in plugin and cleanup in pom
Browse files Browse the repository at this point in the history
  • Loading branch information
klimas7 committed Aug 28, 2016
1 parent cb8c865 commit a86008b
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 34 deletions.
45 changes: 24 additions & 21 deletions pom.xml
Expand Up @@ -5,7 +5,7 @@
<artifactId>plugin</artifactId>
<!-- Baseline Jenkins version you use to build and test the plugin. Users
must have this version or newer to run. -->
<version>1.580.2</version>
<version>2.10</version>
</parent>

<groupId>org.jenkins-ci.tools</groupId>
Expand Down Expand Up @@ -56,36 +56,20 @@

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.3</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.9.4</version>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-core</artifactId>
<version>1.651.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>2.3.4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-core</artifactId>
<version>1.580.2</version>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jquery</artifactId>
<version>1.11.2-0</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand All @@ -96,6 +80,25 @@
<artifactId>joda-time</artifactId>
<version>2.9.2</version>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
</dependencies>

<scm>
Expand Down
19 changes: 19 additions & 0 deletions src/findbugs/excludesFilter.xml
@@ -0,0 +1,19 @@
<FindBugsFilter>
<!-- Jenkins.getInstance() always returns a non-null. -->
<Match>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
<Class name="net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition"/>
<Method name="getEnvironment"/>
</Match>
<!-- Jenkins.getInstance() always returns a non-null. -->
<Match>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
<Class name="net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition"/>
<Method name="getParentProject"/>
</Match>

<Match>
<Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS"/>
<Class name="net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition"/>
</Match>
</FindBugsFilter>
Expand Up @@ -100,24 +100,24 @@ public ParameterValue createValue(StaplerRequest request) {
@Override
public ParameterValue createValue(StaplerRequest request, JSONObject jO) {
Object value = jO.get("value");
String strValue = "";
StringBuilder strValue = new StringBuilder();
if (value instanceof String) {
strValue = (String) value;
strValue.append(value);
} else if (value instanceof JSONArray) {
JSONArray jsonValues = (JSONArray) value;
for (int i = 0; i < jsonValues.size(); i++) {
strValue += jsonValues.getString(i);
strValue.append(jsonValues.getString(i));
if (i < jsonValues.size() - 1) {
strValue += ",";
strValue.append(",");
}
}
}

if ("".equals(strValue)) {
strValue = defaultValue;
if (strValue.length() == 0) {
strValue.append(defaultValue);
}

GitParameterValue gitParameterValue = new GitParameterValue(jO.getString("name"), strValue);
GitParameterValue gitParameterValue = new GitParameterValue(jO.getString("name"), strValue.toString());
return gitParameterValue;
}

Expand All @@ -139,6 +139,11 @@ public ParameterValue getDefaultParameterValue() {
} catch (Exception e) {
LOGGER.log(Level.SEVERE, Messages.GitParameterDefinition_unexpectedError(), e);
}
break;
case DEFAULT:
case NONE:
default:
return super.getDefaultParameterValue();
}
return super.getDefaultParameterValue();
}
Expand Down
@@ -1,12 +1,13 @@
package net.uaznia.lukanus.hudson.plugins.gitparameter;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Comparator;

/**
* Compares strings but treats a sequence of digits as a single character.
*/
class SmartNumberStringComparer implements Comparator<String> {
class SmartNumberStringComparer implements Comparator<String>, Serializable {

/**
* Gets the token starting at the given index. It will return the first
Expand All @@ -18,11 +19,11 @@ class SmartNumberStringComparer implements Comparator<String> {
*/
private String getToken(String str, int index) {
char nextChar = str.charAt(index++);
String token = String.valueOf(nextChar);
StringBuilder token = new StringBuilder(String.valueOf(nextChar));

// if the first char wasn't a digit then we're already done
if (!Character.isDigit(nextChar))
return token;
return token.toString();

// the first char was a digit so continue until end of string or non
// digit
Expand All @@ -32,10 +33,10 @@ private String getToken(String str, int index) {
if (!Character.isDigit(nextChar))
break;

token += nextChar;
token.append(nextChar);
}

return token;
return token.toString();
}

/**
Expand Down Expand Up @@ -75,7 +76,7 @@ && stringContainsInteger(bToken)) {
bIndex += bToken.length();
}

return Integer.valueOf(a.length()).compareTo(Integer.valueOf(b.length()));
return Integer.compare(a.length(), b.length());
}

}
1 change: 1 addition & 0 deletions src/main/resources/index.jelly
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<!--
This view is used to render the plugin list page.
Expand Down
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%parameter.name}" field="name">
Expand Down
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
Expand Down
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
Expand Down
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler">
<script src="${it.packageUrl}/javascript/git-parameter.js" type="text/javascript" />
</j:jelly>

0 comments on commit a86008b

Please sign in to comment.