org.sonar.api.resources
Class Project

java.lang.Object
  extended by org.sonar.api.resources.Resource
      extended by org.sonar.api.resources.Project
All Implemented Interfaces:
Serializable, Component

public class Project
extends Resource
implements Component

A class that manipulates Projects in the Sonar way.

Since:
1.10
See Also:
Serialized Form

Nested Class Summary
static class Project.AnalysisType
          Deprecated. since 4.4 Since 4.3 SQ will no more run tests. So basically it's always reuse report.
 
Field Summary
static Language NONE_LANGUAGE
          Internal use
static String PARAM_REUSE_RULES_CONFIG
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String SCOPE
           
 
Fields inherited from class org.sonar.api.resources.Resource
QUALIFIER_CLASS, QUALIFIER_DIRECTORY, QUALIFIER_FIELD, QUALIFIER_FILE, QUALIFIER_LIB, QUALIFIER_METHOD, QUALIFIER_MODULE, QUALIFIER_PACKAGE, QUALIFIER_PROJECT, QUALIFIER_SUBVIEW, QUALIFIER_UNIT_TEST_CLASS, QUALIFIER_VIEW, SCOPE_ENTITY, SCOPE_SET, SCOPE_SPACE
 
Constructor Summary
Project(String key)
           
Project(String key, String branch, String name)
           
 
Method Summary
static Project createFromMavenIds(String groupId, String artifactId)
           
