From feb1afef7c9aac12f280185267b8fa77ad87c895 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Thu, 20 Jan 2011 15:05:21 +0300 Subject: SONAR-2126: Change API to work with project * Add natures and exclusions/inclusions to ProjectDirectory * Deprecate ProjectFileSystem and Project.getFileSystem() * Instead of interface ProjectDefinition provide class only for bootstrap of batch --- .../org/sonar/batch/DefaultProjectDefinition.java | 95 ---------------------- .../org/sonar/batch/DefaultProjectDirectory.java | 68 ---------------- .../sonar/batch/bootstrap/ProjectDefinition.java | 95 ++++++++++++++++++++++ 3 files changed, 95 insertions(+), 163 deletions(-) delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/DefaultProjectDefinition.java delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/DefaultProjectDirectory.java create mode 100644 sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectDefinition.java (limited to 'sonar-batch') diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectDefinition.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectDefinition.java deleted file mode 100644 index 82e81da59bd..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectDefinition.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2009 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.batch; - -import com.google.common.collect.Lists; -import org.apache.commons.configuration.Configuration; -import org.sonar.api.project.ProjectDefinition; -import org.sonar.api.project.ProjectDirectory; - -import java.io.File; -import java.util.List; - -public class DefaultProjectDefinition implements ProjectDefinition { - - private String key; - private Configuration configuration; - private File sonarWorkingDirectory; - private File basedir; - private List dirs = Lists.newArrayList(); - private DefaultProjectDefinition parent; - private List modules; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public Configuration getConfiguration() { - return configuration; - } - - public void setConfiguration(Configuration configuration) { - this.configuration = configuration; - } - - public File getSonarWorkingDirectory() { - return sonarWorkingDirectory; - } - - public void setSonarWorkingDirectory(File sonarWorkingDirectory) { - this.sonarWorkingDirectory = sonarWorkingDirectory; - } - - public File getBasedir() { - return basedir; - } - - public void setBasedir(File basedir) { - this.basedir = basedir; - } - - public List getDirs() { - return dirs; - } - - public void addDir(ProjectDirectory dir) { - this.dirs.add(dir); - } - - public ProjectDefinition getParent() { - return parent; - } - - public void setParent(DefaultProjectDefinition parent) { - this.parent = parent; - if (parent != null) { - parent.modules.add(this); - } - } - - public List getModules() { - return modules; - } - -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectDirectory.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectDirectory.java deleted file mode 100644 index 7c080531435..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectDirectory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2009 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.batch; - -import org.sonar.api.project.ProjectDirectory; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -public class DefaultProjectDirectory implements ProjectDirectory { - - private Kind kind; - private File location; - private File outputLocation; - - public Kind getKind() { - return kind; - } - - public void setKind(Kind kind) { - this.kind = kind; - } - - public File getLocation() { - return location; - } - - public void setLocation(File location) { - this.location = location; - } - - public File getOutputLocation() { - return outputLocation; - } - - public void setOutputLocation(File outputLocation) { - this.outputLocation = outputLocation; - } - - public List getInclusionPatterns() { - // TODO see example in ProjectDirectory - return Collections.emptyList(); - } - - public List getExclusionPatterns() { - // TODO see example in ProjectDirectory - return Collections.emptyList(); - } - -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectDefinition.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectDefinition.java new file mode 100644 index 00000000000..578ca9e4a16 --- /dev/null +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectDefinition.java @@ -0,0 +1,95 @@ +package org.sonar.batch.bootstrap; + +import com.google.common.collect.Lists; +import org.apache.commons.configuration.Configuration; +import org.sonar.api.resources.ProjectDirectory; + +import java.io.File; +import java.util.List; + +/** + * Defines project in a form suitable to bootstrap Sonar batch. + * We assume that project is just a set of configuration properties and directories. + * This is a part of bootstrap process, so we should take care about backward compatibility. + * + * @since 2.6 + */ +public class ProjectDefinition { + + private Configuration configuration; + + private File workDir; + private File basedir; + private List dirs = Lists.newArrayList(); + + private ProjectDefinition parent; + private List modules; + + /** + * @return project properties. + */ + public Configuration getConfiguration() { + return configuration; + } + + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } + + /** + * @return Sonar working directory for this project. + * It's "${project.build.directory}/sonar" ("${project.basedir}/target/sonar") for Maven projects. + */ + public File getSonarWorkingDirectory() { + return workDir; + } + + public void setSonarWorkingDirectory(File workDir) { + this.workDir = workDir; + } + + /** + * @return project root directory. + * It's "${project.basedir}" for Maven projects. + */ + public File getBasedir() { + return basedir; + } + + public void setBasedir(File basedir) { + this.basedir = basedir; + } + + /** + * @return project directories. + */ + public List getDirs() { + return dirs; + } + + public void addDir(ProjectDirectory dir) { + this.dirs.add(dir); + } + + /** + * @return parent project. + */ + public ProjectDefinition getParent() { + return parent; + } + + public void setParent(ProjectDefinition parent) { + this.parent = parent; + if (parent != null) { + parent.modules.add(this); + } + } + + /** + * @return list of sub-projects. + */ + public List getModules() { + return modules; + } + +} -- cgit v1.2.3 From 561c33f966fcc7290234077e3ecbde586e2885f0 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Thu, 20 Jan 2011 17:45:08 +0300 Subject: SONAR-2126: Rename ProjectDirectory to FileSystemDirectory --- .../sonar/batch/bootstrap/ProjectDefinition.java | 8 +- .../api/resources/DefaultFileSystemDirectory.java | 98 ++++++++++++++++++++++ .../api/resources/DefaultProjectDirectory.java | 98 ---------------------- .../sonar/api/resources/FileSystemDirectory.java | 81 ++++++++++++++++++ .../org/sonar/api/resources/ProjectDirectory.java | 81 ------------------ 5 files changed, 183 insertions(+), 183 deletions(-) create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultFileSystemDirectory.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectDirectory.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/resources/FileSystemDirectory.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectDirectory.java (limited to 'sonar-batch') diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectDefinition.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectDefinition.java index 578ca9e4a16..d12dc1a9af1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectDefinition.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectDefinition.java @@ -2,7 +2,7 @@ package org.sonar.batch.bootstrap; import com.google.common.collect.Lists; import org.apache.commons.configuration.Configuration; -import org.sonar.api.resources.ProjectDirectory; +import org.sonar.api.resources.FileSystemDirectory; import java.io.File; import java.util.List; @@ -20,7 +20,7 @@ public class ProjectDefinition { private File workDir; private File basedir; - private List dirs = Lists.newArrayList(); + private List dirs = Lists.newArrayList(); private ProjectDefinition parent; private List modules; @@ -63,11 +63,11 @@ public class ProjectDefinition { /** * @return project directories. */ - public List getDirs() { + public List getDirs() { return dirs; } - public void addDir(ProjectDirectory dir) { + public void addDir(FileSystemDirectory dir) { this.dirs.add(dir); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultFileSystemDirectory.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultFileSystemDirectory.java new file mode 100644 index 00000000000..44461fb4772 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultFileSystemDirectory.java @@ -0,0 +1,98 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.api.resources; + +import com.google.common.collect.Lists; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +public class DefaultFileSystemDirectory implements FileSystemDirectory { + + private String nature; + private File location; + private File outputLocation; + private List inclusionPatterns; + private List exclusionPatterns; + + public String getNature() { + return nature; + } + + public DefaultFileSystemDirectory setNature(String nature) { + this.nature = nature; + return this; + } + + public File getLocation() { + return location; + } + + public DefaultFileSystemDirectory setLocation(File location) { + this.location = location; + return this; + } + + public File getOutputLocation() { + return outputLocation; + } + + public DefaultFileSystemDirectory setOutputLocation(File outputLocation) { + this.outputLocation = outputLocation; + return this; + } + + public List getInclusionPatterns() { + if (inclusionPatterns == null) { + return Collections.emptyList(); + } + return Collections.unmodifiableList(inclusionPatterns); + } + + /** + * @param pattern Ant-like inclusion pattern + */ + public DefaultFileSystemDirectory addInclusionPattern(String pattern) { + if (inclusionPatterns == null) { + inclusionPatterns = Lists.newArrayList(); + } + inclusionPatterns.add(pattern); + return this; + } + + public List getExclusionPatterns() { + if (exclusionPatterns == null) { + return Collections.emptyList(); + } + return Collections.unmodifiableList(exclusionPatterns); + } + + /** + * @param pattern Ant-like exclusion pattern + */ + public DefaultFileSystemDirectory addExclusionPattern(String pattern) { + if (exclusionPatterns == null) { + exclusionPatterns = Lists.newArrayList(); + } + exclusionPatterns.add(pattern); + return this; + } +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectDirectory.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectDirectory.java deleted file mode 100644 index bdf4ba1a6bb..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectDirectory.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2009 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.resources; - -import com.google.common.collect.Lists; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -public class DefaultProjectDirectory implements ProjectDirectory { - - private String nature; - private File location; - private File outputLocation; - private List inclusionPatterns; - private List exclusionPatterns; - - public String getNature() { - return nature; - } - - public DefaultProjectDirectory setNature(String nature) { - this.nature = nature; - return this; - } - - public File getLocation() { - return location; - } - - public DefaultProjectDirectory setLocation(File location) { - this.location = location; - return this; - } - - public File getOutputLocation() { - return outputLocation; - } - - public DefaultProjectDirectory setOutputLocation(File outputLocation) { - this.outputLocation = outputLocation; - return this; - } - - public List getInclusionPatterns() { - if (inclusionPatterns == null) { - return Collections.emptyList(); - } - return Collections.unmodifiableList(inclusionPatterns); - } - - /** - * @param pattern Ant-like inclusion pattern - */ - public DefaultProjectDirectory addInclusionPattern(String pattern) { - if (inclusionPatterns == null) { - inclusionPatterns = Lists.newArrayList(); - } - inclusionPatterns.add(pattern); - return this; - } - - public List getExclusionPatterns() { - if (exclusionPatterns == null) { - return Collections.emptyList(); - } - return Collections.unmodifiableList(exclusionPatterns); - } - - /** - * @param pattern Ant-like exclusion pattern - */ - public DefaultProjectDirectory addExclusionPattern(String pattern) { - if (exclusionPatterns == null) { - exclusionPatterns = Lists.newArrayList(); - } - exclusionPatterns.add(pattern); - return this; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/FileSystemDirectory.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/FileSystemDirectory.java new file mode 100644 index 00000000000..17c8298836c --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/FileSystemDirectory.java @@ -0,0 +1,81 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.api.resources; + + +import java.io.File; +import java.util.List; + +/** + * Defines project directory in a form suitable for Sonar. + * This is a part of bootstrap process, so we should take care about backward compatibility. + *

+ * Couple of examples to show what this structure defines: + *

    + *
  • Typical Java project based on Ant might consist of two directories: + *
      + *
    1. sources (location "src", output location "bin", includes "*.java")
    2. + *
    3. resources (location "src", output location "bin", excludes "*.java")
    4. + *
    + *
  • + *
  • Typical Java project based on Maven might consist of four directories: + *
      + *
    1. main sources (location "src/main/java", output location "target/classes")
    2. + *
    3. main resources (location "src/main/resources", output location "target/classes")
    4. + *
    5. test sources (location "src/test/java", output location "target/test-classes")
    6. + *
    7. test resources (location "src/test/resources", output location "target/test-classes")
    8. + *
    + *
  • + *
+ *

+ * + * @since 2.6 + */ +public interface FileSystemDirectory { + + /** + * @return nature of underlying files. + * @see Natures + */ + String getNature(); + + /** + * @return location of files for compilation. + * In case of Java this would be directory with Java source files. + */ + File getLocation(); + + /** + * @return location of binary files after compilation. + * In case of Java this would be directory with Class files. + */ + File getOutputLocation(); + + /** + * @return list of Ant-like inclusion patterns for files. + */ + List getInclusionPatterns(); + + /** + * @return list of Ant-like exclusion patterns for files. + */ + List getExclusionPatterns(); + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectDirectory.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectDirectory.java deleted file mode 100644 index 4b645a553ce..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectDirectory.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2009 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.resources; - - -import java.io.File; -import java.util.List; - -/** - * Defines project directory in a form suitable for Sonar. - * This is a part of bootstrap process, so we should take care about backward compatibility. - *

- * Couple of examples to show what this structure defines: - *

    - *
  • Typical Java project based on Ant might consist of two directories: - *
      - *
    1. sources (location "src", output location "bin", includes "*.java")
    2. - *
    3. resources (location "src", output location "bin", excludes "*.java")
    4. - *
    - *
  • - *
  • Typical Java project based on Maven might consist of four directories: - *
      - *
    1. main sources (location "src/main/java", output location "target/classes")
    2. - *
    3. main resources (location "src/main/resources", output location "target/classes")
    4. - *
    5. test sources (location "src/test/java", output location "target/test-classes")
    6. - *
    7. test resources (location "src/test/resources", output location "target/test-classes")
    8. - *
    - *
  • - *
- *

- * - * @since 2.6 - */ -public interface ProjectDirectory { - - /** - * @return nature of underlying files. - * @see Natures - */ - String getNature(); - - /** - * @return location of files for compilation. - * In case of Java this would be directory with Java source files. - */ - File getLocation(); - - /** - * @return location of binary files after compilation. - * In case of Java this would be directory with Class files. - */ - File getOutputLocation(); - - /** - * @return list of Ant-like inclusion patterns for files. - */ - List getInclusionPatterns(); - - /** - * @return list of Ant-like exclusion patterns for files. - */ - List getExclusionPatterns(); - -} -- cgit v1.2.3