import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
import org.apache.commons.lang.ClassUtils;
import org.picocontainer.MutablePicoContainer;
import org.sonar.api.BatchExtension;
public Collection<MavenPluginHandler> selectMavenPluginHandlers(Project project) {
Collection<DependsUponMavenPlugin> selectedExtensions = select(DependsUponMavenPlugin.class, project, true);
- List<MavenPluginHandler> handlers = new ArrayList<MavenPluginHandler>();
+ List<MavenPluginHandler> handlers = Lists.newArrayList();
for (DependsUponMavenPlugin extension : selectedExtensions) {
MavenPluginHandler handler = extension.getMavenPluginHandler(project);
if (handler != null) {
}
private <T> List<T> getFilteredExtensions(Class<T> type, Project project) {
- List<T> result = new ArrayList<T>();
+ List<T> result = Lists.newArrayList();
for (BatchExtension extension : getExtensions()) {
if (shouldKeep(type, extension, project)) {
result.add((T) extension);
protected List evaluateAnnotatedClasses(Object extension, Class annotation) {
- List results = new ArrayList();
+ List results = Lists.newArrayList();
Class aClass = extension.getClass();
while (aClass != null) {
evaluateClass(aClass, annotation, results);
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.api.batch;
+
+/**
+ * Barriers are used to define the order of execution of Decorators.
+ * @since 2.3
+ */
+public interface DecoratorBarriers {
+
+ /**
+ * This barrier is used by a decorator in order to :
+ * <ul>
+ * <li>be executed after all the decorators which generate violations : <code>@DependsUpon(value=DecoratorBarriers.END_OF_VIOLATIONS_GENERATION</code></li>
+ * <li>declare that it generates violations : <code>@DependedUpon(value=DecoratorBarriers.END_OF_VIOLATIONS_GENERATION</code></li>
+ * </ul>
+ */
+ String END_OF_VIOLATIONS_GENERATION = "END_OF_VIOLATIONS_GENERATION";
+
+}
*/
package org.sonar.api.batch;
+import com.google.common.collect.Lists;
import org.junit.Test;
import org.picocontainer.containers.TransientPicoContainer;
import org.sonar.api.BatchExtension;
BatchExtension c = new MethodDependentOf(b);
BatchExtensionDictionnary selector = newSelector(b, c, a);
- List<BatchExtension> extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertThat(extensions.size(), is(3));
assertThat(extensions.get(0), is(a));
BatchExtension b = new MethodDependentOf("foo");
BatchExtensionDictionnary selector = newSelector(a, b);
- List<BatchExtension> extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertThat(extensions.size(), is(2));
assertThat(extensions.get(0), is(a));
// different initial order
selector = newSelector(b, a);
- extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertEquals(2, extensions.size());
assertEquals(a, extensions.get(0));
BatchExtension b = new ClassDependsUpon();
BatchExtensionDictionnary selector = newSelector(a, b);
- List<BatchExtension> extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertThat(extensions.size(), is(2));
assertThat(extensions.get(0), is(a));
// different initial order
selector = newSelector(b, a);
- extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertEquals(2, extensions.size());
assertEquals(a, extensions.get(0));
};
BatchExtensionDictionnary selector = newSelector(a, b);
- List<BatchExtension> extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertThat(extensions.size(), is(2));
assertThat(extensions.get(0), is(a));
// different initial order
selector = newSelector(b, a);
- extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertEquals(2, extensions.size());
assertEquals(a, extensions.get(0));
BatchExtension ko = new CheckProjectKO();
BatchExtensionDictionnary selector = newSelector(ok, ko);
- List<BatchExtension> extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, new Project("key"), true));
+ List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, new Project("key"), true));
assertThat(extensions.size(), is(1));
assertThat(extensions.get(0), is(CheckProjectOK.class));
BatchExtension b = new MethodDependentOf("foo");
BatchExtensionDictionnary selector = newSelector(b, a);
- List<BatchExtension> extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertEquals(2, extensions.size());
assertEquals(a, extensions.get(0));
// change initial order
selector = newSelector(a, b);
- extensions = new ArrayList<BatchExtension>(selector.select(BatchExtension.class, null, true));
+ extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertEquals(2, extensions.size());
assertEquals(a, extensions.get(0));
BatchExtension post = new PostSensor();
BatchExtensionDictionnary selector = newSelector(analyze, post, pre);
- List extensions = new ArrayList(selector.select(BatchExtension.class, null, true));
+ List extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertEquals(3, extensions.size());
assertEquals(pre, extensions.get(0));
BatchExtension post = new PostSensorSubclass();
BatchExtensionDictionnary selector = newSelector(analyze, post, pre);
- List extensions = new ArrayList(selector.select(BatchExtension.class, null, true));
+ List extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertEquals(3, extensions.size());
assertEquals(pre, extensions.get(0));
assertEquals(post, extensions.get(2));
}
-
@Test
public void buildStatusCheckersAreExecutedAfterOtherPostJobs() {
BuildBreaker checker = new BuildBreaker() {
};
BatchExtensionDictionnary selector = newSelector(new FakePostJob(), checker, new FakePostJob());
- List extensions = new ArrayList(selector.select(BatchExtension.class, null, true));
+ List extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true));
assertEquals(3, extensions.size());
assertEquals(checker, extensions.get(2));
interface InterfaceDependedUpon extends BatchExtension {
}
-
class GeneratesSomething implements BatchExtension {
private Object gen;