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

Clean imports #146

Merged
merged 7 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<minimumJavaVersion>1.8.0</minimumJavaVersion>
<!-- Compatible since is used to warn the user that this new version of the plugin is not compatible
with earlier version than the one we mention below.
https://wiki.jenkins.io/display/JENKINS/Marking+a+new+plugin+version+as+incompatible+with+older+versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import hudson.DescriptorExtensionList;
import hudson.EnvVars;
import hudson.ExtensionPoint;
import hudson.Launcher;
import hudson.model.*;
import hudson.model.AbstractProject;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Result;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.pretestedintegration.exceptions.IntegrationFailedException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.IntegrationUnknownFailureException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.NothingToDoException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.UnsupportedConfigurationException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
Expand Down Expand Up @@ -67,11 +65,7 @@ public static DescriptorExtensionList<AbstractSCMBridge, SCMBridgeDescriptor<Abs
* @return all the Integration Strategy Descriptors
*/
public static List<IntegrationStrategyDescriptor<?>> getBehaviours() {
List<IntegrationStrategyDescriptor<?>> behaviours = new ArrayList<>();
for (IntegrationStrategyDescriptor<?> behaviour : IntegrationStrategy.all()) {
behaviours.add(behaviour);
}
return behaviours;
return new ArrayList<>(IntegrationStrategy.all());
}

