diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-11-04 21:15:35 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-11-05 09:34:47 +0100 |
commit | e7885c175b5e078bd93a58650d99a32224b3679b (patch) | |
tree | cd238ec9eb4c74bcc915b200815c11fff69f6bf0 /sonar-plugin-api | |
parent | e2379a7ffa7e879ededf5f160f55eba26a785a6c (diff) | |
download | sonarqube-e7885c175b5e078bd93a58650d99a32224b3679b.tar.gz sonarqube-e7885c175b5e078bd93a58650d99a32224b3679b.zip |
SONAR-6658 Remove ProjectClasspath, ProjectFileSystem, sonar.binaries, sonar.libraries
Diffstat (limited to 'sonar-plugin-api')
5 files changed, 3 insertions, 445 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java index 137437fae4f..6a9bf9b164f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java @@ -19,14 +19,12 @@ */ package org.sonar.api.batch; -import org.sonar.api.resources.Language; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.ProjectFileSystem; -import org.sonar.api.resources.Resource; - import java.io.File; import java.nio.charset.Charset; import java.util.List; +import org.sonar.api.resources.Language; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.Resource; /** * @since 1.10 @@ -56,10 +54,6 @@ public abstract class AbstractSourceImporter implements Sensor { } - protected void analyse(ProjectFileSystem fileSystem, SensorContext context) { - // Do not remove for backward compatibility - } - protected void parseDirs(SensorContext context, List<File> files, List<File> sourceDirs, boolean unitTest, Charset sourcesEncoding) { // Do not remove for backward compatibility } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/ProjectClasspath.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/ProjectClasspath.java deleted file mode 100644 index 8b6af71cf3c..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/ProjectClasspath.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.api.batch; - -import com.google.common.collect.Lists; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.List; -import org.sonar.api.BatchComponent; -import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.resources.ProjectFileSystem; -import org.sonar.api.utils.SonarException; - -/** - * @since 2.2 - * @deprecated since 4.5 this is some Java specific stuff that should by handled by SQ Java plugin - */ -@Deprecated -public class ProjectClasspath implements BatchComponent { - - private final ProjectDefinition def; - private final ProjectFileSystem projectFileSystem; - private List<File> elements; - private URLClassLoader classloader; - - public ProjectClasspath(ProjectDefinition def, ProjectFileSystem projectFileSystem) { - this.def = def; - this.projectFileSystem = projectFileSystem; - } - - public URLClassLoader getClassloader() { - if (classloader == null) { - classloader = createClassLoader(); - } - return classloader; - } - - /** - * bytecode directory + JARs (dependencies) - */ - public List<File> getElements() { - if (elements == null) { - elements = createElements(); - } - return elements; - } - - protected URLClassLoader createClassLoader() { - try { - List<URL> urls = Lists.newArrayList(); - for (File file : getElements()) { - urls.add(file.toURI().toURL()); - } - return new URLClassLoader(urls.toArray(new URL[urls.size()]), null); - - } catch (MalformedURLException e) { - throw new SonarException("Fail to create the project classloader. Classpath element is unvalid.", e); - } - } - - protected List<File> createElements() { - List<File> e = Lists.newArrayList(); - for (String path : def.getBinaries()) { - e.add(projectFileSystem.resolvePath(path)); - } - for (String path : def.getLibraries()) { - e.add(projectFileSystem.resolvePath(path)); - } - return e; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java index 5c083a107cd..e58e97e8ec7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java @@ -27,7 +27,6 @@ import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ToStringBuilder; import org.sonar.api.CoreProperties; -import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.component.Component; import org.sonar.api.config.Settings; @@ -72,7 +71,6 @@ public class Project extends Resource implements Component { } private String branch; - private ProjectFileSystem fileSystem; private String name; private String description; private Language language; @@ -340,26 +338,6 @@ public class Project extends Resource implements Component { return analysisDate; } - /** - * Note: it's better to get a reference on ProjectFileSystem as an IoC dependency (constructor parameter) - * @deprecated since 3.5 use {@link FileSystem} instead - */ - @Deprecated - public ProjectFileSystem getFileSystem() { - return fileSystem; - } - - /** - * For internal use only. - * - * @deprecated since 2.6. See http://jira.sonarsource.com/browse/SONAR-2126 - */ - @Deprecated - public Project setFileSystem(ProjectFileSystem fs) { - this.fileSystem = fs; - return this; - } - public static Project createFromMavenIds(String groupId, String artifactId) { return createFromMavenIds(groupId, artifactId, null); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectFileSystem.java deleted file mode 100644 index 3780adc4a13..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectFileSystem.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.api.resources; - -import org.sonar.api.BatchComponent; -import org.sonar.api.batch.fs.FileSystem; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.List; - -/** - * @since 1.10 - * @deprecated since 3.5 replaced by {@link FileSystem} - */ -@Deprecated -public interface ProjectFileSystem extends BatchComponent { - /** - * Source encoding. - * Never null, it returns the default platform charset if it is not defined in project. - * (Maven property 'project.build.sourceEncoding'). - */ - Charset getSourceCharset(); - - /** - * Project root directory. - */ - File getBasedir(); - - /** - * Build directory. It's "${basedir}/target" by default in Maven projects. - */ - File getBuildDir(); - - /** - * Directory where classes are placed. It's "${basedir}/target/classes" by default in Maven projects. - */ - File getBuildOutputDir(); - - /** - * The list of existing directories with sources - */ - List<File> getSourceDirs(); - - /** - * Adds a source directory - * - * @return the current object - * @deprecated since 2.6 - ProjectFileSystem should be immutable - * See http://jira.sonarsource.com/browse/SONAR-2126 - */ - @Deprecated - ProjectFileSystem addSourceDir(File dir); - - /** - * The list of existing directories with tests - */ - List<File> getTestDirs(); - - /** - * Adds a test directory - * - * @return the current object - * @deprecated since 2.6 - ProjectFileSystem should be immutable - * See http://jira.sonarsource.com/browse/SONAR-2126 - */ - @Deprecated - ProjectFileSystem addTestDir(File dir); - - /** - * @return the directory where reporting is placed. Default is target/sites - */ - File getReportOutputDir(); - - /** - * @return the Sonar working directory. Default is "target/sonar" - */ - File getSonarWorkingDirectory(); - - /** - * @return file in canonical form from specified path. Path can be absolute or relative to project basedir. - * For example resolvePath("pom.xml") or resolvePath("src/main/java") - * @deprecated since 5.0 use {@link FileSystem#resolvePath(String)} - */ - File resolvePath(String path); - - /** - * Source files, excluding unit tests and files matching project exclusion patterns. - * - * @param langs language filter. Check all files, whatever their language, if null or empty. - * @deprecated since 2.6 use {@link #mainFiles(String...)} instead. - * See http://jira.sonarsource.com/browse/SONAR-2126 - */ - @Deprecated - List<File> getSourceFiles(Language... langs); - - /** - * Java source files, excluding unit tests and files matching project exclusion patterns. Shortcut for getSourceFiles(Java.INSTANCE) - * - * @deprecated since 2.6 use {@link #mainFiles(String...)} instead. - * See http://jira.sonarsource.com/browse/SONAR-2126 - */ - @Deprecated - List<File> getJavaSourceFiles(); - - /** - * Check if the project has Java files, excluding unit tests and files matching project exclusion patterns. - * - * @deprecated since 2.6 - API should be language agnostic - */ - @Deprecated - boolean hasJavaSourceFiles(); - - /** - * Unit test files, excluding files matching project exclusion patterns. - * - * @deprecated since 2.6 use {@link #testFiles(String...)} instead. - * See http://jira.sonarsource.com/browse/SONAR-2126 - */ - @Deprecated - List<File> getTestFiles(Language... langs); - - /** - * Check if the project has unit test files, excluding files matching project exclusion patterns. - * - * @deprecated since 2.6 - use language key instead of Language object - */ - @Deprecated - boolean hasTestFiles(Language lang); - - /** - * Save data into a new file of Sonar working directory. - * - * @return the created file - */ - File writeToWorkingDirectory(String content, String fileName) throws IOException; - - File getFileFromBuildDirectory(String filename); - - Resource toResource(File file); - - /** - * Source files, excluding unit tests and files matching project exclusion patterns. - * - * @param langs language filter. If null or empty, will return empty list - * @since 2.6 - */ - List<InputFile> mainFiles(String... langs); - - /** - * Source files of unit tests. Exclusion patterns are not applied. - * - * @param langs language filter. If null or empty, will return empty list - * @since 2.6 - */ - List<InputFile> testFiles(String... langs); - -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/SimpleProjectFileSystem.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/SimpleProjectFileSystem.java deleted file mode 100644 index 1660307d3a1..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/test/SimpleProjectFileSystem.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 02110-1301, USA. - */ -package org.sonar.api.test; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.CharEncoding; -import org.apache.commons.lang.NotImplementedException; -import org.sonar.api.resources.InputFile; -import org.sonar.api.resources.Language; -import org.sonar.api.resources.ProjectFileSystem; -import org.sonar.api.resources.Resource; -import org.sonar.api.utils.SonarException; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.List; - -public class SimpleProjectFileSystem implements ProjectFileSystem { - - private File basedir; - - public SimpleProjectFileSystem(File basedir) { - this.basedir = basedir; - } - - public Charset getSourceCharset() { - return Charset.defaultCharset(); - } - - private File createDir(String path) { - try { - File dir = new File(basedir, path); - FileUtils.forceMkdir(dir); - return dir; - - } catch (IOException e) { - throw new SonarException(e); - } - } - - public File getBasedir() { - return basedir; - } - - public File getBuildDir() { - return createDir("target"); - } - - public File getBuildOutputDir() { - return createDir("target/classes"); - } - - public List<File> getSourceDirs() { - return Arrays.asList(createDir("src/main")); - } - - public ProjectFileSystem addSourceDir(File dir) { - throw new NotImplementedException(); - } - - public List<File> getTestDirs() { - return Arrays.asList(createDir("src/test")); - } - - public ProjectFileSystem addTestDir(File dir) { - throw new NotImplementedException(); - } - - public File getReportOutputDir() { - return createDir("target/site"); - } - - public File getSonarWorkingDirectory() { - return createDir("target/sonar"); - } - - public File resolvePath(String path) { - return null; - } - - public List<File> getSourceFiles(Language... langs) { - return null; - } - - public List<File> getJavaSourceFiles() { - return null; - } - - public boolean hasJavaSourceFiles() { - return false; - } - - public List<File> getTestFiles(Language... langs) { - return null; - } - - public boolean hasTestFiles(Language lang) { - return false; - } - - public File writeToWorkingDirectory(String content, String filename) throws IOException { - File file = new File(getSonarWorkingDirectory(), filename); - FileUtils.writeStringToFile(file, content, CharEncoding.UTF_8); - return file; - } - - public File getFileFromBuildDirectory(String filename) { - return null; - } - - public Resource toResource(File file) { - return null; - } - - /** - * @since 2.6 - */ - public List<InputFile> mainFiles(String... lang) { - return null; - } - - /** - * @since 2.6 - */ - public List<InputFile> testFiles(String... lang) { - return null; - } - -} |