Skip to content

Commit

Permalink
Clean up imports and whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Jan 30, 2023
1 parent 17d1cda commit 25ba3f7
Show file tree
Hide file tree
Showing 49 changed files with 248 additions and 225 deletions.
50 changes: 44 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<parent>
<groupId>org.jenkins-ci</groupId>
<artifactId>jenkins</artifactId>
<version>1.94</version>
Expand All @@ -19,8 +19,8 @@
<scm>
<connection>scm:git:ssh://git@github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:ssh://git@github.com/${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
<url>https://github.com/${gitHubRepo}</url>
</scm>

<properties>
Expand Down Expand Up @@ -164,21 +164,59 @@

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.31.0</version>
<configuration>
<java>
<endWithNewline />
<importOrder />
<indent>
<spaces>true</spaces>
</indent>
<removeUnusedImports />
<trimTrailingWhitespace />
</java>
<pom>
<sortPom>
<encoding>${project.build.sourceEncoding}</encoding>
<lineSeparator>\n</lineSeparator>
<expandEmptyElements>false</expandEmptyElements>
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
<sortDependencies>scope,groupId,artifactId</sortDependencies>
<sortDependencyExclusions>groupId,artifactId</sortDependencyExclusions>
<sortPlugins>scope,groupId,artifactId</sortPlugins>
<sortModules>true</sortModules>
<sortExecutions>true</sortExecutions>
</sortPom>
</pom>
</configuration>
<executions>
<execution>
<!-- Runs in verify phase by default -->
<goals>
<!-- Can be disabled using -Dspotless.check.skip -->
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
29 changes: 13 additions & 16 deletions src/main/java/org/jenkins/tools/test/CliOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,20 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jenkins.tools.test;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.jenkins.tools.test.model.TestStatus;
package org.jenkins.tools.test;

import com.beust.jcommander.IParameterValidator;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jenkins.tools.test.model.TestStatus;