/**
Expand All @@ -86,11 +80,7 @@ public Descriptor<AbstractSCMBridge> getDescriptor() {
* @return all the SCM Bridge Descriptors
*/
public static List<SCMBridgeDescriptor<?>> getDescriptors() {
List<SCMBridgeDescriptor<?>> descriptors = new ArrayList<>();
for (SCMBridgeDescriptor<?> descriptor : all()) {
descriptors.add(descriptor);
}
return descriptors;
return new ArrayList<>(all());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import hudson.DescriptorExtensionList;
import hudson.ExtensionPoint;
import hudson.Launcher;
import hudson.model.*;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.pretestedintegration.exceptions.*;

/**
* Abstract class representing a strategy to apply when merging pretested commits into the integration integrationBranch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import javaposse.jobdsl.dsl.RequiresPlugin;
import javaposse.jobdsl.dsl.helpers.publisher.PublisherContext;
import javaposse.jobdsl.dsl.helpers.scm.GitExtensionContext;
import javaposse.jobdsl.dsl.helpers.wrapper.WrapperContext;
import javaposse.jobdsl.plugin.ContextExtensionPoint;
import javaposse.jobdsl.plugin.DslExtensionMethod;
import org.jenkinsci.plugins.pretestedintegration.scm.git.AccumulatedCommitStrategy;
import org.jenkinsci.plugins.pretestedintegration.scm.git.GitBridge;
import org.jenkinsci.plugins.pretestedintegration.scm.git.PretestedIntegrationAsGitPluginExt;
import org.jenkinsci.plugins.pretestedintegration.scm.git.SquashCommitStrategy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
FilePath wsForUs = rtd != null ? rtd.getWorkingDirectory(scm, proj, build.getWorkspace(), build.getEnvironment(listener), listener) : build.getWorkspace();
printWarningIfUnsupported(proj.getClass(), listener);
if(wsForUs != null) {
perform((Run) build, wsForUs, launcher, listener);
perform((Run<?, ?>) build, wsForUs, launcher, listener);
} else {
throw new InterruptedException("[PREINT] Fatal: Workspace is null");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jenkinsci.plugins.pretestedintegration;

import hudson.model.Descriptor.FormException;
import hudson.model.Descriptor;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.jenkinsci.plugins.pretestedintegration.scm.git;

import hudson.*;
import hudson.model.*;
import hudson.AbortException;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.plugins.git.Branch;
import hudson.plugins.git.GitException;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.extensions.impl.RelativeTargetDirectory;
import hudson.scm.SCM;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jgit.lib.ObjectId;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.jenkinsci.plugins.pretestedintegration.AbstractSCMBridge;
import org.jenkinsci.plugins.pretestedintegration.IntegrationStrategy;
Expand All @@ -18,7 +19,6 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import javax.annotation.CheckForNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -231,7 +231,7 @@ public void evalBranchConfigurations(Branch triggeredBranch, String integrationB
}
}

public void handleIntegrationExceptionsGit(Run run, TaskListener listener, Exception e, GitClient client) throws IOException, InterruptedException {
public void handleIntegrationExceptionsGit(Run<?, ?> run, TaskListener listener, Exception e, GitClient client) throws IOException, InterruptedException {
if (e instanceof NothingToDoException) {
run.setResult(Result.NOT_BUILT);
String logMessage = LOG_PREFIX + String.format("%s - setUp() - NothingToDoException - %s", LOG_PREFIX, e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jenkinsci.plugins.pretestedintegration.exceptions.UnsupportedConfigurationException;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -195,16 +196,12 @@ public GitClientType getRequiredClient() {
public static class DescriptorImpl extends GitSCMExtensionDescriptor {

@Override
public String getDisplayName() {
public @Nonnull String getDisplayName() {
return "Use pretested integration";
}

public List<IntegrationStrategyDescriptor<?>> getIntegrationStrategies() {
List<IntegrationStrategyDescriptor<?>> list = new ArrayList<>();
for (IntegrationStrategyDescriptor<?> descr : IntegrationStrategy.all()) {
list.add(descr);
}
return list;
return new ArrayList<>(IntegrationStrategy.all());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package org.jenkinsci.plugins.pretestedintegration.scm.git;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.plugins.git.Branch;
import hudson.plugins.git.Revision;
import hudson.plugins.git.util.BuildData;
import org.eclipse.jgit.lib.ObjectId;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.jenkinsci.plugins.pretestedintegration.exceptions.*;
import org.jenkinsci.plugins.pretestedintegration.exceptions.NothingToDoException;
import org.jenkinsci.plugins.pretestedintegration.exceptions.UnsupportedConfigurationException;

import java.io.IOException;
import java.io.PrintStream;
import java.util.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package org.jenkinsci.plugins.pretestedintegration.scm.git;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import jenkins.plugins.git.traits.GitSCMExtensionTrait;
import jenkins.plugins.git.traits.GitSCMExtensionTraitDescriptor;
import org.jenkinsci.plugins.pretestedintegration.IntegrationStrategy;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.Nonnull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
*/
public abstract class RepositoryListenerAwareCallback<T> implements RepositoryCallback<T> {

/**
* The TaskListener for use in invoke
*/
// public final TaskListener listener;

/**
* Constructor for a RepositoryListenerAwareCallback
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class SquashCommitStrategy extends GitIntegrationStrategy {
public SquashCommitStrategy() {
}

private void doTheIntegration(Run build, TaskListener listener, GitBridge gitbridge, ObjectId commitId, GitClient client, String expandedIntegrationBranch, Branch triggerBranch) throws IntegrationFailedException, NothingToDoException, UnsupportedConfigurationException, IntegrationUnknownFailureException {
private void doTheIntegration(Run<?, ?> build, TaskListener listener, GitBridge gitbridge, ObjectId commitId, GitClient client, String expandedIntegrationBranch, Branch triggerBranch) throws IntegrationFailedException, NothingToDoException, UnsupportedConfigurationException, IntegrationUnknownFailureException {
{
int commitCount;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.jenkinsci.plugins.pretestedintegration.integration.scm.git;

import hudson.model.TaskListener;

import java.io.File;

import org.apache.commons.io.FileUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public static FreeStyleProject configurePretestedIntegrationPlugin(JenkinsRule r

return project;
}

private static String createCommitMessageForRepo(String repositoryRootFolder, String branch, String message) {
return String.format("%s-%s-%s", message, branch, repositoryRootFolder);
}
Expand Down Expand Up @@ -757,11 +757,8 @@ public static boolean checkForLineInFile(File file, String stringToCheck) throws
inputReader.close();

return result;
} catch (FileNotFoundException e1) {
System.out.println(String.format("TestUtilsFactory.checkForLineInFile throwed an exception: %s", e1.toString()));
return false;
} catch (IOException ep) {
System.out.println(String.format("TestUtilsFactory.checkForLineInFile throwed an exception: %s", ep.toString()));
} catch (IOException e1) {
System.out.println(String.format("TestUtilsFactory.checkForLineInFile threw an exception: %s", e1.toString()));
return false;
}
}
Expand Down