static Project createFromMavenIds(String groupId, String artifactId, String branch)
           
 Date getAnalysisDate()
           
 Project.AnalysisType getAnalysisType()
          Deprecated. since 4.4 Since 4.3 SQ will no more run tests. So basically it's always reuse report.
 String getAnalysisVersion()
           
 String getArtifactId()
          Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011
 String getBranch()
           
 org.apache.commons.configuration.Configuration getConfiguration()
          Deprecated. since 2.12. The component org.sonar.api.config.Settings must be used.
 String getDescription()
           
 String[] getExclusionPatterns()
          Deprecated. replaced by FileExclusions in version 3.5
 ProjectFileSystem getFileSystem()
          Deprecated. replaced by ModuleFileSystem in 3.5
 String getGroupId()
          Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011
 Language getLanguage()
          Deprecated. since 4.2 use FileSystem.languages()
 String getLanguageKey()
          Deprecated. since 4.2 use FileSystem.languages()
 String getLongName()
           
 List<Project> getModules()
           
 String getName()
           
 String getPackaging()
          Deprecated. in 2.8. See http://jira.codehaus.org/browse/SONAR-2341
 Project getParent()
          The parent is used to build the resources tree, for example for relations between classes, packages and projects.
 org.apache.maven.project.MavenProject getPom()
          Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011 , MavenProject can be retrieved as an IoC dependency
 Object getProperty(String key)
          Deprecated. since 3.6. Replaced by Settings.
 String getQualifier()
          The qualifier tells the type of the resource.
 boolean getReuseExistingRulesConfig()
          Deprecated. since 2.5. See discussion from http://jira.codehaus.org/browse/SONAR-1873
 Project getRoot()
           
 String getScope()
           
 String[] getTestExclusionPatterns()
          Deprecated. replaced by FileExclusions in version 3.5
 boolean isLatestAnalysis()
          Deprecated. in 3.6. The analysis is now always the latest one (past analysis must be done in a chronological order). See http://jira.codehaus.org/browse/SONAR-4334
 boolean isModule()
           
 boolean isRoot()
           
 String key()
           
 String longName()
           
 boolean matchFilePattern(String antPattern)
          Check resource against an Ant pattern, like mypackag?/*Foo.java.
 String name()
           
 String path()
          Path of the component relative to basedir of the parent module.
 String qualifier()
           
 void removeFromParent()
          For internal use only.
 Project setAnalysisDate(Date analysisDate)
          For internal use only.
 Project setAnalysisType(Project.AnalysisType at)
          Deprecated. since 4.4 Since 4.3 SQ will no more run tests. So basically it's always reuse report.
 Project setAnalysisVersion(String analysisVersion)
          For internal use only.
 Project setBranch(String branch)
          For internal use only.
 Project setConfiguration(org.apache.commons.configuration.Configuration configuration)
          For internal use only.
 Project setDescription(String description)
          For internal use only.
 Project setExclusionPatterns(String[] s)
          Deprecated. replaced by FileExclusions in version 3.5
 Project setFileSystem(ProjectFileSystem fs)
          Deprecated. since 2.6. See http://jira.codehaus.org/browse/SONAR-2126
 Project setLanguage(Language language)
          Internal use
 Project setLatestAnalysis(boolean b)
          Deprecated. in 3.6. It's not possible to analyze a project before the latest known quality snapshot. See http://jira.codehaus.org/browse/SONAR-4334
 Project setName(String name)
          For internal use only.
 Project setPackaging(String packaging)
          Deprecated. in 2.8. See http://jira.codehaus.org/browse/SONAR-2341
 Project setParent(Project parent)
          For internal use only.
 Project setPom(org.apache.maven.project.MavenProject pom)
          For internal use only.
 String toString()
           
 
Methods inherited from class org.sonar.api.resources.Resource
equals, getDeprecatedKey, getEffectiveKey, getId, getKey, getPath, hashCode, isExcluded, normalize, setDeprecatedKey, setEffectiveKey, setExcluded, setId, setKey, setPath
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE_LANGUAGE

public static final Language NONE_LANGUAGE
Internal use


SCOPE

public static final String SCOPE
See Also:
Constant Field Values

PARAM_REUSE_RULES_CONFIG

@Deprecated
public static final String PARAM_REUSE_RULES_CONFIG
Deprecated. since version 1.11. Constant moved to CoreProperties
See Also:
Constant Field Values
Constructor Detail

Project

public Project(String key)

Project

public Project(String key,
               String branch,
               String name)
Method Detail

getBranch

public String getBranch()

setBranch

public Project setBranch(String branch)
For internal use only.


setPom

public final Project setPom(org.apache.maven.project.MavenProject pom)
For internal use only.


getPackaging

@Deprecated
public String getPackaging()
Deprecated. in 2.8. See http://jira.codehaus.org/browse/SONAR-2341

Returns:
the project's packaging

getName

public String getName()
Specified by:
getName in class Resource
Returns:
the resource name

getLongName

public String getLongName()
Specified by:
getLongName in class Resource
Returns:
the resource long name

getDescription

public String getDescription()
Specified by:
getDescription in class Resource
Returns:
the resource description

setName

public Project setName(String name)
For internal use only.


setDescription

public Project setDescription(String description)
For internal use only.


setPackaging

@Deprecated
public Project setPackaging(String packaging)
Deprecated. in 2.8. See http://jira.codehaus.org/browse/SONAR-2341

For internal use only.


isRoot

public boolean isRoot()
Returns:
whether the current project is root project

getRoot

public Project getRoot()

isModule

public boolean isModule()
Returns:
whether the current project is a module

getAnalysisType

@Deprecated
public Project.AnalysisType getAnalysisType()
Deprecated. since 4.4 Since 4.3 SQ will no more run tests. So basically it's always reuse report.


setAnalysisType

@Deprecated
public Project setAnalysisType(Project.AnalysisType at)
Deprecated. since 4.4 Since 4.3 SQ will no more run tests. So basically it's always reuse report.


isLatestAnalysis

@Deprecated
public boolean isLatestAnalysis()
Deprecated. in 3.6. The analysis is now always the latest one (past analysis must be done in a chronological order). See http://jira.codehaus.org/browse/SONAR-4334

whether it's the latest analysis done on this project (displayed in sonar dashboard) or an analysis on a past revision.

Since:
2.0

setLatestAnalysis

@Deprecated
public Project setLatestAnalysis(boolean b)
Deprecated. in 3.6. It's not possible to analyze a project before the latest known quality snapshot. See http://jira.codehaus.org/browse/SONAR-4334

For internal use only.


getLanguage

@Deprecated
public Language getLanguage()
Deprecated. since 4.2 use FileSystem.languages()

Specified by:
getLanguage in class Resource
Returns:
the project language when there is only one language

setLanguage

public Project setLanguage(Language language)
Internal use


getLanguageKey

@Deprecated
public String getLanguageKey()
Deprecated. since 4.2 use FileSystem.languages()

Returns:
the language key or empty if no language is specified

setAnalysisDate

public Project setAnalysisDate(Date analysisDate)
For internal use only.


setAnalysisVersion

public Project setAnalysisVersion(String analysisVersion)
For internal use only.


getScope

public String getScope()
Specified by:
getScope in class Resource
Returns:
the scope of the current object

getQualifier

public String getQualifier()
Description copied from class: Resource
The qualifier tells the type of the resource. For example, it can be a File, a Class, a Project, a Unit Test...

Specified by:
getQualifier in class Resource
Returns:
the qualifier of the current object
See Also:
for the list of qualifiers, to find out if a resource if a class, a unit test,... from its qualifier

matchFilePattern

public boolean matchFilePattern(String antPattern)
Description copied from class: Resource
Check resource against an Ant pattern, like mypackag?/*Foo.java. It's used for example to match resource exclusions.

Specified by:
matchFilePattern in class Resource
Parameters:
antPattern - Ant-like pattern (with **, * and ?). It includes file suffixes.
Returns:
true if the resource matches the Ant pattern

getParent

public Project getParent()
Description copied from class: Resource
The parent is used to build the resources tree, for example for relations between classes, packages and projects.

Return null if the parent is the project.

Specified by:
getParent in class Resource

setParent

public Project setParent(Project parent)
For internal use only.


removeFromParent

public void removeFromParent()
For internal use only.


getModules

public List<Project> getModules()
Returns:
the list of modules

getReuseExistingRulesConfig

@Deprecated
public boolean getReuseExistingRulesConfig()
Deprecated. since 2.5. See discussion from http://jira.codehaus.org/browse/SONAR-1873

Returns:
whether to use external source for rules configuration

getAnalysisVersion

public String getAnalysisVersion()
Returns:
the current version of the project

getAnalysisDate

public Date getAnalysisDate()
Returns:
the analysis date, i.e. the date that will be used to store the snapshot

getExclusionPatterns

@Deprecated
public String[] getExclusionPatterns()
Deprecated. replaced by FileExclusions in version 3.5

Patterns of resource exclusion as defined in project settings page.

Since:
3.3 also applies exclusions in general settings page and global exclusions.

getTestExclusionPatterns

@Deprecated
public String[] getTestExclusionPatterns()
Deprecated. replaced by FileExclusions in version 3.5

Patterns of test exclusion as defined in project settings page. Also applies exclusions in general settings page and global exclusions.

Since:
3.3

setExclusionPatterns

@Deprecated
public Project setExclusionPatterns(String[] s)
Deprecated. replaced by FileExclusions in version 3.5

Set exclusion patterns. Configuration is not saved, so this method must be used ONLY IN UNIT TESTS.


getFileSystem

@Deprecated
public ProjectFileSystem getFileSystem()
Deprecated. replaced by ModuleFileSystem in 3.5

Note: it's better to get a reference on ProjectFileSystem as an IoC dependency (constructor parameter)


setFileSystem

@Deprecated
public Project setFileSystem(ProjectFileSystem fs)
Deprecated. since 2.6. See http://jira.codehaus.org/browse/SONAR-2126

For internal use only.


getGroupId

@Deprecated
public String getGroupId()
Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011


getArtifactId

@Deprecated
public String getArtifactId()
Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011


getPom

@Deprecated
public org.apache.maven.project.MavenProject getPom()
Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011 , MavenProject can be retrieved as an IoC dependency

Returns:
the underlying Maven project

getConfiguration

@Deprecated
public org.apache.commons.configuration.Configuration getConfiguration()
Deprecated. since 2.12. The component org.sonar.api.config.Settings must be used.

Returns:
the project configuration

setConfiguration

public final Project setConfiguration(org.apache.commons.configuration.Configuration configuration)
For internal use only.


getProperty

@Deprecated
public Object getProperty(String key)
Deprecated. since 3.6. Replaced by Settings.


createFromMavenIds

public static Project createFromMavenIds(String groupId,
                                         String artifactId)

createFromMavenIds

public static Project createFromMavenIds(String groupId,
                                         String artifactId,
                                         @Nullable
                                         String branch)

toString

public String toString()
Overrides:
toString in class Object

key

public String key()
Specified by:
key in interface Component

name

public String name()
Specified by:
name in interface Component

path

public String path()
Description copied from interface: Component
Path of the component relative to basedir of the parent module.

Specified by:
path in interface Component
Returns:
null if this component is not a child of a module

longName

public String longName()
Specified by:
longName in interface Component

qualifier

public String qualifier()
Specified by:
qualifier in interface Component


Copyright © 2009–2015 SonarSource. All rights reserved.