Skip to content
Permalink
Browse files

Merge pull request #67 from redeamer/reduce-java-warnings

[FIXED JENKINS-45456] Reduce Java warnings of the plugin and remove u…
  • Loading branch information...
orrc committed Nov 14, 2017
2 parents 2c5a646 + 8224c8a commit 779118b40a4753e6d1963c47b1a3d6349e4932e0
@@ -13,7 +13,6 @@
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.Computer;
import hudson.model.Hudson;
import hudson.model.Node;
import hudson.model.Result;
import hudson.plugins.android_emulator.sdk.AndroidSdk;
@@ -30,6 +29,7 @@
import hudson.util.ForkOutputStream;
import hudson.util.FormValidation;
import hudson.util.NullStream;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils;
@@ -179,7 +179,7 @@ public Environment setUp(AbstractBuild build, final Launcher launcher, BuildList
throws IOException, InterruptedException {
final PrintStream logger = listener.getLogger();
if (descriptor == null) {
descriptor = Hudson.getInstance().getDescriptorByType(DescriptorImpl.class);
descriptor = Jenkins.getInstance().getDescriptorByType(DescriptorImpl.class);
}

// Substitute environment and build variables into config
@@ -4,7 +4,6 @@
import hudson.matrix.MatrixConfiguration;
import hudson.model.BuildableItemWithBuildWrappers;
import hudson.model.Executor;
import hudson.model.Hudson;
import hudson.model.Node;
import hudson.model.Queue;
import hudson.model.Queue.BuildableItem;
@@ -15,6 +14,7 @@
import hudson.model.queue.SubTask;

import hudson.plugins.android_emulator.AndroidEmulator.DescriptorImpl;
import jenkins.model.Jenkins;

/**
* This QueueTaskDispatcher prevents any one Android emulator instance from being executed more than
@@ -43,13 +43,13 @@ public CauseOfBlockage canTake(Node node, Task task) {
}

// If the AndroidEmulator uses workspace-local emulators, we don't care.
DescriptorImpl descriptor = Hudson.getInstance().getDescriptorByType(DescriptorImpl.class);
DescriptorImpl descriptor = Jenkins.getInstance().getDescriptorByType(DescriptorImpl.class);
if (descriptor != null && descriptor.shouldKeepInWorkspace) {
return null;
}

// Check for builds in the queue which have the same emulator config as this task
Queue queue = Hudson.getInstance().getQueue();
Queue queue = Jenkins.getInstance().getQueue();
for (BuildableItem item : queue.getBuildableItems()) {
Task queuedTask = item.task;
if (task == queuedTask) {
@@ -7,7 +7,6 @@
import hudson.model.BuildListener;
import hudson.model.Computer;
import hudson.model.EnvironmentContributingAction;
import hudson.model.Hudson;
import hudson.model.Node;
import hudson.model.TaskListener;
import hudson.plugins.android_emulator.AndroidEmulator;
@@ -24,6 +23,7 @@
import hudson.tasks.Builder;
import hudson.util.ForkOutputStream;
import jenkins.MasterToSlaveFileCallable;
import jenkins.model.Jenkins;
import net.dongliu.apk.parser.ApkParser;
import net.dongliu.apk.parser.bean.ApkMeta;

@@ -51,7 +51,7 @@ protected static AndroidSdk getAndroidSdk(AbstractBuild<?, ?> build, Launcher la
BuildListener listener) throws IOException, InterruptedException {
boolean shouldInstallSdk = true;
boolean keepInWorkspace = false;
DescriptorImpl descriptor = Hudson.getInstance().getDescriptorByType(DescriptorImpl.class);
DescriptorImpl descriptor = Jenkins.getInstance().getDescriptorByType(DescriptorImpl.class);
if (descriptor != null) {
shouldInstallSdk = descriptor.shouldInstallSdk;
keepInWorkspace = descriptor.shouldKeepInWorkspace;
@@ -286,6 +286,8 @@ protected static boolean uninstallApk(AbstractBuild<?, ?> build, Launcher launch
*/
private static String getPackageIdForApk(FilePath apkPath) throws IOException, InterruptedException {
return apkPath.act(new MasterToSlaveFileCallable<String>() {
private static final long serialVersionUID = 1L;

public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
return getApkMetadata(f).getPackageName();
}
@@ -190,6 +190,8 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
private static String getWorkspacePath(FilePath workspace) throws IOException,
InterruptedException {
return workspace.act(new MasterToSlaveFileCallable<String>() {
private static final long serialVersionUID = 1L;

public String invoke(File f, VirtualChannel channel) throws IOException {
return f.getCanonicalPath();
}
@@ -148,7 +148,7 @@ public String getHelpFile() {
}

@Override
public boolean isApplicable(Class<? extends AbstractProject> jobType) {
public boolean isApplicable(@SuppressWarnings("rawtypes") Class<? extends AbstractProject> jobType) {
return true;
}

@@ -1,6 +1,5 @@
package hudson.plugins.android_emulator.snapshot;

import hudson.Extension;
import hudson.Functions;
import hudson.model.Descriptor;
import hudson.plugins.android_emulator.Messages;
@@ -1,6 +1,5 @@
package hudson.plugins.android_emulator.snapshot;

import hudson.Extension;
import hudson.Functions;
import hudson.model.Descriptor;
import hudson.plugins.android_emulator.Messages;
@@ -54,22 +54,22 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;

import static hudson.plugins.android_emulator.AndroidEmulator.log;

public class Utils {

private static final Logger LOGGER = Logger.getLogger(Utils.class.getName());
private static final Pattern REVISION = Pattern.compile("(\\d++).*");

/**
* Retrieves the configured Android SDK root directory.
*
* @return The configured Android SDK root, if any. May include un-expanded variables.
*/
public static String getConfiguredAndroidHome() {
DescriptorImpl descriptor = Hudson.getInstance().getDescriptorByType(DescriptorImpl.class);
DescriptorImpl descriptor = Jenkins.getInstance().getDescriptorByType(DescriptorImpl.class);
if (descriptor != null) {
return descriptor.androidHome;
}
@@ -315,7 +315,7 @@ private static boolean validateSDKCheckIfAllNecessaryFilesExists(final File sdkR
public static ValidationResult validateAndroidHome(final File sdkRoot, final boolean allowLegacy, final boolean fromWebConfig) {

// This can be used to check the existence of a file on the server, so needs to be protected
if (fromWebConfig && !Hudson.getInstance().hasPermission(Hudson.ADMINISTER)) {
if (fromWebConfig && !Jenkins.getInstance().hasPermission(Hudson.ADMINISTER)) {
return ValidationResult.ok();
}

@@ -52,9 +52,10 @@ public FormValidation getFormValidation() {
} else {
return FormValidation.error(message);
}
case OK:
default:
return FormValidation.ok();
}

return FormValidation.ok();
}

public boolean isFatal() {

0 comments on commit 779118b

Please sign in to comment.
You can’t perform that action at this time.