/*
 * Copyright 2014 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Eclipse Public License version 1.0, available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.jboss.forge.furnace.impl.modules.providers;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.jboss.modules.DependencySpec;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoader;
import org.jboss.modules.ModuleSpec.Builder;
import org.jboss.modules.filter.PathFilters;

public class FurnaceContainerSpec extends AbstractModuleSpecProvider
{
   public static final ModuleIdentifier ID = ModuleIdentifier.create("org.jboss.forge.furnace.api");

   public static Set<String> paths = new HashSet<>();

   static
   {
      paths.add("org/jboss/forge/furnace/proxy/javassist");
      paths.add("org/jboss/forge/furnace/proxy/javassist/bytecode");
      paths.add("org/jboss/forge/furnace/proxy/javassist/bytecode/analysis");
      paths.add("org/jboss/forge/furnace/proxy/javassist/bytecode/annotation");
      paths.add("org/jboss/forge/furnace/proxy/javassist/bytecode/stackmap");
      paths.add("org/jboss/forge/furnace/proxy/javassist/compiler");
      paths.add("org/jboss/forge/furnace/proxy/javassist/compiler/ast");
      paths.add("org/jboss/forge/furnace/proxy/javassist/convert");
      paths.add("org/jboss/forge/furnace/proxy/javassist/expr");
      paths.add("org/jboss/forge/furnace/proxy/javassist/runtime");
      paths.add("org/jboss/forge/furnace/proxy/javassist/scopedpool");
      paths.add("org/jboss/forge/furnace/proxy/javassist/tools");
      paths.add("org/jboss/forge/furnace/proxy/javassist/tools/reflect");
      paths.add("org/jboss/forge/furnace/proxy/javassist/tools/rmi");
      paths.add("org/jboss/forge/furnace/proxy/javassist/tools/web");
      paths.add("org/jboss/forge/furnace/proxy/javassist/util");
      paths.add("org/jboss/forge/furnace/proxy/javassist/util/proxy");

      paths.add("org/jboss/forge/furnace");
      paths.add("org/jboss/forge/furnace/addons");
      paths.add("org/jboss/forge/furnace/event");
      paths.add("org/jboss/forge/furnace/exception");
      paths.add("org/jboss/forge/furnace/lifecycle");
      paths.add("org/jboss/forge/furnace/lock");
      paths.add("org/jboss/forge/furnace/repositories");
      paths.add("org/jboss/forge/furnace/services");
      paths.add("org/jboss/forge/furnace/spi");
      paths.add("org/jboss/forge/furnace/util");
      paths.add("org/jboss/forge/furnace/versions");

      paths.add("org/jboss/forge/furnace/proxy");
   }

   @Override
   protected void configure(ModuleLoader loader, Builder builder)
   {
      builder.addDependency(DependencySpec.createSystemDependencySpec(
               PathFilters.acceptAll(),
               PathFilters.all(
                        PathFilters.not(PathFilters.any(
                                 PathFilters.is("org/jboss/forge/furnace/impl"),
                                 PathFilters.isChildOf("org/jboss/forge/furnace/impl"))),

                        PathFilters.any(Arrays.asList(
                                 PathFilters.is("org/jboss/forge/furnace/proxy/javassist"),
                                 PathFilters.isChildOf("org/jboss/forge/furnace/proxy/javassist"),
                                 PathFilters.is("META-INF/services"),
                                 PathFilters.is("org/jboss/forge/furnace"),
                                 PathFilters.is("org/jboss/forge/furnace/addons"),
                                 PathFilters.is("org/jboss/forge/furnace/event"),
                                 PathFilters.is("org/jboss/forge/furnace/exception"),
                                 PathFilters.is("org/jboss/forge/furnace/lifecycle"),
                                 PathFilters.is("org/jboss/forge/furnace/lock"),
                                 PathFilters.is("org/jboss/forge/furnace/repositories"),
                                 PathFilters.is("org/jboss/forge/furnace/services"),
                                 PathFilters.is("org/jboss/forge/furnace/spi"),
                                 PathFilters.is("org/jboss/forge/furnace/util"),
                                 PathFilters.is("org/jboss/forge/furnace/versions"),
                                 PathFilters.is("org/jboss/forge/furnace/proxy")
                                 ))),
               getPaths()));
   }

   @Override
   public ModuleIdentifier getId()
   {
      return ID;
   }

   @Override
   protected Set<String> getPaths()
   {
      return paths;
   }

}

@@ -519,16 +519,92 @@
 lters;%0A%0A
+import static org.jboss.forge.furnace.impl.FurnaceImpl.TEST_MODE_PROPERTY;%0A%0A
 public c
@@ -834,24 +834,827 @@
 static%0A   %7B%0A
+      if (Boolean.getBoolean(TEST_MODE_PROPERTY))%0A      %7B%0A         paths.add(%22javassist%22);%0A         paths.add(%22javassist/bytecode%22);%0A         paths.add(%22javassist/bytecode/analysis%22);%0A         paths.add(%22javassist/bytecode/annotation%22);%0A         paths.add(%22javassist/bytecode/stackmap%22);%0A         paths.add(%22javassist/compiler%22);%0A         paths.add(%22javassist/compiler/ast%22);%0A         paths.add(%22javassist/convert%22);%0A         paths.add(%22javassist/expr%22);%0A         paths.add(%22javassist/runtime%22);%0A         paths.add(%22javassist/scopedpool%22);%0A         paths.add(%22javassist/tools%22);%0A         paths.add(%22javassist/tools/reflect%22);%0A         paths.add(%22javassist/tools/rmi%22);%0A         paths.add(%22javassist/tools/web%22);%0A         paths.add(%22javassist/util%22);%0A         paths.add(%22javassist/util/proxy%22);%0A      %7D%0A%0A
       paths.
@@ -5223,25 +5223,16 @@
 proxy%22)%0A
-         
         

Add javassist packages when running a test inside IDE