/**
* POJO containing CLI arguments &amp; help.
Expand Down Expand Up @@ -132,7 +129,7 @@ public class CliOptions {

@Parameter(names="-hookPrefixes", description = "Prefixes of the extra hooks' classes")
private String hookPrefixes;

@Parameter(names="-externalHooksJars", description = "Comma-separated list of external hooks jar file locations", listConverter = FileListConverter.class, validateWith = FileValidator.class)
private List<File> externalHooksJars;

Expand All @@ -144,10 +141,10 @@ public class CliOptions {

@Parameter(names = "-failOnError", description = "Immediately if the PCT run fails for a plugin. Error status will be also reported as a return code")
private boolean failOnError;
@Parameter(names = "-storeAll",
description = "By default only failed tests are stored in PCT report file. \n" +
"If set, the PCT will store ALL executed test names for each plugin in report file. \n" +

@Parameter(names = "-storeAll",
description = "By default only failed tests are stored in PCT report file. \n" +
"If set, the PCT will store ALL executed test names for each plugin in report file. \n" +
"Disabled by default because it may bloat reports for plugins which thousands of tests."
)
private Boolean storeAll = null;
Expand Down Expand Up @@ -218,7 +215,7 @@ public String getCacheThresholdStatus() {
public String getHookPrefixes() {
return hookPrefixes;
}

public List<File> getExternalHooksJars() {
return externalHooksJars != null ? Collections.unmodifiableList(externalHooksJars) : null;
}
Expand All @@ -244,7 +241,7 @@ public String getTestJavaArgs() {
public boolean isFailOnError() {
return failOnError;
}

public Boolean isStoreAll() {
return storeAll;
}
Expand All @@ -260,7 +257,7 @@ public List<File> convert(String files) {
return fileList;
}
}

public static class FileValidator implements IParameterValidator {
@Override
public void validate(String name, String value) throws ParameterException {
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/org/jenkins/tools/test/PluginCompatTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.jenkins.tools.test;

import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -65,9 +66,10 @@
import net.sf.json.JSONObject;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.jenkins.tools.test.exception.ExecutedTestNamesSolverException;
import org.jenkins.tools.test.exception.PluginSourcesUnavailableException;
import org.jenkins.tools.test.exception.PomExecutionException;
import org.jenkins.tools.test.exception.ExecutedTestNamesSolverException;
import org.jenkins.tools.test.exception.PomTransformationException;
import org.jenkins.tools.test.maven.ExternalMavenRunner;
import org.jenkins.tools.test.maven.MavenRunner;
import org.jenkins.tools.test.model.MavenCoordinates;
Expand All @@ -84,7 +86,6 @@
import org.jenkins.tools.test.model.hook.PluginCompatTesterHooks;
import org.jenkins.tools.test.util.ExecutedTestNamesSolver;
import org.jenkins.tools.test.util.StreamGobbler;
import org.jenkins.tools.test.exception.PomTransformationException;

/**
* Frontend for plugin compatibility tests
Expand All @@ -107,7 +108,7 @@ public PluginCompatTester(PluginCompatTesterConfig config){
runner = new ExternalMavenRunner(config.getExternalMaven());
}

public PluginCompatReport testPlugins()
public PluginCompatReport testPlugins()
throws IOException, PomExecutionException {
PluginCompatTesterHooks pcth = new PluginCompatTesterHooks(config.getHookPrefixes(), config.getExternalHooksJars(), config.getExcludeHooks());
// Providing XSL Stylesheet along xml report file
Expand Down Expand Up @@ -158,7 +159,6 @@ public PluginCompatReport testPlugins()
}
}


PluginCompatReport report = PluginCompatReport.fromXml(config.reportFile);

MavenCoordinates coreCoordinates = new MavenCoordinates("org.jenkins-ci.main", "jenkins-war", data.core.version);
Expand Down Expand Up @@ -233,8 +233,8 @@ public PluginCompatReport testPlugins()
status = TestStatus.COMPILATION_ERROR;
} else if (!e.getTestDetails().hasBeenExecuted()) { // testing was not able to start properly (i.e: invalid exclusion list file format)
status = TestStatus.INTERNAL_ERROR;
} else if (e.getTestDetails().hasFailures()) {
status = TestStatus.TEST_FAILURES;
} else if (e.getTestDetails().hasFailures()) {
status = TestStatus.TEST_FAILURES;
} else { // ???
status = TestStatus.INTERNAL_ERROR;
}
Expand All @@ -252,7 +252,6 @@ public PluginCompatReport testPlugins()
}
}


File buildLogFile = createBuildLogFile(config.reportFile, plugin.name, plugin.version, coreCoordinates);
String buildLogFilePath = "";
if(buildLogFile.exists()){
Expand Down Expand Up @@ -474,7 +473,7 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates,
}

public void cloneFromSCM(PomData pomData, String name, String version, File checkoutDirectory, String tag) throws IOException {
String scmTag = !(tag.equals("")) ? tag : getScmTag(pomData, name, version);
String scmTag = !(tag.equals("")) ? tag : getScmTag(pomData, name, version);
String connectionURLPomData = pomData.getConnectionUrl();
List<String> connectionURLs = new ArrayList<>();
connectionURLs.add(connectionURLPomData);
Expand Down Expand Up @@ -721,7 +720,7 @@ private UpdateSite.Data scanWAR(File war, @NonNull Map<String, String> pluginGro
}

/**
* Provides the Maven module used for a plugin on a {@code mvn [...] -pl} operation in the parent path
* Provides the Maven module used for a plugin on a {@code mvn [...] -pl} operation in the parent path
*/
public static String getMavenModule(String plugin, File pluginPath, MavenRunner runner, MavenRunner.Config mavenConfig) throws PomExecutionException, IOException {
String absolutePath = pluginPath.getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.jenkins.tools.test;

import com.beust.jcommander.JCommander;
Expand All @@ -34,9 +35,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jenkins.tools.test.exception.PomExecutionException;
import org.jenkins.tools.test.logging.LoggingConfiguration;
import org.jenkins.tools.test.model.PluginCompatTesterConfig;
import org.jenkins.tools.test.exception.PomExecutionException;
import org.jenkins.tools.test.model.TestStatus;

/**
Expand All @@ -58,7 +59,7 @@ public class PluginCompatTesterCli {
value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
justification =
"We're already checking for null in each relevant instance, so why does SpotBugs complain?")
public static void main(String[] args) throws IOException, PomExecutionException {
public static void main(String[] args) throws IOException, PomExecutionException {
CliOptions options = new CliOptions();
JCommander jcommander = null;
try {
Expand Down Expand Up @@ -139,7 +140,7 @@ public static void main(String[] args) throws IOException, PomExecutionException
//TODO: also interpolate it for the case when a single plugin passed?
config.setFailOnError(true);
}

if (options.isStoreAll() != null) {
config.setStoreAll(options.isStoreAll().booleanValue());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public ExecutedTestNamesSolverException(String msg, Exception e) {
public ExecutedTestNamesSolverException(Exception e) {
super(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.jenkins.tools.test.exception;

/**
Expand All @@ -33,7 +34,7 @@
*/
public class PluginSourcesUnavailableException extends Exception {

public PluginSourcesUnavailableException(String message, Throwable cause){
super(message, cause);
}
public PluginSourcesUnavailableException(String message, Throwable cause){
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.jenkins.tools.test.exception;

import java.io.PrintWriter;
Expand Down Expand Up @@ -77,7 +78,7 @@ public String getErrorMessage(){
public List<String> getPomWarningMessages() {
return pomWarningMessages;
}

public ExecutedTestNamesDetails getTestDetails() {
return testDetails;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.jenkins.tools.test.exception;

/**
Expand All @@ -32,7 +33,7 @@
*/
public class PomTransformationException extends Exception {

public PomTransformationException(String message, Throwable cause){
super(message, cause);
}
public PomTransformationException(String message, Throwable cause){
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.jenkins.tools.test.PluginCompatTester;
import org.jenkins.tools.test.model.PluginCompatTesterConfig;
import org.jenkins.tools.test.model.PomData;
Expand All @@ -23,15 +22,14 @@ public abstract class AbstractMultiParentHook extends PluginCompatTesterHookBefo
private static final Logger LOGGER = Logger.getLogger(AbstractMultiParentHook.class.getName());

protected boolean firstRun = true;

private PomData pomData;

@Override
public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception {
PluginCompatTesterConfig config = (PluginCompatTesterConfig)moreInfo.get("config");
UpdateSite.Plugin currentPlugin = (UpdateSite.Plugin)moreInfo.get("plugin");


// We should not execute the hook if using localCheckoutDir
boolean shouldExecuteHook = config.getLocalCheckoutDir() == null || !config.getLocalCheckoutDir().exists();

Expand Down Expand Up @@ -77,13 +75,13 @@ public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception

private void cloneFromSCM(UpdateSite.Plugin currentPlugin, File parentPath, String scmTag, String url, String fallbackGitHubOrganization)
throws IOException {

List<String> connectionURLs = new ArrayList<>();
connectionURLs.add(url);
if(fallbackGitHubOrganization != null){
connectionURLs = PluginCompatTester.getFallbackConnectionURL(connectionURLs, url, fallbackGitHubOrganization);
}

IOException lastException = null;
for (String connectionURL: connectionURLs){
if (connectionURL != null) {
Expand All @@ -99,7 +97,7 @@ private void cloneFromSCM(UpdateSite.Plugin currentPlugin, File parentPath, Stri
lastException = e;
}
}

if (lastException != null) {
throw new UncheckedIOException(lastException);
}
Expand Down

0 comments on commit 25ba3f7

Please sign in to comment.