From 61efd4090dbbb72060c26e3b89c162cc622e2c80 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 4 Oct 2012 14:42:30 +0200 Subject: [PATCH] SONAR-2602 the extensions Language must not be declared with InstantiationStrategy=PER_BATCH --- .../org/sonar/plugins/cpd/CpdSensorTest.java | 24 ++++++++++------ .../plugins/cpd/SonarBridgeEngineTest.java | 26 +++++++++-------- .../sonar/batch/bootstrap/BatchModule.java | 2 -- .../sonar/batch/bootstrap/ProjectModule.java | 3 +- .../sonar/batch/config/ProjectSettings.java | 6 +--- .../java/org/sonar/batch/phases/Phases.java | 12 +++++--- .../ProjectInitializer.java | 16 +++++------ .../sonar/batch/DefaultProfileLoaderTest.java | 10 +++++-- .../ProjectExtensionInstallerTest.java | 9 ++++-- .../index/DefaultResourcePersisterTest.java | 28 +++++++++++-------- .../sonar/api/resources/AbstractLanguage.java | 2 +- .../org/sonar/api/resources/Language.java | 2 -- .../org/sonar/api/resources/Languages.java | 1 - .../java/org/sonar/api/resources/Project.java | 11 +------- 14 files changed, 83 insertions(+), 69 deletions(-) rename sonar-batch/src/main/java/org/sonar/batch/{bootstrap => phases}/ProjectInitializer.java (81%) diff --git a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/CpdSensorTest.java b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/CpdSensorTest.java index 66e946c6d49..d49dd75daf2 100644 --- a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/CpdSensorTest.java +++ b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/CpdSensorTest.java @@ -65,16 +65,18 @@ public class CpdSensorTest { } @Test - public void skipByLanguage() { - PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty("sonar.cpd.skip", "false"); - conf.setProperty("sonar.cpd.php.skip", "true"); - - Project phpProject = createPhpProject().setConfiguration(conf); - Project javaProject = createJavaProject().setConfiguration(conf); + public void shouldSkipByLanguage() { + Project phpProject = createPhpProject(); + phpProject.getConfiguration().setProperty("sonar.cpd.skip", "false"); + phpProject.getConfiguration().setProperty("sonar.cpd.php.skip", "true"); assertTrue(sensor.isSkipped(phpProject)); + + Project javaProject = createJavaProject(); + javaProject.getConfiguration().setProperty("sonar.cpd.skip", "false"); + javaProject.getConfiguration().setProperty("sonar.cpd.php.skip", "true"); assertFalse(sensor.isSkipped(javaProject)); + } @Test @@ -87,12 +89,16 @@ public class CpdSensorTest { } private Project createJavaProject() { - return new Project("java_project").setLanguageKey("java").setLanguage(Java.INSTANCE); + PropertiesConfiguration conf = new PropertiesConfiguration(); + conf.setProperty("sonar.language", "java"); + return new Project("java_project").setConfiguration(conf).setLanguage(Java.INSTANCE); } private Project createPhpProject() { + PropertiesConfiguration conf = new PropertiesConfiguration(); + conf.setProperty("sonar.language", "php"); Language phpLanguage = mock(Language.class); - return new Project("php_project").setLanguageKey("php").setLanguage(phpLanguage); + return new Project("php_project").setConfiguration(conf).setLanguage(phpLanguage); } } diff --git a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/SonarBridgeEngineTest.java b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/SonarBridgeEngineTest.java index b036804b74e..c36facc230a 100644 --- a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/SonarBridgeEngineTest.java +++ b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/SonarBridgeEngineTest.java @@ -39,31 +39,35 @@ public class SonarBridgeEngineTest { @Test public void defaultMinimumTokens() { - Project project = new Project("foo").setConfiguration(new PropertiesConfiguration()); + Project project = newProject("foo", "java"); assertThat(SonarBridgeEngine.getMinimumTokens(project), is(CoreProperties.CPD_MINIMUM_TOKENS_DEFAULT_VALUE)); } @Test public void generalMinimumTokens() { - PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty("sonar.cpd.minimumTokens", "33"); - Project project = new Project("foo").setConfiguration(conf); + Project project = newProject("foo", "java"); + project.getConfiguration().setProperty("sonar.cpd.minimumTokens", "33"); assertThat(SonarBridgeEngine.getMinimumTokens(project), is(33)); } @Test public void minimumTokensByLanguage() { - PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty("sonar.cpd.java.minimumTokens", "42"); - conf.setProperty("sonar.cpd.php.minimumTokens", "33"); - - Project javaProject = new Project("foo").setLanguageKey("java").setConfiguration(conf); - Project phpProject = new Project("foo").setLanguageKey("php").setConfiguration(conf); - + Project javaProject = newProject("foo", "java"); + javaProject.getConfiguration().setProperty("sonar.cpd.java.minimumTokens", "42"); + javaProject.getConfiguration().setProperty("sonar.cpd.php.minimumTokens", "33"); assertThat(SonarBridgeEngine.getMinimumTokens(javaProject), is(42)); + + Project phpProject = newProject("foo", "php"); + phpProject.getConfiguration().setProperty("sonar.cpd.java.minimumTokens", "42"); + phpProject.getConfiguration().setProperty("sonar.cpd.php.minimumTokens", "33"); assertThat(SonarBridgeEngine.getMinimumTokens(phpProject), is(33)); } + private static Project newProject(String key, String language) { + PropertiesConfiguration conf = new PropertiesConfiguration(); + conf.setProperty("sonar.language", language); + return new Project(key).setConfiguration(conf).setAnalysisType(Project.AnalysisType.DYNAMIC); + } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java index 645907de581..b598f81a9ad 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java @@ -22,7 +22,6 @@ package org.sonar.batch.bootstrap; import org.sonar.api.Plugins; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; -import org.sonar.api.resources.Languages; import org.sonar.api.resources.Project; import org.sonar.api.resources.ResourceTypes; import org.sonar.batch.DefaultFileLinesContextFactory; @@ -84,7 +83,6 @@ public class BatchModule extends Module { addCoreSingleton(DefaultNotificationManager.class); addCoreSingleton(DefaultUserFinder.class); addCoreSingleton(ResourceTypes.class); - addCoreSingleton(Languages.class); addCoreMetrics(); addBatchExtensions(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java index 9b4cf76d9e1..02cb458c473 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; import org.sonar.api.batch.BatchExtensionDictionnary; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.profiles.RulesProfile; +import org.sonar.api.resources.Languages; import org.sonar.api.resources.Project; import org.sonar.api.utils.IocContainer; import org.sonar.batch.*; @@ -63,7 +64,6 @@ public class ProjectModule extends Module { addCoreSingleton(projectDefinition); addCoreSingleton(project); addCoreSingleton(project.getConfiguration()); - addCoreSingleton(ProjectInitializer.class); addCoreSingleton(ProjectSettings.class); addCoreSingleton(UnsupportedProperties.class); addCoreSingleton(IocContainer.class); @@ -71,6 +71,7 @@ public class ProjectModule extends Module { for (Object component : projectDefinition.getContainerExtensions()) { addCoreSingleton(component); } + addCoreSingleton(Languages.class); addCoreSingleton(DefaultProjectClasspath.class); addCoreSingleton(DefaultProjectFileSystem2.class); addCoreSingleton(RulesDao.class); diff --git a/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java b/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java index 09496102faf..d470a9cdb02 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java +++ b/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java @@ -27,7 +27,6 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.Settings; import org.sonar.api.resources.Project; -import org.sonar.batch.bootstrap.ProjectInitializer; import org.sonar.core.config.ConfigurationUtils; import org.sonar.core.properties.PropertiesDao; import org.sonar.core.properties.PropertyDto; @@ -43,15 +42,12 @@ public class ProjectSettings extends Settings { private ProjectDefinition projectDefinition; private PropertiesDao propertiesDao; - public ProjectSettings(PropertyDefinitions definitions, ProjectDefinition projectDefinition, PropertiesDao propertiesDao, Project project, ProjectInitializer initializer) { + public ProjectSettings(PropertyDefinitions definitions, ProjectDefinition projectDefinition, PropertiesDao propertiesDao, Project project) { super(definitions); this.deprecatedCommonsConf = project.getConfiguration(); // Configuration is not a parameter to be sure that the project conf is used, not the global one this.projectDefinition = projectDefinition; this.propertiesDao = propertiesDao; load(); - - // TODO should be refactored in a clean way - initializer.execute(project, this); } public ProjectSettings load() { diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java b/sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java index 767b43cffbe..e57e8e3fd80 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/Phases.java @@ -22,6 +22,7 @@ package org.sonar.batch.phases; import com.google.common.collect.Lists; import org.sonar.api.batch.SensorContext; import org.sonar.api.resources.Project; +import org.sonar.batch.phases.ProjectInitializer; import org.sonar.batch.events.EventBus; import org.sonar.batch.index.DefaultIndex; import org.sonar.batch.index.PersistenceManager; @@ -34,7 +35,7 @@ public final class Phases { public static Collection getPhaseClasses(boolean dryRun) { List classes = Lists.newArrayList(DecoratorsExecutor.class, MavenPhaseExecutor.class, MavenPluginsConfigurator.class, PostJobsExecutor.class, SensorsExecutor.class, - InitializersExecutor.class); + InitializersExecutor.class, ProjectInitializer.class); if (!dryRun) { classes.add(UpdateStatusJob.class); } @@ -52,12 +53,13 @@ public final class Phases { private PersistenceManager persistenceManager; private SensorContext sensorContext; private DefaultIndex index; + private ProjectInitializer pi; public Phases(DecoratorsExecutor decoratorsExecutor, MavenPhaseExecutor mavenPhaseExecutor, MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, PersistenceManager persistenceManager, SensorContext sensorContext, DefaultIndex index, - EventBus eventBus, UpdateStatusJob updateStatusJob) { + EventBus eventBus, UpdateStatusJob updateStatusJob, ProjectInitializer pi) { this.decoratorsExecutor = decoratorsExecutor; this.mavenPhaseExecutor = mavenPhaseExecutor; this.mavenPluginsConfigurator = mavenPluginsConfigurator; @@ -69,21 +71,23 @@ public final class Phases { this.index = index; this.eventBus = eventBus; this.updateStatusJob = updateStatusJob; + this.pi = pi; } public Phases(DecoratorsExecutor decoratorsExecutor, MavenPhaseExecutor mavenPhaseExecutor, MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, PersistenceManager persistenceManager, SensorContext sensorContext, DefaultIndex index, - EventBus eventBus) { + EventBus eventBus, ProjectInitializer pi) { this(decoratorsExecutor, mavenPhaseExecutor, mavenPluginsConfigurator, initializersExecutor, postJobsExecutor, - sensorsExecutor, persistenceManager, sensorContext, index, eventBus, null); + sensorsExecutor, persistenceManager, sensorContext, index, eventBus, null, pi); } /** * Executed on each module */ public void execute(Project project) { + pi.execute(project); eventBus.fireEvent(new ProjectAnalysisEvent(project, true)); mavenPluginsConfigurator.execute(project); mavenPhaseExecutor.execute(project); diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectInitializer.java b/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java similarity index 81% rename from sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectInitializer.java rename to sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java index f20751864cb..7e5cabb7afc 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectInitializer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java @@ -17,13 +17,14 @@ * 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.bootstrap; +package org.sonar.batch.phases; -import org.apache.commons.lang.StringUtils; import org.sonar.api.BatchComponent; -import org.sonar.api.resources.*; +import org.sonar.api.resources.Language; +import org.sonar.api.resources.Languages; +import org.sonar.api.resources.Project; import org.sonar.api.utils.SonarException; -import org.sonar.batch.config.ProjectSettings; +import org.sonar.batch.bootstrap.DryRun; import org.sonar.core.resource.ResourceDao; import org.sonar.core.resource.ResourceDto; @@ -42,12 +43,11 @@ public class ProjectInitializer implements BatchComponent { this.languages = languages; } - public void execute(Project project, ProjectSettings settings) { - initLanguage(project, settings); + public void execute(Project project) { + initLanguage(project); } - private void initLanguage(Project project, ProjectSettings settings) { - project.setLanguageKey(StringUtils.defaultIfBlank(settings.getString("sonar.language"), Java.KEY)); + private void initLanguage(Project project) { Language language = languages.get(project.getLanguageKey()); if (language == null) { throw new SonarException("Language with key '" + project.getLanguageKey() + "' not found"); diff --git a/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java index fcf5c004ea7..410e8032ac7 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/DefaultProfileLoaderTest.java @@ -19,6 +19,7 @@ */ package org.sonar.batch; +import org.apache.commons.configuration.PropertiesConfiguration; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -40,7 +41,7 @@ public class DefaultProfileLoaderTest { public ExpectedException thrown = ExpectedException.none(); private ProfilesDao dao; - private Project javaProject = new Project("project").setLanguageKey(Java.KEY); + private Project javaProject = newProject(Java.KEY); @Before public void setUp() { @@ -73,11 +74,16 @@ public class DefaultProfileLoaderTest { */ @Test public void should_give_explicit_message_if_default_profile_not_found() { - Project cobolProject = new Project("cobol-javaProject").setLanguageKey("cobol"); + Project cobolProject = newProject("cobol"); thrown.expect(SonarException.class); thrown.expectMessage("You must install a plugin that supports the language 'cobol'"); new DefaultProfileLoader(dao, new Settings()).load(cobolProject); } + private Project newProject(String language) { + PropertiesConfiguration configuration = new PropertiesConfiguration(); + configuration.setProperty("sonar.language", language); + return new Project("project").setConfiguration(configuration); + } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectExtensionInstallerTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectExtensionInstallerTest.java index 374dc7e8f92..5690e949b4b 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectExtensionInstallerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectExtensionInstallerTest.java @@ -21,6 +21,7 @@ package org.sonar.batch.bootstrap; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; +import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.maven.project.MavenProject; import org.junit.Test; import org.sonar.api.BatchExtension; @@ -101,12 +102,16 @@ public class ProjectExtensionInstallerTest { } private static Project newJavaProject() { - Project project = new Project("foo").setLanguageKey(Java.KEY).setAnalysisType(Project.AnalysisType.DYNAMIC); + PropertiesConfiguration configuration = new PropertiesConfiguration(); + configuration.setProperty("sonar.language", Java.KEY); + Project project = new Project("foo").setConfiguration(configuration).setAnalysisType(Project.AnalysisType.DYNAMIC); return project; } private static Project newGroovyProject() { - return new Project("foo").setLanguageKey("grvy").setAnalysisType(Project.AnalysisType.DYNAMIC); + PropertiesConfiguration configuration = new PropertiesConfiguration(); + configuration.setProperty("sonar.language", "grvy"); + return new Project("foo").setConfiguration(configuration).setAnalysisType(Project.AnalysisType.DYNAMIC); } @Test diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java index 75f86585fed..21cd76173d4 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java @@ -19,6 +19,7 @@ */ package org.sonar.batch.index; +import org.apache.commons.configuration.PropertiesConfiguration; import org.junit.Before; import org.junit.Test; import org.sonar.api.database.model.ResourceModel; @@ -43,22 +44,22 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { @Before public void before() throws ParseException { SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); - singleProject = new Project("foo"); - singleProject.setName("Foo").setDescription("some description").setLanguageKey("java").setAnalysisDate(format.parse("25/12/2010")); + singleProject = newProject("foo", "java"); + singleProject.setName("Foo").setDescription("some description").setAnalysisDate(format.parse("25/12/2010")); - multiModuleProject = new Project("root"); - multiModuleProject.setName("Root").setLanguageKey("java").setAnalysisDate(format.parse("25/12/2010")); + multiModuleProject = newProject("root", "java"); + multiModuleProject.setName("Root").setAnalysisDate(format.parse("25/12/2010")); - moduleA = new Project("a"); - moduleA.setName("A").setLanguageKey("java").setAnalysisDate(format.parse("25/12/2010")); + moduleA = newProject("a", "java"); + moduleA.setName("A").setAnalysisDate(format.parse("25/12/2010")); moduleA.setParent(multiModuleProject); - moduleB = new Project("b"); - moduleB.setName("B").setLanguageKey("java").setAnalysisDate(format.parse("25/12/2010")); + moduleB = newProject("b", "java"); + moduleB.setName("B").setAnalysisDate(format.parse("25/12/2010")); moduleB.setParent(multiModuleProject); - moduleB1 = new Project("b1"); - moduleB1.setName("B1").setLanguageKey("java").setAnalysisDate(format.parse("25/12/2010")); + moduleB1 = newProject("b1", "java"); + moduleB1.setName("B1").setAnalysisDate(format.parse("25/12/2010")); moduleB1.setParent(moduleB); } @@ -100,7 +101,6 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { // check that the directory is attached to the project checkTables("shouldSaveNewDirectory", new String[] {"build_date", "created_at"}, "projects", "snapshots"); } - @Test public void shouldSaveNewLibrary() { setupData("shared"); @@ -153,4 +153,10 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { checkTables("shouldRemoveRootIndexIfResourceIsProject", new String[] {"build_date", "created_at"}, "projects", "snapshots"); } + private static Project newProject(String key, String language) { + PropertiesConfiguration configuration = new PropertiesConfiguration(); + configuration.setProperty("sonar.language", language); + return new Project(key).setConfiguration(configuration).setAnalysisType(Project.AnalysisType.DYNAMIC); + } + } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/AbstractLanguage.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/AbstractLanguage.java index 267e945a284..e23da992fa5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/AbstractLanguage.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/AbstractLanguage.java @@ -48,7 +48,7 @@ public abstract class AbstractLanguage implements Language { * @param name the display name of the language in the interface */ public AbstractLanguage(String key, String name) { - Preconditions.checkArgument(key.length() < 21, "The following language key exceeds 20 characters: '" + key + "'"); + Preconditions.checkArgument(key.length() <= 20, "The following language key exceeds 20 characters: '" + key + "'"); this.key = key.toLowerCase(Locale.ENGLISH); this.name = name; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Language.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Language.java index 5544ee479cf..6aee345fe1f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Language.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Language.java @@ -21,14 +21,12 @@ package org.sonar.api.resources; import org.sonar.api.BatchExtension; import org.sonar.api.ServerExtension; -import org.sonar.api.batch.InstantiationStrategy; /** * The extension point to define a new language * * @since 1.10 */ -@InstantiationStrategy(InstantiationStrategy.PER_BATCH) public interface Language extends BatchExtension, ServerExtension { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java index 01fbc5ddedc..920cbc6b27b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java @@ -35,7 +35,6 @@ import org.sonar.api.batch.InstantiationStrategy; * * @since 1.10 */ -@InstantiationStrategy(InstantiationStrategy.PER_BATCH) public class Languages implements BatchComponent, ServerComponent { private final Map map = Maps.newHashMap(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java index 7edac70d88d..fc39d34827d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java @@ -98,7 +98,6 @@ public class Project extends Resource { private String description; private String packaging; private Language language; - private String languageKey; private Date analysisDate; private AnalysisType analysisType; private String analysisVersion; @@ -260,15 +259,7 @@ public class Project extends Resource { * @return the language key */ public String getLanguageKey() { - return languageKey; - } - - /** - * For internal use only. - */ - public Project setLanguageKey(String languageKey) { - this.languageKey = languageKey; - return this; + return configuration.getString("sonar.language", Java.KEY); } /** -- 2.39.5