import org.sonar.api.batch.Phase;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
+import org.sonar.core.NotDryRun;
import org.sonar.jpa.dao.AsyncMeasuresService;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.ResourceUtils;
+@NotDryRun
@Phase(name = Phase.Name.PRE)
public class AsynchronousMeasuresSensor implements Sensor {
import org.sonar.api.resources.Resource;
import org.sonar.api.resources.ResourceUtils;
import org.sonar.batch.index.ResourcePersister;
+import org.sonar.core.NotDryRun;
/**
* Decorator that currently only closes a review when its corresponding violation has been fixed.
*/
+@NotDryRun
@DependsUpon(DecoratorBarriers.END_OF_VIOLATION_TRACKING)
public class CloseReviewsDecorator implements Decorator {
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.resources.Project;
+import org.sonar.core.NotDryRun;
import java.util.Iterator;
+@NotDryRun
public class VersionEventsSensor implements Sensor {
private static final String SNAPSHOT_SUFFIX = "-SNAPSHOT";
import org.sonar.api.utils.KeyValueFormat;
import org.sonar.batch.components.PastSnapshot;
import org.sonar.batch.components.TimeMachineConfiguration;
+import org.sonar.core.NotDryRun;
import java.util.Arrays;
import java.util.Date;
/**
* @since 2.7
*/
+@NotDryRun
@DependedUpon(DecoratorBarriers.END_OF_TIME_MACHINE)
public final class NewCoverageFileAnalyzer implements Decorator {
import org.sonar.api.rules.Violation;
import org.sonar.batch.components.PastSnapshot;
import org.sonar.batch.components.TimeMachineConfiguration;
+import org.sonar.core.NotDryRun;
import java.util.*;
+@NotDryRun
@DependsUpon(DecoratorBarriers.END_OF_VIOLATION_TRACKING)
public class NewViolationsDecorator implements Decorator {
import org.sonar.api.resources.Resource;
import org.sonar.api.resources.Scopes;
import org.sonar.batch.components.TimeMachineConfiguration;
+import org.sonar.core.NotDryRun;
import java.util.List;
+@NotDryRun
@DependedUpon(DecoratorBarriers.END_OF_TIME_MACHINE)
public class TendencyDecorator implements Decorator {
import org.sonar.api.resources.ResourceUtils;
import org.sonar.batch.components.PastSnapshot;
import org.sonar.batch.components.TimeMachineConfiguration;
+import org.sonar.core.NotDryRun;
import java.util.List;
+@NotDryRun
public final class TimeMachineConfigurationPersister implements Decorator {
private TimeMachineConfiguration configuration;
import org.sonar.batch.components.PastMeasuresLoader;
import org.sonar.batch.components.PastSnapshot;
import org.sonar.batch.components.TimeMachineConfiguration;
+import org.sonar.core.NotDryRun;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+@NotDryRun
@DependedUpon(DecoratorBarriers.END_OF_TIME_MACHINE)
public class VariationDecorator implements Decorator {
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+import org.sonar.core.NotDryRun;
+@NotDryRun
@DependsUpon({ DecoratorBarriers.END_OF_VIOLATIONS_GENERATION, DecoratorBarriers.START_VIOLATION_TRACKING })
@DependedUpon(DecoratorBarriers.END_OF_VIOLATION_TRACKING)
public class ViolationPersisterDecorator implements Decorator {
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.TimeProfiler;
+import org.sonar.core.NotDryRun;
import org.sonar.plugins.dbcleaner.api.Purge;
import javax.persistence.Query;
+@NotDryRun
public final class PurgeRunner implements PostJob {
private DatabaseSession session;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.MetricFinder;
-import org.sonar.api.resources.Project;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
import org.sonar.batch.index.DefaultIndex;
Map<Integer, Metric> metricById = getMetricsById(query);
List<Object[]> rows = execute(query, false, metricById.keySet());
for (Object[] fields : rows) {
- fields[1]=metricById.get(fields[1]);
+ fields[1] = metricById.get(fields[1]);
}
return rows;
}
protected List execute(TimeMachineQuery query, boolean selectAllFields, Set<Integer> metricIds) {
Resource resource = query.getResource();
- if (resource!=null && resource.getId()==null) {
+ if (resource != null && resource.getId() == null) {
resource = index.getResource(query.getResource());
}
if (resource == null) {
private BatchPluginRepository pluginRepository;
private EnvironmentInformation environment;
+ private DryRun dryRun;
- public BatchExtensionInstaller(BatchPluginRepository pluginRepository, EnvironmentInformation environment) {
+ public BatchExtensionInstaller(BatchPluginRepository pluginRepository, EnvironmentInformation environment, DryRun dryRun) {
this.pluginRepository = pluginRepository;
this.environment = environment;
+ this.dryRun = dryRun;
}
public void install(Module module) {
void installExtension(Module module, Object extension) {
if (ExtensionUtils.isBatchExtension(extension) &&
ExtensionUtils.isSupportedEnvironment(extension, environment) &&
+ ExtensionUtils.checkDryRun(extension, dryRun.isEnabled()) &&
ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_BATCH)) {
if (ExtensionUtils.isType(extension, CoverageExtension.class)) {
throw new IllegalArgumentException("Instantiation strategy " + InstantiationStrategy.PER_BATCH + " is not supported on CoverageExtension components: " + extension);
* Level-2 components. Connected to database.
*/
public class BatchModule extends Module {
+
+ private final boolean dryRun;
+
+ public BatchModule(boolean dryRun) {
+ this.dryRun = dryRun;
+ }
+
@Override
protected void configure() {
addComponent(ProjectTree.class);
addComponent(DefaultResourceCreationLock.class);
addComponent(DefaultIndex.class);
- addComponent(DefaultPersistenceManager.class);
- addComponent(DependencyPersister.class);
- addComponent(EventPersister.class);
- addComponent(LinkPersister.class);
- addComponent(MeasurePersister.class);
- addComponent(MemoryOptimizer.class);
- addComponent(DefaultResourcePersister.class);
- addComponent(SourcePersister.class);
- addComponent(ViolationPersister.class);
+
+ if (dryRun) {
+ addComponent(ReadOnlyPersistenceManager.class);
+ } else {
+ addComponent(DefaultPersistenceManager.class);
+ addComponent(DependencyPersister.class);
+ addComponent(EventPersister.class);
+ addComponent(LinkPersister.class);
+ addComponent(MeasurePersister.class);
+ addComponent(MemoryOptimizer.class);
+ addComponent(DefaultResourcePersister.class);
+ addComponent(SourcePersister.class);
+ addComponent(ViolationPersister.class);
+ }
+
addComponent(Plugins.class);
addComponent(ServerHttpClient.class);
addComponent(MeasuresDao.class);
analyze(subProject);
}
- Module projectComponents = installChild(new ProjectModule(project));
+ Module projectComponents = installChild(new ProjectModule(project, dryRun));
try {
projectComponents.start();
} finally {
protected void configure() {
addComponent(reactor);
addComponent(configuration);
+ addComponent(DryRun.class);
addComponent(ServerMetadata.class);// registered here because used by BootstrapClassLoader
addComponent(TempDirectories.class);// registered here because used by BootstrapClassLoader
addComponent(HttpDownloader.class);// registered here because used by BootstrapClassLoader
@Override
protected void doStart() {
addPlugins();
- Module batchComponents = installChild(new BatchModule());
+ boolean dryRun = getComponent(DryRun.class).isEnabled();
+ Module batchComponents = installChild(new BatchModule(dryRun));
batchComponents.start();
}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * 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.batch.bootstrap;
+
+import org.apache.commons.configuration.Configuration;
+
+public class DryRun {
+ private boolean enabled;
+
+ public DryRun(Configuration conf) {
+ enabled=conf.getBoolean("sonar.dryRun", Boolean.FALSE);
+ }
+
+ DryRun(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+}
import org.sonar.api.BatchExtension;
import org.sonar.api.Extension;
import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.batch.Purge;
import org.sonar.api.batch.SupportedEnvironment;
import org.sonar.api.utils.AnnotationUtils;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
+import org.sonar.core.NotDryRun;
public final class ExtensionUtils {
return false;
}
+ static boolean checkDryRun(Object extension, boolean dryRun) {
+ return !dryRun || AnnotationUtils.getClassAnnotation(extension, NotDryRun.class)==null;
+ }
+
static boolean isMavenExtensionOnly(Object extension) {
Class clazz = (extension instanceof Class ? (Class) extension : extension.getClass());
SupportedEnvironment env = AnnotationUtils.getClassAnnotation(clazz, SupportedEnvironment.class);
private MutablePicoContainer container;
+
/**
* @return this
*/
private BatchPluginRepository pluginRepository;
private EnvironmentInformation environment;
+ private DryRun dryRun;
- public ProjectExtensionInstaller(BatchPluginRepository pluginRepository, EnvironmentInformation environment) {
+ public ProjectExtensionInstaller(BatchPluginRepository pluginRepository, EnvironmentInformation environment, DryRun dryRun) {
this.pluginRepository = pluginRepository;
this.environment = environment;
+ this.dryRun = dryRun;
}
public void install(Module module, Project project) {
if (ExtensionUtils.isBatchExtension(extension) &&
ExtensionUtils.isSupportedEnvironment(extension, environment) &&
ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT) &&
+ ExtensionUtils.checkDryRun(extension, dryRun.isEnabled()) &&
!isDeactivatedCoverageExtension(extension, project, pluginKey) &&
!isMavenExtensionOnEmulatedMavenProject(extension, project)) {
module.addComponent(extension);
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.BatchExtensionDictionnary;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.measures.Metrics;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
public class ProjectModule extends Module {
private static final Logger LOG = LoggerFactory.getLogger(ProjectModule.class);
private Project project;
+ private boolean dryRun;
- public ProjectModule(Project project) {
+ public ProjectModule(Project project, boolean dryRun) {
this.project = project;
+ this.dryRun = dryRun;
}
@Override
addComponent(DaoFacade.class);
addComponent(RulesDao.class);
- // the Snapshot component will be removed when asynchronous measures are improved (required for AsynchronousMeasureSensor)
- addComponent(getComponent(DefaultResourcePersister.class).getSnapshot(project));
+ if (!dryRun) {
+ // the Snapshot component will be removed when asynchronous measures are improved (required for AsynchronousMeasureSensor)
+ addComponent(getComponent(DefaultResourcePersister.class).getSnapshot(project));
+ addComponent(TimeMachineConfiguration.class);
+ addComponent(PastViolationsLoader.class);
+ }
addComponent(org.sonar.api.database.daos.MeasuresDao.class);
addComponent(ProfilesDao.class);
addComponent(AsyncMeasuresDao.class);
addComponent(ViolationFilters.class);
addComponent(ResourceFilters.class);
addComponent(DefaultModelFinder.class);
- addComponent(TimeMachineConfiguration.class);
- addComponent(PastViolationsLoader.class);
addComponent(ProfileLoader.class, DefaultProfileLoader.class);
addAdapter(new ProfileProvider());
}
addComponent(EventBus.class);
addComponent(Phases.class);
addComponent(PhasesTimeProfiler.class);
- for (Class clazz : Phases.getPhaseClasses()) {
+ for (Class clazz : Phases.getPhaseClasses(dryRun)) {
addComponent(clazz);
}
}
import org.sonar.api.resources.Resource;
import org.sonar.api.utils.SonarException;
import org.sonar.batch.index.ResourcePersister;
+import org.sonar.core.NotDryRun;
import java.util.Collections;
import java.util.List;
+@NotDryRun
public class PastViolationsLoader implements BatchExtension {
private DatabaseSession session;
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * 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.batch.index;
+
+import org.sonar.api.batch.Event;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.design.Dependency;
+import org.sonar.api.measures.Measure;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.ProjectLink;
+import org.sonar.api.resources.Resource;
+
+import java.util.Collections;
+import java.util.List;
+
+public final class ReadOnlyPersistenceManager implements PersistenceManager {
+
+ public void clear() {
+ }
+
+ public void setDelayedMode(boolean b) {
+ }
+
+ public void dump() {
+ }
+
+ public void saveProject(Project project, Project parent) {
+ }
+
+ public Snapshot saveResource(Project project, Resource resource, Resource parent) {
+ return null;
+ }
+
+ public void setSource(Resource file, String source) {
+ }
+
+ public void saveMeasure(Resource resource, Measure measure) {
+ }
+
+ public Measure reloadMeasure(Measure measure) {
+ return measure;
+ }
+
+ public void saveDependency(Project project, Dependency dependency, Dependency parentDependency) {
+ }
+
+ public void saveLink(Project project, ProjectLink link) {
+ }
+
+ public void deleteLink(Project project, String key) {
+ }
+
+ public List<Event> getEvents(Resource resource) {
+ return Collections.emptyList();
+ }
+
+ public void deleteEvent(Event event) {
+ }
+
+ public void saveEvent(Resource resource, Event event) {
+ }
+}
*/
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.events.EventBus;
import org.sonar.batch.index.DefaultIndex;
import org.sonar.batch.index.PersistenceManager;
-import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
public final class Phases {
- public static Collection<Class> getPhaseClasses() {
- return Arrays.<Class> asList(
- DecoratorsExecutor.class, MavenPhaseExecutor.class, MavenPluginsConfigurator.class,
- PostJobsExecutor.class, SensorsExecutor.class, UpdateStatusJob.class,
+ public static Collection<Class> getPhaseClasses(boolean dryRun) {
+ List<Class> classes = Lists.<Class>newArrayList(DecoratorsExecutor.class, MavenPhaseExecutor.class, MavenPluginsConfigurator.class,
+ PostJobsExecutor.class, SensorsExecutor.class,
InitializersExecutor.class);
+ if (!dryRun) {
+ classes.add(UpdateStatusJob.class);
+ }
+ return classes;
}
private EventBus eventBus;
public Phases(DecoratorsExecutor decoratorsExecutor, MavenPhaseExecutor mavenPhaseExecutor,
MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor,
- PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, UpdateStatusJob updateStatusJob,
+ PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor,
PersistenceManager persistenceManager, SensorContext sensorContext, DefaultIndex index,
- EventBus eventBus) {
+ EventBus eventBus, UpdateStatusJob updateStatusJob) {
this.decoratorsExecutor = decoratorsExecutor;
this.mavenPhaseExecutor = mavenPhaseExecutor;
this.mavenPluginsConfigurator = mavenPluginsConfigurator;
this.postJobsExecutor = postJobsExecutor;
this.initializersExecutor = initializersExecutor;
this.sensorsExecutor = sensorsExecutor;
- this.updateStatusJob = updateStatusJob;
this.persistenceManager = persistenceManager;
this.sensorContext = sensorContext;
this.index = index;
this.eventBus = eventBus;
+ this.updateStatusJob = updateStatusJob;
+ }
+
+ public Phases(DecoratorsExecutor decoratorsExecutor, MavenPhaseExecutor mavenPhaseExecutor,
+ MavenPluginsConfigurator mavenPluginsConfigurator, InitializersExecutor initializersExecutor,
+ PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor,
+ PersistenceManager persistenceManager, SensorContext sensorContext, DefaultIndex index,
+ EventBus eventBus) {
+ this(decoratorsExecutor, mavenPhaseExecutor, mavenPluginsConfigurator, initializersExecutor, postJobsExecutor,
+ sensorsExecutor, persistenceManager, sensorContext, index, eventBus, null);
}
/**
persistenceManager.setDelayedMode(false);
if (project.isRoot()) {
- updateStatusJob.execute();
+ if (updateStatusJob != null) {
+ updateStatusJob.execute();
+ }
postJobsExecutor.execute(sensorContext);
}
cleanMemory();
import org.sonar.api.resources.Scopes;
import org.sonar.batch.ServerMetadata;
import org.sonar.batch.index.ResourcePersister;
+import org.sonar.core.NotDryRun;
import javax.persistence.Query;
import java.util.List;
+@NotDryRun
public class UpdateStatusJob implements BatchComponent {
private DatabaseSession session;
}
}));
Module module = new FakeModule().init();
- BatchExtensionInstaller installer = new BatchExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
+ BatchExtensionInstaller installer = new BatchExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), new DryRun(false));
installer.install(module);
}
}));
Module module = new FakeModule().init();
- BatchExtensionInstaller installer = new BatchExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
+ BatchExtensionInstaller installer = new BatchExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), new DryRun(false));
installer.install(module);
}
}));
Module module = new FakeModule().init();
- BatchExtensionInstaller installer = new BatchExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
+ BatchExtensionInstaller installer = new BatchExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), new DryRun(false));
installer.install(module);
}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * 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.batch.bootstrap;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.hamcrest.core.Is;
+import org.junit.Test;
+
+import static org.junit.Assert.assertThat;
+
+public class DryRunTest {
+
+ @Test
+ public void shouldReadConfiguration() {
+ PropertiesConfiguration conf = new PropertiesConfiguration();
+ conf.setProperty("sonar.dryRun", "true");
+ assertThat(new DryRun(conf).isEnabled(), Is.is(true));
+
+ conf.setProperty("sonar.dryRun", "false");
+ assertThat(new DryRun(conf).isEnabled(), Is.is(false));
+ }
+
+ @Test
+ public void shouldNotEnableDryRunByDefault() {
+ PropertiesConfiguration conf = new PropertiesConfiguration();
+ assertThat(new DryRun(conf).isEnabled(), Is.is(false));
+ }
+}
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.SupportedEnvironment;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
+import org.sonar.core.NotDryRun;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
assertThat(ExtensionUtils.isMavenExtensionOnly(BuildToolService.class), is(false));
}
+ @Test
+ public void shouldCheckDryRun() {
+ assertThat(ExtensionUtils.checkDryRun(BatchService.class, true), is(true));
+ assertThat(ExtensionUtils.checkDryRun(PersistentService.class, true), is(false));
+ }
+
+ @Test
+ public void shouldNotCheckDryRun() {
+ assertThat(ExtensionUtils.checkDryRun(BatchService.class, false), is(true));
+ assertThat(ExtensionUtils.checkDryRun(PersistentService.class, false), is(true));
+ }
+
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
public static class BatchService implements BatchExtension {
public static class BuildToolService implements BatchExtension {
}
+
+ @NotDryRun
+ public static class PersistentService implements BatchExtension {
+
+ }
}
});
when(pluginRepository.getPluginsByKey()).thenReturn(pluginsMap);
Module module = new FakeModule().init();
- ProjectExtensionInstaller installer = new ProjectExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
+ ProjectExtensionInstaller installer = new ProjectExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), new DryRun(false));
installer.install(module, new Project("foo"));
});
when(pluginRepository.getPluginsByKey()).thenReturn(pluginsMap);
Module module = new FakeModule().init();
- ProjectExtensionInstaller installer = new ProjectExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
+ ProjectExtensionInstaller installer = new ProjectExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), new DryRun(false));
installer.install(module, new Project("foo"));
@Test
public void shouldDefinePhaseClasses() {
- assertThat(Phases.getPhaseClasses().size(), greaterThan(4));
+ assertThat(Phases.getPhaseClasses(false).size(), greaterThan(4));
+ }
+
+ @Test
+ public void someComponentsShouldBeDisabledOnDryRun() {
+ assertThat(Phases.getPhaseClasses(false).size(), greaterThan(Phases.getPhaseClasses(true).size()));
}
}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * 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.core;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Disables component on dry runs.
+ * This annotation must be used by core modules only. It MUST not be used by external plugins.
+ * @since 2.9
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface NotDryRun {
+}