001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2011 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.api.resources; 021 022 import org.sonar.api.BatchComponent; 023 024 import java.io.File; 025 import java.io.IOException; 026 import java.nio.charset.Charset; 027 import java.util.List; 028 029 /** 030 * @since 1.10 031 */ 032 public interface ProjectFileSystem extends BatchComponent { 033 /** 034 * Source encoding. 035 * Never null, it returns the default platform charset if it is not defined in project. 036 * (Maven property 'project.build.sourceEncoding'). 037 */ 038 Charset getSourceCharset(); 039 040 /** 041 * Project root directory. 042 */ 043 File getBasedir(); 044 045 /** 046 * Build directory. It's "${basedir}/target" by default in Maven projects. 047 */ 048 File getBuildDir(); 049 050 /** 051 * Directory where classes are placed. It's "${basedir}/target/classes" by default in Maven projects. 052 */ 053 File getBuildOutputDir(); 054 055 /** 056 * The list of existing directories with sources 057 */ 058 List<File> getSourceDirs(); 059 060 /** 061 * Adds a source directory 062 * 063 * @return the current object 064 * @deprecated since 2.6 - ProjectFileSystem should be immutable 065 * See http://jira.codehaus.org/browse/SONAR-2126 066 */ 067 @Deprecated 068 ProjectFileSystem addSourceDir(File dir); 069 070 /** 071 * The list of existing directories with tests 072 */ 073 List<File> getTestDirs(); 074 075 /** 076 * Adds a test directory 077 * 078 * @return the current object 079 * @deprecated since 2.6 - ProjectFileSystem should be immutable 080 * See http://jira.codehaus.org/browse/SONAR-2126 081 */ 082 @Deprecated 083 ProjectFileSystem addTestDir(File dir); 084 085 /** 086 * @return the directory where reporting is placed. Default is target/sites 087 */ 088 File getReportOutputDir(); 089 090 /** 091 * @return the Sonar working directory. Default is "target/sonar" 092 */ 093 File getSonarWorkingDirectory(); 094 095 /** 096 * @return file in canonical form from specified path. Path can be absolute or relative to project basedir. 097 * For example resolvePath("pom.xml") or resolvePath("src/main/java") 098 */ 099 File resolvePath(String path); 100 101 /** 102 * Source files, excluding unit tests and files matching project exclusion patterns. 103 * 104 * @param langs language filter. Check all files, whatever their language, if null or empty. 105 * @deprecated since 2.6 use {@link #mainFiles(String...)} instead. 106 * See http://jira.codehaus.org/browse/SONAR-2126 107 */ 108 @Deprecated 109 List<File> getSourceFiles(Language... langs); 110 111 /** 112 * Java source files, excluding unit tests and files matching project exclusion patterns. Shortcut for getSourceFiles(Java.INSTANCE) 113 * 114 * @deprecated since 2.6 use {@link #mainFiles(String...)} instead. 115 * See http://jira.codehaus.org/browse/SONAR-2126 116 */ 117 @Deprecated 118 List<File> getJavaSourceFiles(); 119 120 /** 121 * Check if the project has Java files, excluding unit tests and files matching project exclusion patterns. 122 * 123 * @deprecated since 2.6 - API should be language agnostic 124 */ 125 @Deprecated 126 boolean hasJavaSourceFiles(); 127 128 /** 129 * Unit test files, excluding files matching project exclusion patterns. 130 * 131 * @deprecated since 2.6 use {@link #testFiles(String...)} instead. 132 * See http://jira.codehaus.org/browse/SONAR-2126 133 */ 134 @Deprecated 135 List<File> getTestFiles(Language... langs); 136 137 /** 138 * Check if the project has unit test files, excluding files matching project exclusion patterns. 139 * 140 * @deprecated since 2.6 - use language key instead of Language object 141 */ 142 @Deprecated 143 boolean hasTestFiles(Language lang); 144 145 /** 146 * Save data into a new file of Sonar working directory. 147 * 148 * @return the created file 149 */ 150 File writeToWorkingDirectory(String content, String fileName) throws IOException; 151 152 File getFileFromBuildDirectory(String filename); 153 154 Resource toResource(File file); 155 156 /** 157 * Source files, excluding unit tests and files matching project exclusion patterns. 158 * 159 * @param langs language filter. If null or empty, will return empty list 160 * @since 2.6 161 */ 162 List<InputFile> mainFiles(String... langs); 163 164 /** 165 * Source files of unit tests. Exclusion patterns are not applied. 166 * 167 * @param langs language filter. If null or empty, will return empty list 168 * @since 2.6 169 */ 170 List<InputFile> testFiles(String... langs); 171 172 }