From d34d9a97294ba185a5574899a67c76bec764bbb1 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 29 Sep 2015 10:26:21 +0200 Subject: [PATCH] Remove any dependency on SQ SNAPSHOT --- sonar-runner-batch/pom.xml | 17 +- .../org/sonar/batch/bootstrapper/Batch.java | 149 ++++++++++++++++++ .../batch/bootstrapper/IssueListener.java | 135 ++++++++++++++++ .../sonar/batch/bootstrapper/LogOutput.java | 33 ++++ .../batch/bootstrapper/package-info.java | 23 +++ travis.sh | 4 - 6 files changed, 356 insertions(+), 5 deletions(-) create mode 100644 sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java create mode 100644 sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/IssueListener.java create mode 100644 sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java create mode 100644 sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/package-info.java diff --git a/sonar-runner-batch/pom.xml b/sonar-runner-batch/pom.xml index 20e039d..ff19533 100644 --- a/sonar-runner-batch/pom.xml +++ b/sonar-runner-batch/pom.xml @@ -10,7 +10,7 @@ SonarQube Runner - Batch - 5.2-SNAPSHOT + 4.5.1 @@ -50,6 +50,12 @@ junit test + + org.assertj + assertj-core + 2.1.0 + test + org.mockito mockito-all @@ -59,6 +65,15 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + **/org/sonar/batch/bootstrapper/* + + + org.apache.maven.plugins maven-shade-plugin diff --git a/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java new file mode 100644 index 0000000..60f1465 --- /dev/null +++ b/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java @@ -0,0 +1,149 @@ +/* + * SonarQube Runner - Batch + * Copyright (C) 2011 SonarSource + * sonarqube@googlegroups.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.batch.bootstrapper; + +import java.util.List; +import java.util.Map; +import org.picocontainer.annotations.Nullable; + +/** + * Entry point for sonar-runner 2.1. + * + * @since 2.14 + */ +public final class Batch { + + private Batch(Builder builder) { + } + + public LoggingConfiguration getLoggingConfiguration() { + return null; + } + + /** + * @deprecated since 4.4 use {@link #start()}, {@link #executeTask(Map)} and then {@link #stop()} + */ + @Deprecated + public synchronized Batch execute() { + return this; + } + + /** + * @since 4.4 + */ + public synchronized Batch start() { + return start(false); + } + + public synchronized Batch start(boolean forceSync) { + return this; + } + + /** + * @since 4.4 + */ + public Batch executeTask(Map analysisProperties, Object... components) { + return this; + } + + /** + * @since 5.2 + */ + public Batch executeTask(Map analysisProperties, IssueListener issueListener) { + return this; + } + + /** + * @since 5.2 + */ + public Batch syncProject(String projectKey) { + return this; + } + + /** + * @since 4.4 + */ + public synchronized void stop() { + } + + private void doStop(boolean swallowException) { + } + + private void configureLogging() { + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + + private Builder() { + } + + public Builder setEnvironment(EnvironmentInformation env) { + return this; + } + + public Builder setComponents(List l) { + return this; + } + + public Builder setLogOutput(@Nullable LogOutput logOutput) { + return this; + } + + /** + * @deprecated since 3.7 use {@link #setBootstrapProperties(Map)} + */ + @Deprecated + public Builder setGlobalProperties(Map globalProperties) { + return this; + } + + public Builder setBootstrapProperties(Map bootstrapProperties) { + return this; + } + + public Builder addComponents(Object... components) { + return this; + } + + public Builder addComponent(Object component) { + return this; + } + + public boolean isEnableLoggingConfiguration() { + return false; + } + + /** + * Logback is configured by default. It can be disabled, but n this case the batch bootstrapper must provide its + * own implementation of SLF4J. + */ + public Builder setEnableLoggingConfiguration(boolean b) { + return this; + } + + public Batch build() { + return new Batch(this); + } + } +} diff --git a/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/IssueListener.java b/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/IssueListener.java new file mode 100644 index 0000000..193ae46 --- /dev/null +++ b/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/IssueListener.java @@ -0,0 +1,135 @@ +/* + * SonarQube Runner - Batch + * Copyright (C) 2011 SonarSource + * sonarqube@googlegroups.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.batch.bootstrapper; + +public interface IssueListener { + void handle(Issue issue); + + class Issue { + private String key; + private String componentKey; + private Integer line; + private String message; + private String ruleKey; + private String ruleName; + private String status; + private String resolution; + private boolean isNew; + private String assigneeLogin; + private String assigneeName; + private String severity; + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getComponentKey() { + return componentKey; + } + + public void setComponentKey(String componentKey) { + this.componentKey = componentKey; + } + + public Integer getLine() { + return line; + } + + public void setLine(Integer line) { + this.line = line; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getRuleKey() { + return ruleKey; + } + + public void setRuleKey(String ruleKey) { + this.ruleKey = ruleKey; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String ruleName) { + this.ruleName = ruleName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getResolution() { + return resolution; + } + + public void setResolution(String resolution) { + this.resolution = resolution; + } + + public boolean isNew() { + return isNew; + } + + public void setNew(boolean isNew) { + this.isNew = isNew; + } + + public String getAssigneeLogin() { + return assigneeLogin; + } + + public void setAssigneeLogin(String assigneeLogin) { + this.assigneeLogin = assigneeLogin; + } + + public String getAssigneeName() { + return assigneeName; + } + + public void setAssigneeName(String assigneeName) { + this.assigneeName = assigneeName; + } + } +} diff --git a/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java b/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java new file mode 100644 index 0000000..f4e0bcb --- /dev/null +++ b/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java @@ -0,0 +1,33 @@ +/* + * SonarQube Runner - Batch + * Copyright (C) 2011 SonarSource + * sonarqube@googlegroups.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.batch.bootstrapper; + +/** + * Allow to redirect batch logs to a custom output. By defaults logs are written to System.out + * @since 5.2 + */ +public interface LogOutput { + + void log(String formattedMessage, Level level); + + enum Level { + ERROR, WARN, INFO, DEBUG, TRACE; + } +} diff --git a/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/package-info.java b/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/package-info.java new file mode 100644 index 0000000..59c2684 --- /dev/null +++ b/sonar-runner-batch/src/main/java/org/sonar/batch/bootstrapper/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube Runner - Batch + * Copyright (C) 2011 SonarSource + * sonarqube@googlegroups.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +/** + * This package contains duplicated classes to avoid a dependency on SQ batch + */ +package org.sonar.batch.bootstrapper; diff --git a/travis.sh b/travis.sh index a3bb399..abaceeb 100755 --- a/travis.sh +++ b/travis.sh @@ -13,16 +13,12 @@ case "$TESTS" in CI) installTravisTools - build_snapshot "SonarSource/sonarqube" - mvn verify -B -e -V ;; IT-DEV) installTravisTools - build_snapshot "SonarSource/sonarqube" - mvn install -Dsource.skip=true -Denforcer.skip=true -Danimal.sniffer.skip=true -Dmaven.test.skip=true cd it -- 2.39.5