From bf8d692a15333107ab5bfc8652b5a5b88b550e07 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Sun, 23 Sep 2007 16:57:46 +0000 Subject: [PATCH] o reverting fix for MNG-1323, breaks trunk horribly when everything is clean. I ran the ITs after Piotr did but doing so with everything clean doesn't work. Time for Hudson. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@578582 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/DefaultPluginManager.java | 123 +++++++------- .../plugin/DefaultPluginRealmManager.java | 153 ------------------ .../maven/plugin/MavenPluginCollector.java | 153 +++++------------- .../maven/plugin/PluginRealmManager.java | 18 --- .../resources/META-INF/plexus/components.xml | 14 +- .../plugin/DefaultPluginRealmManagerTest.java | 130 --------------- 6 files changed, 103 insertions(+), 488 deletions(-) delete mode 100644 maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmManager.java delete mode 100644 maven-core/src/main/java/org/apache/maven/plugin/PluginRealmManager.java delete mode 100644 maven-core/src/test/java/org/apache/maven/plugin/DefaultPluginRealmManagerTest.java diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 5de4763272..06c7d158d9 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -105,8 +105,6 @@ public class DefaultPluginManager RESERVED_GROUP_IDS = rgids; } - - protected PluginRealmManager pluginRealmManager; protected PlexusContainer container; @@ -379,70 +377,67 @@ public class DefaultPluginManager { // TODO When/if we go to project-level plugin instances (like for plugin-level deps in the // POM), we need to undo this somehow. + ClassRealm pluginRealm = container.getComponentRealm( projectPlugin.getKey() ); - ClassRealm componentRealm = pluginRealmManager.getOrCreateRealm(projectPlugin, pluginArtifact, artifacts); - -// ClassRealm pluginRealm = container.getComponentRealm( projectPlugin.getKey()+":"+projectPlugin.getVersion() ); + if ( ( pluginRealm != null ) && ( pluginRealm != container.getContainerRealm() ) ) + { + getLogger().debug( + "Realm already exists for: " + projectPlugin.getKey() + + ". Skipping addition..." ); + // we've already discovered this plugin, and configured it, so skip it this time. -// if ( ( pluginRealm != null ) && ( pluginRealm != container.getContainerRealm() ) ) -// { -// getLogger().debug( -// "Realm already exists for: " + projectPlugin.getKey() -// + ". Skipping addition..." ); -// // we've already discovered this plugin, and configured it, so skip it this time. -// -// return; -// } -// -// // ---------------------------------------------------------------------------- -// // Realm creation for a plugin -// // ---------------------------------------------------------------------------- -// -// ClassRealm componentRealm = null; -// -// try -// { -// List jars = new ArrayList(); -// -// for ( Iterator i = artifacts.iterator(); i.hasNext(); ) -// { -// Artifact artifact = (Artifact) i.next(); -// -// jars.add( artifact.getFile() ); -// } -// -// jars.add( pluginArtifact.getFile() ); -// -// // Now here we need the artifact coreArtifactFilter stuff -// -// componentRealm = container.createComponentRealm( projectPlugin.getKey()+projectPlugin.getVersion(), jars ); -// -// // adding for MNG-3012 to try to work around problems with Xpp3Dom (from plexus-utils) -// // spawning a ClassCastException when a mojo calls plugin.getConfiguration() from maven-model... -// componentRealm.importFrom( componentRealm.getParentRealm().getId(), -// Xpp3Dom.class.getName() ); -// componentRealm.importFrom( componentRealm.getParentRealm().getId(), -// "org.codehaus.plexus.util.xml.pull" ); -// -// // Adding for MNG-2878, since maven-reporting-impl was removed from the -// // internal list of artifacts managed by maven, the classloader is different -// // between maven-reporting-impl and maven-reporting-api...so this resource -// // is not available from the AbstractMavenReport since it uses: -// // getClass().getResourceAsStream( "/default-report.xml" ) -// // (maven-reporting-impl version 2.0; line 134; affects: checkstyle plugin, and probably others) -// componentRealm.importFrom( componentRealm.getParentRealm().getId(), "/default-report.xml" ); -// } -// catch ( PlexusContainerException e ) -// { -// throw new PluginManagerException( "Failed to create realm for plugin '" + projectPlugin -// + ".", e ); -// } -// catch ( NoSuchRealmException e ) -// { -// throw new PluginManagerException( -// "Failed to import Xpp3Dom from parent realm for plugin: '" -// + projectPlugin + ".", e ); -// } + return; + } + + // ---------------------------------------------------------------------------- + // Realm creation for a plugin + // ---------------------------------------------------------------------------- + + ClassRealm componentRealm = null; + + try + { + List jars = new ArrayList(); + + for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + { + Artifact artifact = (Artifact) i.next(); + + jars.add( artifact.getFile() ); + } + + jars.add( pluginArtifact.getFile() ); + + // Now here we need the artifact coreArtifactFilter stuff + + componentRealm = container.createComponentRealm( projectPlugin.getKey(), jars ); + + // adding for MNG-3012 to try to work around problems with Xpp3Dom (from plexus-utils) + // spawning a ClassCastException when a mojo calls plugin.getConfiguration() from maven-model... + componentRealm.importFrom( componentRealm.getParentRealm().getId(), + Xpp3Dom.class.getName() ); + componentRealm.importFrom( componentRealm.getParentRealm().getId(), + "org.codehaus.plexus.util.xml.pull" ); + + // Adding for MNG-2878, since maven-reporting-impl was removed from the + // internal list of artifacts managed by maven, the classloader is different + // between maven-reporting-impl and maven-reporting-api...so this resource + // is not available from the AbstractMavenReport since it uses: + // getClass().getResourceAsStream( "/default-report.xml" ) + // (maven-reporting-impl version 2.0; line 134; affects: checkstyle plugin, and probably others) + componentRealm.importFrom( componentRealm.getParentRealm().getId(), "/default-report.xml" ); + } + catch ( PlexusContainerException e ) + { + throw new PluginManagerException( "Failed to create realm for plugin '" + projectPlugin + + ".", e ); + } + catch ( NoSuchRealmException e ) + { + throw new PluginManagerException( + "Failed to import Xpp3Dom from parent realm for plugin: '" + + projectPlugin + ".", e ); + } // ---------------------------------------------------------------------------- // The PluginCollector will now know about the plugin we are trying to load diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmManager.java deleted file mode 100644 index 0c076f31ed..0000000000 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmManager.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.apache.maven.plugin; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; -import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.model.Plugin; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.PlexusContainerException; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * @author Piotr Tabor - */ -public class DefaultPluginRealmManager - extends AbstractLogEnabled - implements PluginRealmManager -{ - private PlexusContainer container; - - public ClassRealm getOrCreateRealm( Plugin projectPlugin, Artifact pluginArtifact, Set artifacts ) - throws PluginManagerException - { - Set allArtifacts = new HashSet( artifacts ); - allArtifacts.add( pluginArtifact ); - - List/* */pluginJars = generateJarsListForArtifacts( allArtifacts ); - - String realmKey = generateChildContainerName( projectPlugin, allArtifacts ); - ClassRealm pluginRealm = container.getComponentRealm( realmKey ); - - if ( ( pluginRealm != null ) && ( pluginRealm != container.getContainerRealm() ) ) - { - getLogger().debug( "Realm already exists for: " + realmKey + ". Skipping addition..." ); - /* - * we've already discovered this plugin, and configured it, so skip it this time. - */ - return pluginRealm; - } - - // ---------------------------------------------------------------------------- - // Realm creation for a plugin - // ---------------------------------------------------------------------------- - - ClassRealm componentRealm = null; - - try - { - // Now here we need the artifact coreArtifactFilter - // stuff - - componentRealm = container.createComponentRealm( realmKey, pluginJars ); - - /* - * adding for MNG-3012 to try to work around problems with Xpp3Dom (from plexus-utils spawning a - * ClassCastException when a mojo calls plugin.getConfiguration() from maven-model... - */ - componentRealm.importFrom( componentRealm.getParentRealm().getId(), Xpp3Dom.class.getName() ); - componentRealm.importFrom( componentRealm.getParentRealm().getId(), "org.codehaus.plexus.util.xml.pull" ); - - /* - * Adding for MNG-2878, since maven-reporting-impl was removed from the internal list of artifacts managed - * by maven, the classloader is different between maven-reporting-impl and maven-reporting-api...so this - * resource is not available from the AbstractMavenReport since it uses: getClass().getResourceAsStream( - * "/default-report.xml" ) (maven-reporting-impl version 2.0; line 134; affects: checkstyle plugin, and - * probably others) - */ - componentRealm.importFrom( componentRealm.getParentRealm().getId(), "/default-report.xml" ); - - } - catch ( PlexusContainerException e ) - { - throw new PluginManagerException( "Failed to create realm for plugin '" + projectPlugin + ".", e ); - } - catch ( NoSuchRealmException e ) - { - throw new PluginManagerException( "Failed to import Xpp3Dom from parent realm for plugin: '" + - projectPlugin + ".", e ); - } - - getLogger().debug( "Realm for plugin: " + realmKey + ":\n" + componentRealm ); - - // ---------------------------------------------------------------------------- - // The PluginCollector will now know about the plugin we - // are trying to load - // ---------------------------------------------------------------------------- - - return componentRealm; - } - - List/* */generateJarsListForArtifacts( Set/* */artifacts ) - { - List/* */jars = new ArrayList(); - - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) - { - Artifact artifact = (Artifact) i.next(); - - jars.add( artifact.getFile() ); - } - - return jars; - } - - - private static String generateChildContainerName( Plugin plugin, Set artifacts ) - { - return plugin.getKey() + ":" + plugin.getVersion() + ":" + getHashOfArtifacts( artifacts ); - } - - static long getHashOfArtifacts( Set a ) - { - long i = 1; - Iterator/* */iterator = a.iterator(); - while ( iterator.hasNext() ) - { - Artifact artifact = (Artifact) iterator.next(); - i = ( i * artifact.hashCode() ) % 2147483647 /* big prime */; - } - return i; - } -} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java index 74e1b3148d..b299d90f9f 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java @@ -31,26 +31,18 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; public class MavenPluginCollector extends AbstractLogEnabled implements ComponentDiscoveryListener { - /** - * Map from pluginDescriptor.getKey (groupId:artifactId) into (ordered) map from version into pluginDescriptor - * Internal map is ordered to make sure that builds are determinic (used pluginVersion is determined) - */ - private Map/* > */pluginDescriptors = new HashMap(); - private Map/* > */pluginIdsByPrefix = new HashMap(); + private Set pluginsInProcess = new HashSet(); + + private Map pluginDescriptors = new HashMap(); + + private Map pluginIdsByPrefix = new HashMap(); - public String getId() - { - return "maven-plugin-collector"; - } - // ---------------------------------------------------------------------- // Mojo discovery // ---------------------------------------------------------------------- @@ -61,125 +53,66 @@ public class MavenPluginCollector if ( componentSetDescriptor instanceof PluginDescriptor ) { PluginDescriptor pluginDescriptor = (PluginDescriptor) componentSetDescriptor; + + // TODO: see comment in getPluginDescriptor + String key = Plugin.constructKey( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId() ); - putIntoPluginDescriptors( pluginDescriptor ); - putIntoPluginIdsByPrefix( pluginDescriptor ); + if ( !pluginsInProcess.contains( key ) ) + { + pluginsInProcess.add( key ); + + getLogger().debug( this + ": Discovered plugin: " + key ); + + pluginDescriptors.put( key, pluginDescriptor ); + + // TODO: throw an (not runtime) exception if there is a prefix overlap - means doing so elsewhere + // we also need to deal with multiple versions somehow - currently, first wins + if ( !pluginIdsByPrefix.containsKey( pluginDescriptor.getGoalPrefix() ) ) + { + pluginIdsByPrefix.put( pluginDescriptor.getGoalPrefix(), pluginDescriptor ); + } + } } } + public String getId() + { + return "maven-plugin-collector"; + } + public PluginDescriptor getPluginDescriptor( Plugin plugin ) { - SortedMap/* */pluginVersions = (SortedMap) pluginDescriptors.get( plugin.getKey() ); - if ( pluginVersions != null ) - { - PluginDescriptor res; - if ( plugin.getVersion() != null ) - { - res = (PluginDescriptor) pluginVersions.get( plugin.getVersion() ); - } - else - { - res = getDefaultPluginDescriptorVersion( pluginVersions ); - } - return res; - } - else - { - return null; - } - } - - private PluginDescriptor getDefaultPluginDescriptorVersion( SortedMap pluginVersions ) - { - if ( pluginVersions.size() > 0 ) - { - return (PluginDescriptor) pluginVersions.get( pluginVersions.lastKey() ); - } - else - { - return null; - } + // TODO: include version, but can't do this in the plugin manager as it is not resolved to the right version + // at that point. Instead, move the duplication check to the artifact container, or store it locally based on + // the unresolved version? + return (PluginDescriptor) pluginDescriptors.get( plugin.getKey() ); } public boolean isPluginInstalled( Plugin plugin ) { // TODO: see comment in getPluginDescriptor - return getPluginDescriptor( plugin ) != null; + return pluginDescriptors.containsKey( plugin.getKey() ); } public PluginDescriptor getPluginDescriptorForPrefix( String prefix ) { - return getPluginDescriptorForPrefix( prefix, null ); + return (PluginDescriptor) pluginIdsByPrefix.get( prefix ); } - public PluginDescriptor getPluginDescriptorForPrefix( String prefix, String version ) + public void flushPluginDescriptor( Plugin plugin ) { - SortedMap/* */pluginVersions = (SortedMap) pluginIdsByPrefix.get( prefix ); - if ( pluginVersions != null ) + pluginsInProcess.remove( plugin.getKey() ); + pluginDescriptors.remove( plugin.getKey() ); + + for ( Iterator it = pluginIdsByPrefix.entrySet().iterator(); it.hasNext(); ) { - PluginDescriptor res; - if ( version != null ) + Map.Entry entry = (Map.Entry) it.next(); + + if ( plugin.getKey().equals( entry.getValue() ) ) { - res = (PluginDescriptor) pluginVersions.get( version ); + it.remove(); } - else - { - res = getDefaultPluginDescriptorVersion( pluginVersions ); - } - return res; } - else - { - return null; - } - } - -// public void flushPluginDescriptor( Plugin plugin ) -// { -// getPluginDescriptor( plugin ).cleanPluginDescriptor(); -// } - - /** - * Puts given pluginDescriptor into pluginDescriptors map (if the map does not contains plugin for specified maven - * version) - * - * @param pluginDescriptor - */ - protected void putIntoPluginDescriptors( PluginDescriptor pluginDescriptor ) - { - String key = Plugin.constructKey( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId() ); - - SortedMap/* */descriptorsVersions = (SortedMap) pluginDescriptors.get( key ); - if ( descriptorsVersions == null ) - { - descriptorsVersions = new TreeMap(); - pluginDescriptors.put( key, descriptorsVersions ); - } - - putIntoVersionsMap( descriptorsVersions, pluginDescriptor ); - } - - protected void putIntoVersionsMap( SortedMap/* */pluginVersions, - PluginDescriptor pluginDescriptor ) - { - if ( !pluginVersions.containsKey( pluginDescriptor.getVersion() ) ) - { - pluginVersions.put( pluginDescriptor.getVersion(), pluginDescriptor ); - } - } - - protected void putIntoPluginIdsByPrefix( PluginDescriptor pluginDescriptor ) - { - String goalPrefix = pluginDescriptor.getGoalPrefix(); - - SortedMap/* */descriptorsVersions = (SortedMap) pluginIdsByPrefix.get( goalPrefix ); - if ( descriptorsVersions == null ) - { - descriptorsVersions = new TreeMap(); - pluginIdsByPrefix.put( goalPrefix, descriptorsVersions ); - } - - putIntoVersionsMap( descriptorsVersions, pluginDescriptor ); } } diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmManager.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmManager.java deleted file mode 100644 index 3871f34437..0000000000 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmManager.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.apache.maven.plugin; - -import java.util.Set; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.model.Plugin; -import org.codehaus.plexus.classworlds.realm.ClassRealm; - -/** - * - * @author Piotr Tabor - */ -public interface PluginRealmManager -{ - public static final String ROLE=PluginRealmManager.class.getName(); - - public ClassRealm getOrCreateRealm( Plugin projectPlugin, Artifact pluginArtifact, Set artifacts ) throws PluginManagerException; -} \ No newline at end of file diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml index 74a03e782b..2c4a16cee6 100644 --- a/maven-core/src/main/resources/META-INF/plexus/components.xml +++ b/maven-core/src/main/resources/META-INF/plexus/components.xml @@ -64,10 +64,7 @@ under the License. org.apache.maven.plugin.MavenPluginCollector - - org.apache.maven.plugin.PluginRealmManager - - + org.apache.maven.plugin.version.PluginVersionManager default @@ -731,14 +728,5 @@ under the License. - - org.apache.maven.plugin.PluginRealmManager - org.apache.maven.plugin.DefaultPluginRealmManager - - - org.codehaus.plexus.PlexusContainer - - - diff --git a/maven-core/src/test/java/org/apache/maven/plugin/DefaultPluginRealmManagerTest.java b/maven-core/src/test/java/org/apache/maven/plugin/DefaultPluginRealmManagerTest.java deleted file mode 100644 index b1dfa91f82..0000000000 --- a/maven-core/src/test/java/org/apache/maven/plugin/DefaultPluginRealmManagerTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.apache.maven.plugin; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.codehaus.plexus.PlexusTestCase; - -public class DefaultPluginRealmManagerTest - extends PlexusTestCase -{ - public void testCreateComponent() - throws Exception - { - assertNotNull( "Cannot lookup component: " + PluginRealmManager.ROLE, lookup( PluginRealmManager.ROLE ) ); - } - - public void testGenerateJarsListForArtifactsEmpty() - throws Exception - { - DefaultPluginRealmManager defaultPluginRealmManager = new DefaultPluginRealmManager(); - - assertEquals( "List of jars generated by empty set should be empty", 0, - defaultPluginRealmManager.generateJarsListForArtifacts( Collections.EMPTY_SET ).size() ); - } - - public void testGenerateJarsListForArtifacts() - throws Exception - { - DefaultPluginRealmManager defaultPluginRealmManager = new DefaultPluginRealmManager(); - - /*Different artifactId*/ - List/* */result = - defaultPluginRealmManager.generateJarsListForArtifacts( createArtifactSet( HashSet.class, 5 ) ); - checkListOfNumeredFiles( 5, result ); - - /*Different groups*/ - result = - defaultPluginRealmManager.generateJarsListForArtifacts( createArtifactSetGroups( HashSet.class, 6 ) ); - checkListOfNumeredFiles( 6, result ); - - /*Different versions*/ - result = - defaultPluginRealmManager.generateJarsListForArtifacts( createArtifactSetVersions( HashSet.class, 4 ) ); - checkListOfNumeredFiles( 4, result ); - } - - public void testGetHashOfArtifacts() throws Exception - { - assertEquals("Hash code of empty set should be always the same", DefaultPluginRealmManager.getHashOfArtifacts( Collections.EMPTY_SET), DefaultPluginRealmManager.getHashOfArtifacts( Collections.EMPTY_SET)); - assertEquals("Hash code should be the same for the same content of artifacts list",DefaultPluginRealmManager.getHashOfArtifacts(createArtifactSet(HashSet.class,5)),DefaultPluginRealmManager.getHashOfArtifacts(createArtifactSet(HashSet.class,5))); - assertEquals("Hash code should not depend on set implementation",DefaultPluginRealmManager.getHashOfArtifacts(createArtifactSet(HashSet.class,5)),DefaultPluginRealmManager.getHashOfArtifacts(createArtifactSet(TreeSet.class,5))); - - assertTrue( "Hash should be different for different content", DefaultPluginRealmManager.getHashOfArtifacts(createArtifactSet(HashSet.class,5))!=DefaultPluginRealmManager.getHashOfArtifacts(createArtifactSet(TreeSet.class,6))); - } - - - // =========================== Helpers ==================================================== - - private void checkListOfNumeredFiles( int count, List/* */result ) - throws MalformedURLException - { - assertEquals( "Unexpected size of created urls list: ", count, result.size() ); - for ( int i = 0; i < count; i++ ) - { - File expectedFile = createNumberedFile( i ); - assertTrue( "Expected url not found: " + expectedFile + " in: " + result, result.contains( expectedFile ) ); - } - } - - protected Artifact createArtifact( String groupId, String artifactId, String version ) - throws Exception - { - ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - - // TODO: used to be SCOPE_COMPILE, check - return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" ); - } - - protected Set/* */createArtifactSet( Class/* */setClass, int count ) - throws Exception - { - Set/* */artifactSet = (Set) setClass.newInstance(); - for ( int i = 0; i < count; i++ ) - { - Artifact artifact = createArtifact( "testGroup", "testArtifact_" + i, "1.0" ); - artifact.setFile( createNumberedFile( i ) ); - artifactSet.add( artifact ); - } - return artifactSet; - } - - protected Set/* */createArtifactSetVersions( Class/* */setClass, int count ) - throws Exception - { - Set/* */artifactSet = (Set) setClass.newInstance(); - for ( int i = 0; i < count; i++ ) - { - Artifact artifact = createArtifact( "testGroup", "testArtifact", i + ".0" ); - artifact.setFile( createNumberedFile( i ) ); - artifactSet.add( artifact ); - } - return artifactSet; - } - - protected Set/* */createArtifactSetGroups( Class/* */setClass, int count ) - throws Exception - { - Set/* */artifactSet = (Set) setClass.newInstance(); - for ( int i = 0; i < count; i++ ) - { - Artifact artifact = createArtifact( "testGroup" + i, "testArtifact_", "1.0" ); - artifact.setFile( createNumberedFile( i ) ); - artifactSet.add( artifact ); - } - return artifactSet; - } - - protected File createNumberedFile( int i ) - { - return new File( "/not_existing_file_" + i + ".jar" ); - } -}