From 4313d39bfde2f96bc15cd7df3e629cd4d758b736 Mon Sep 17 00:00:00 2001
From: Evgeny Mandrikov
Date: Mon, 17 Jan 2011 09:28:11 +0300
Subject: Add new structure to define project in a form suitable for
bootstrapping Sonar batch
---
.../org/sonar/api/project/ProjectDefinition.java | 76 +++++++++++++++++++
.../org/sonar/api/project/ProjectDirectory.java | 88 ++++++++++++++++++++++
2 files changed, 164 insertions(+)
create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/project/ProjectDefinition.java
create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/project/ProjectDirectory.java
(limited to 'sonar-plugin-api')
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/project/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/project/ProjectDefinition.java
new file mode 100644
index 00000000000..db076fe803d
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/project/ProjectDefinition.java
@@ -0,0 +1,76 @@
+/*
+ * 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.project;
+
+import org.apache.commons.configuration.Configuration;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Defines project in a form suitable for Sonar.
+ * This is a part of bootstrap process, so we should take care about backward compatibility.
+ *
+ * We assume that project is just a set of configuration properties and directories. And each project has unique key in format
+ * "groupId:artifactId" (for example "org.codehaus.sonar:sonar").
+ *
+ *
+ * @since 2.6
+ */
+public interface ProjectDefinition {
+
+ /**
+ * @return project key.
+ */
+ String getKey();
+
+ /**
+ * @return project properties.
+ */
+ Configuration getConfiguration();
+
+ /**
+ * @return Sonar working directory.
+ * It's "${project.build.directory}/sonar" ("${project.basedir}/target/sonar") for Maven projects.
+ */
+ File getSonarWorkingDirectory();
+
+ /**
+ * @return project root directory.
+ * It's "${project.basedir}" for Maven projects.
+ */
+ File getBasedir();
+
+ /**
+ * @return project directories.
+ */
+ List getDirs();
+
+ /**
+ * @return parent project.
+ */
+ ProjectDefinition getParent();
+
+ /**
+ * @return list of sub-projects.
+ */
+ List getModules();
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/project/ProjectDirectory.java b/sonar-plugin-api/src/main/java/org/sonar/api/project/ProjectDirectory.java
new file mode 100644
index 00000000000..d516a46b959
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/project/ProjectDirectory.java
@@ -0,0 +1,88 @@
+/*
+ * 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.project;
+
+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:
+ *
+ * - sources (location "src", output location "bin", includes "*.java")
+ * - resources (location "src", output location "bin", excludes "*.java")
+ *
+ *
+ * - Typical Java project based on Maven might consist of four directories:
+ *
+ * - main sources (location "src/main/java", output location "target/classes")
+ * - main resources (location "src/main/resources", output location "target/classes")
+ * - test sources (location "src/test/java", output location "target/test-classes")
+ * - test resources (location "src/test/resources", output location "target/test-classes")
+ *
+ *
+ *
+ *
+ *
+ * @since 2.6
+ */
+public interface ProjectDirectory {
+
+ /**
+ * TODO We should find a more flexible way to specify kind.
+ * Because actually this is just a logical division to be able to associate different quality profiles for different kinds of directories.
+ * Imagine that we can have different rules for unit tests, integration tests, performance tests, UI tests and so on.
+ * But seems that for now this enumeration would cover our needs.
+ */
+ public static enum Kind {
+ SOURCES, RESOURCES, TESTS, TEST_RESOURCES
+ }
+
+ /**
+ * @return kind of underlying files.
+ */
+ Kind getKind();
+
+ /**
+ * @return location of files for compilation.
+ */
+ 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