You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by bw...@apache.org on 2003/04/30 16:01:22 UTC
cvs commit: maven-new/core/src/java/org/apache/maven/plugin DefaultPluginManager.java
bwalding 2003/04/30 07:01:22
Modified: core/src/java/org/apache/maven/plugin
DefaultPluginManager.java
Log:
Add ashkelon plugin (yep still hardwired) and clean up method of adding plugins a fraction
Revision Changes Path
1.7 +68 -39 maven-new/core/src/java/org/apache/maven/plugin/DefaultPluginManager.java
Index: DefaultPluginManager.java
===================================================================
RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/plugin/DefaultPluginManager.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultPluginManager.java 28 Apr 2003 14:47:27 -0000 1.6
+++ DefaultPluginManager.java 30 Apr 2003 14:01:22 -0000 1.7
@@ -23,6 +23,7 @@
import com.werken.classworlds.ClassRealm;
import com.werken.classworlds.ClassWorld;
import com.werken.classworlds.DuplicateRealmException;
+import com.werken.classworlds.NoSuchRealmException;
import com.werken.werkz.Action;
import com.werken.werkz.CyclicGoalChainException;
import com.werken.werkz.Goal;
@@ -51,63 +52,35 @@
throw new RuntimeException("No plugin found : " + id);
}
- /* (non-Javadoc)
+ /**
* @see org.apache.maven.plugin.PluginManager#getPlugins()
*/
- List plugins = null;
+ private List plugins = null;
public List getPlugins()
{
if (plugins == null)
{
List l = new ArrayList();
- //XXX plexusify
try
{
- ClassRealm realm = null;
-
- ClassWorld classWorld = classWorldService.getClassWorld();
- for (Iterator iter = classWorld.getRealms().iterator(); iter.hasNext();)
- {
- ClassRealm r = (ClassRealm) iter.next();
- System.out.println("Known Realm:" + r.getId());
- }
-
- try {
- realm = classWorld.newRealm("maven-new:plugin-suiterunner");
- realm.setParent(classWorld.getRealm("root.maven"));
- } catch (DuplicateRealmException e) {
- realm = classWorld.getRealm("maven-new:plugin-suiterunner");
- }
-
-
- realm.importFrom("root.maven", "org.apache.maven.plugin.");
- realm.importFrom("root.maven", "org.apache.avalon.framework.");
- realm.importFrom("root.maven", "org.apache.plexus.");
- realm.addConstituent(getJar("maven-new", "plugin-suiterunner", "SNAPSHOT"));
-
- realm.displayConstituents();
-
- //XXX plexusify
- Class c = realm.loadClass("org.apache.maven.plugins.suiterunner.DefaultSuiteRunnerPlugin");
- //Class c = realm.loadClass("org.apache.maven.plugins.suiterunner.SuiteRunnerPlugin");
- System.out.println(c.getName());
- System.out.println(c.getInterfaces()[0]);
- l.add(c.newInstance());
+ l.add(configureSuiteRunnerPlugin());
+ l.add(configureAshkelonPlugin());
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException(e.getLocalizedMessage());
}
-
+
plugins = Collections.unmodifiableList(l);
}
return plugins;
}
/**Ignores jar overrides **/
- private URL getJar(String groupId, String artifactId, String version) throws DuplicateRealmException, MalformedURLException
+ private URL getJar(String groupId, String artifactId, String version)
+ throws DuplicateRealmException, MalformedURLException
{
Dependency d = new Dependency();
d.setId(groupId + ":" + artifactId);
@@ -116,7 +89,8 @@
GenericArtifact arti = new GenericArtifact(d);
File artif = new File(System.getProperty("maven.home") + "/repository/" + arti.getPath());
- if (!artif.exists()) {
+ if (!artif.exists())
+ {
System.out.println("Adding nonexistent constituent:" + artif.getAbsolutePath());
}
URL url = artif.toURL();
@@ -174,10 +148,10 @@
Iterator pluginIter = getPlugins().iterator();
while (pluginIter.hasNext())
{
- Object o = pluginIter.next();
- System.out.println("Object:" + o);
+ Object o = pluginIter.next();
+ System.out.println("Object:" + o);
final Plugin plugin = (Plugin) o;
-
+
Iterator goalIter = plugin.getGoals().iterator();
while (goalIter.hasNext())
{
@@ -229,6 +203,61 @@
}
+ public Plugin configureSuiteRunnerPlugin()
+ throws
+ NoSuchRealmException,
+ DuplicateRealmException,
+ MalformedURLException,
+ ClassNotFoundException,
+ InstantiationException,
+ IllegalAccessException
+ {
+ ClassRealm realm = configurePluginRealm("suiterunner");
+ realm.addConstituent(getJar("maven-new", "plugin-suiterunner", "SNAPSHOT"));
+
+ Class c = realm.loadClass("org.apache.maven.plugins.suiterunner.DefaultSuiteRunnerPlugin");
+ return (Plugin) c.newInstance();
+ }
+
+ public Plugin configureAshkelonPlugin()
+ throws
+ NoSuchRealmException,
+ DuplicateRealmException,
+ MalformedURLException,
+ ClassNotFoundException,
+ InstantiationException,
+ IllegalAccessException
+ {
+ ClassRealm realm = configurePluginRealm("ashkelon");
+ realm.addConstituent(getJar("maven-new", "plugin-ashkelon", "SNAPSHOT"));
+ realm.addConstituent(getJar("ashkelon", "ashkelon", "SNAPSHOT"));
+
+ Class c = realm.loadClass("org.apache.maven.plugins.ashkelon.DefaultAshkelonPlugin");
+ return (Plugin) c.newInstance();
+ }
+
+ public ClassRealm configurePluginRealm(String pluginArtifactId) throws NoSuchRealmException
+ {
+ ClassRealm realm = null;
+ ClassWorld classWorld = classWorldService.getClassWorld();
+
+ try
+ {
+ realm = classWorld.newRealm("maven-new:plugin-" + pluginArtifactId);
+ realm.setParent(classWorld.getRealm("root.maven"));
+ }
+ catch (DuplicateRealmException e)
+ {
+ realm = classWorld.getRealm("maven-new:plugin-" + pluginArtifactId);
+ }
+
+ realm.importFrom("root.maven", "org.apache.maven.plugin.");
+ realm.importFrom("root.maven", "org.apache.avalon.framework.");
+ realm.importFrom("root.maven", "org.apache.plexus.");
+
+ return realm;
+
+ }
}
/*
JellyPlugin jp = new DefaultJellyPlugin();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org