001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2008-2012 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
019 */
020 package org.sonar.batch.bootstrapper;
021
022 import java.io.File;
023 import java.util.ArrayList;
024 import java.util.List;
025 import java.util.Properties;
026
027 /**
028 * Describes project in a form suitable to bootstrap Sonar batch.
029 * We assume that project is just a set of configuration properties and directories.
030 *
031 * @since 2.6
032 * @deprecated since 2.9. Move into org.sonar.api.batch.bootstrap
033 */
034 @Deprecated
035 public class ProjectDefinition {
036
037 private org.sonar.api.batch.bootstrap.ProjectDefinition target = null;
038 private List<ProjectDefinition> children = new ArrayList<ProjectDefinition>();
039
040 /**
041 * @param baseDir project base directory
042 * @param properties project properties
043 */
044 public ProjectDefinition(File baseDir, File workDir, Properties properties) {
045 target = org.sonar.api.batch.bootstrap.ProjectDefinition.create(properties)
046 .setBaseDir(baseDir)
047 .setWorkDir(workDir);
048 }
049
050 public File getBaseDir() {
051 return target.getBaseDir();
052 }
053
054 public File getWorkDir() {
055 return target.getWorkDir();
056 }
057
058 public Properties getProperties() {
059 return target.getProperties();
060 }
061
062 public List<String> getSourceDirs() {
063 return target.getSourceDirs();
064 }
065
066 public void addSourceDir(String path) {
067 target.addSourceDirs(path);
068 }
069
070 public List<String> getTestDirs() {
071 return target.getTestDirs();
072 }
073
074 /**
075 * @param path path to directory with test sources.
076 * It can be absolute or relative to project directory.
077 */
078 public void addTestDir(String path) {
079 target.addTestDirs(path);
080 }
081
082 public List<String> getBinaries() {
083 return target.getBinaries();
084 }
085
086 /**
087 * @param path path to directory with compiled source. In case of Java this is directory with class files.
088 * It can be absolute or relative to project directory.
089 * @TODO currently Sonar supports only one such directory due to dependency on MavenProject
090 */
091 public void addBinaryDir(String path) {
092 target.addBinaryDir(path);
093 }
094
095 public List<String> getLibraries() {
096 return target.getLibraries();
097 }
098
099 /**
100 * @param path path to file with third-party library. In case of Java this is path to jar file.
101 * It can be absolute or relative to project directory.
102 */
103 public void addLibrary(String path) {
104 target.addLibrary(path);
105 }
106
107 /**
108 * Adds an extension, which would be available in PicoContainer during analysis of this project.
109 *
110 * @since 2.8
111 */
112 public void addContainerExtension(Object extension) {
113 target.addContainerExtension(extension);
114 }
115
116 /**
117 * @since 2.8
118 */
119 public List<Object> getContainerExtensions() {
120 return target.getContainerExtensions();
121 }
122
123 /**
124 * @since 2.8
125 */
126 public void addModule(ProjectDefinition projectDefinition) {
127 target.addSubProject(projectDefinition.toNewProjectDefinition());
128 children.add(projectDefinition);
129 }
130
131 /**
132 * @since 2.8
133 */
134 public List<ProjectDefinition> getModules() {
135 return children;
136 }
137
138 public org.sonar.api.batch.bootstrap.ProjectDefinition toNewProjectDefinition() {
139 return target;
140 }
141 }