Author: sisbell Date: Wed Feb 28 11:45:25 2007 New Revision: 512930 URL: http://svn.apache.org/viewvc?view=rev&rev=512930 Log: Added profile support for .NET dependencies (from the net-dependencies.xml file). This allows the maven plugins to have different sets of .NET dependencies, so we can target different build environments for NMaven.
Added: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependenciesRepository.java (with props) incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependencyMatchPolicy.java (with props) incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java (with props) Removed: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepository.java Modified: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/resources/META-INF/nmaven/artifact-registry.xml incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/registry-config.xml incubator/nmaven/branches/SI_IDE/components/dotnet-model/netdependency/netdependency.mdo incubator/nmaven/branches/SI_IDE/maven-dotnet.iml incubator/nmaven/branches/SI_IDE/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java Added: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependenciesRepository.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependenciesRepository.java?view=auto&rev=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependenciesRepository.java (added) +++ incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependenciesRepository.java Wed Feb 28 11:45:25 2007 @@ -0,0 +1,68 @@ +/* + * 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. + */ +package org.apache.maven.dotnet.artifact; + +import org.apache.maven.dotnet.registry.Repository; +import org.apache.maven.dotnet.registry.RepositoryRegistry; +import org.apache.maven.model.Dependency; + +import java.io.InputStream; +import java.io.IOException; +import java.util.Hashtable; +import java.util.List; + +/** + * Provides methods for loading and reading the net dependency config file. + * + * @author Shane Isbell + */ +public interface NetDependenciesRepository + extends Repository +{ + /** + * @see org.apache.maven.dotnet.registry.Repository#load(java.io.InputStream, java.util.Hashtable) + */ + void load( InputStream inputStream, Hashtable properties ) + throws IOException; + + /** + * @see org.apache.maven.dotnet.registry.Repository#setRepositoryRegistry(org.apache.maven.dotnet.registry.RepositoryRegistry) + */ + void setRepositoryRegistry( RepositoryRegistry repositoryRegistry ); + + /** + * Returns a list of .NET dependencies as given within the net dependencies config file. This dependency list + * is external to the pom file dependencies. This separation is necessary since some Java Maven plugins + * - which themselves are necessary for building .NET applications - may have .NET executable dependencies that + * have not been built yet and can't be resolved. + * + * @return a list of .NET dependencies as given within the net dependencies config file + */ + List<Dependency> getDependencies(); + + /** + * Returns a list of .NET dependencies as given within the net dependencies config file that matches ALL of the + * specified match policies. + * + * @param matchPolicies the policies to match against the dependencies + * @return a list of .NET dependencies as given within the net dependencies config file that matches ALL of the + * specified match policies + */ + List<Dependency> getDependenciesFor( List<NetDependencyMatchPolicy> matchPolicies ); +} Propchange: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependenciesRepository.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependencyMatchPolicy.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependencyMatchPolicy.java?view=auto&rev=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependencyMatchPolicy.java (added) +++ incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependencyMatchPolicy.java Wed Feb 28 11:45:25 2007 @@ -0,0 +1,32 @@ +/* + * 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. + */ +package org.apache.maven.dotnet.artifact; + +import org.apache.maven.dotnet.model.netdependency.NetDependency; + +public interface NetDependencyMatchPolicy +{ + /** + * Return true if the policy matches the specified net dependency, otherwise returns false. + * + * @param netDependency the net dependency to match + * @return true if the policy matches the specified net dependency, otherwise returns false + */ + boolean match( NetDependency netDependency ); +} Propchange: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/NetDependencyMatchPolicy.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java?view=diff&rev=512930&r1=512929&r2=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java (original) +++ incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java Wed Feb 28 11:45:25 2007 @@ -111,8 +111,8 @@ */ public List<Artifact> getArtifactsFor( String groupId, String artifactId, String version, String type ) { - NetDependenciesRepository repository = - (NetDependenciesRepository) repositoryRegistry.find( "net-dependencies" ); + NetDependenciesRepositoryImpl repository = + (NetDependenciesRepositoryImpl) repositoryRegistry.find( "net-dependencies" ); if ( repository == null ) { logger.warn( Added: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java?view=auto&rev=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java (added) +++ incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java Wed Feb 28 11:45:25 2007 @@ -0,0 +1,214 @@ +/* + * 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. + */ +package org.apache.maven.dotnet.artifact.impl; + +import org.apache.maven.dotnet.registry.Repository; +import org.apache.maven.dotnet.registry.RepositoryRegistry; +import org.apache.maven.dotnet.model.netdependency.NetDependency; +import org.apache.maven.dotnet.model.netdependency.NetDependencyModel; +import org.apache.maven.dotnet.model.netdependency.io.xpp3.NetDependencyXpp3Reader; +import org.apache.maven.dotnet.artifact.NetDependenciesRepository; +import org.apache.maven.dotnet.artifact.NetDependencyMatchPolicy; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.apache.maven.model.Dependency; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.artifact.factory.ArtifactFactory; + +import java.util.List; +import java.util.Hashtable; +import java.util.ArrayList; +import java.io.InputStream; +import java.io.IOException; +import java.io.Reader; +import java.io.InputStreamReader; + + +/** + * Provides methods for loading and reading the net dependency config file. + * + * @author Shane Isbell + */ +public class NetDependenciesRepositoryImpl + implements NetDependenciesRepository +{ + + /** + * List of net dependencies. These dependencies are intended to be executed directly from the local Maven repository, + * not to be compiled against. + */ + private List<NetDependency> netDependencies; + + /** + * The artifact factory, used for creating artifacts. + */ + private ArtifactFactory artifactFactory; + + /** + * Constructor. This method is intended to be invoked by the <code>RepositoryRegistry<code>, not by the + * application developer. + */ + public NetDependenciesRepositoryImpl() + { + } + + /** + * @see Repository#load(java.io.InputStream, java.util.Hashtable) + */ + public void load( InputStream inputStream, Hashtable properties ) + throws IOException + { + NetDependencyXpp3Reader xpp3Reader = new NetDependencyXpp3Reader(); + Reader reader = new InputStreamReader( inputStream ); + NetDependencyModel model; + try + { + model = xpp3Reader.read( reader ); + } + catch ( XmlPullParserException e ) + { + e.printStackTrace(); + throw new IOException( "NMAVEN-062-000: Could not read plugins-compiler.xml" ); + } + netDependencies = model.getNetDependencies(); + } + + + /** + * @see Repository#setRepositoryRegistry(org.apache.maven.dotnet.registry.RepositoryRegistry) + */ + public void setRepositoryRegistry( RepositoryRegistry repositoryRegistry ) + { + } + + /** + * Returns a list of .NET dependencies as given within the net dependencies config file. This dependency list + * is external to the pom file dependencies. This separation is necessary since some Java Maven plugins + * - which themselves are necessary for building .NET applications - may have .NET executable dependencies that + * have not been built yet and can't be resolved. + * + * @return a list of .NET dependencies as given within the net dependencies config file + */ + public List<Dependency> getDependencies() + { + return getDependenciesFor(null); + } + + /** + * @see NetDependenciesRepository#getDependenciesFor(java.util.List<org.apache.maven.dotnet.artifact.NetDependencyMatchPolicy>) + */ + public List<Dependency> getDependenciesFor( List<NetDependencyMatchPolicy> matchPolicies ) + { + if(matchPolicies == null) matchPolicies = new ArrayList<NetDependencyMatchPolicy>(); + + List<Dependency> dependencies = new ArrayList<Dependency>(); + for ( NetDependency netDependency : netDependencies ) + { + if(isMatch(netDependency, matchPolicies)) dependencies.add( netDependencyToDependency( netDependency ) ); + } + return dependencies; + } + + /** + * Intializes this repository. + * + * @param artifactFactory the artifact factory + */ + void init( ArtifactFactory artifactFactory ) + { + this.artifactFactory = artifactFactory; + } + + + /** + * Return true is the specified net dependency matches ALL of the specified match policies, otherwise returns false. + * + * @param netDependency the net dependency to match + * @param matchPolicies the match policies to use in matching the net dependency + * @return true is the specified net dependency matches ALL of the specified match policies, otherwise returns false + */ + private boolean isMatch(NetDependency netDependency, List<NetDependencyMatchPolicy> matchPolicies) + { + for(NetDependencyMatchPolicy matchPolicy : matchPolicies) + { + if(!matchPolicy.match( netDependency)) return false; + } + return true; + } + /** + * Returns a list of artifacts that match the specified parameters. If the version or type parameters are null, + * then the returned list will include all versions and types. + * + * @param groupId the group ID of the artifact to match. This value should not be null. + * @param artifactId the artifact ID of the artifact to match. This value should not be null. + * @param version the version if the artifact to match. + * @param type the type of artifact to match + * @return a list of artifacts that match the specified parameters + */ + List<Artifact> getArtifactsFor( String groupId, String artifactId, String version, String type ) + { + List<Artifact> artifacts = new ArrayList<Artifact>(); + for ( NetDependency netDependency : netDependencies ) + { + if ( netDependency.getGroupId().equals( groupId ) && netDependency.getArtifactId().equals( artifactId ) && + ( version == null || netDependency.getVersion().equals( version ) ) && + ( type == null || netDependency.getType().equals( type ) ) ) + { + artifacts.add( netDependencyToArtifact( netDependency ) ); + } + + } + return artifacts; + } + + /** + * Copies the information from a <code>NetDependency</code> object to a <code>Dependency</code> object. This method + * is for converting from an NMaven specific model to a Maven model that can be used within the general Maven + * framework. Note that all artifacts automatically have a runtime scope since <code>NetDependencies</code> are + * always executables that are intended to be executed directly from the local Maven repository. + * + * @param netDependency the net dependency, which is the source to copy information from. + * @return dependency + */ + private Dependency netDependencyToDependency( NetDependency netDependency ) + { + Dependency dependency = new Dependency(); + dependency.setArtifactId( netDependency.getArtifactId() ); + dependency.setGroupId( netDependency.getGroupId() ); + dependency.setType( netDependency.getType() ); + dependency.setScope( Artifact.SCOPE_RUNTIME ); + dependency.setVersion( netDependency.getVersion() ); + return dependency; + } + + /** + * Creates an artifact based on the information from a <code>NetDepencency</code> object. Note that all artifacts + * automatically have a runtime scope since <code>NetDependencies</code> are always executables that + * are intended to be executed directly from the local Maven repository. + * + * @param dependency the net dependency, which is the source to copy information from. + * @return artifact + */ + private Artifact netDependencyToArtifact( NetDependency dependency ) + { + return artifactFactory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), + VersionRange.createFromVersion( dependency.getVersion() ), + dependency.getType(), null, Artifact.SCOPE_RUNTIME, null ); + } +} Propchange: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/NetDependenciesRepositoryImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/resources/META-INF/nmaven/artifact-registry.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/resources/META-INF/nmaven/artifact-registry.xml?view=diff&rev=512930&r1=512929&r2=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/resources/META-INF/nmaven/artifact-registry.xml (original) +++ incubator/nmaven/branches/SI_IDE/components/dotnet-artifact/src/main/resources/META-INF/nmaven/artifact-registry.xml Wed Feb 28 11:45:25 2007 @@ -4,7 +4,7 @@ <repositories> <repository> <repository-name>net-dependencies</repository-name> - <repository-class>org.apache.maven.dotnet.artifact.impl.NetDependenciesRepository</repository-class> + <repository-class>org.apache.maven.dotnet.artifact.impl.NetDependenciesRepositoryImpl</repository-class> <repository-config>/META-INF/nmaven/net-dependencies.xml</repository-config> </repository> </repositories> Modified: incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml?view=diff&rev=512930&r1=512929&r2=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml (original) +++ incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/net-dependencies.xml Wed Feb 28 11:45:25 2007 @@ -1,14 +1,21 @@ <netDependencies> - <netDependency> - <groupId>NMaven.Plugin</groupId> - <artifactId>NMaven.Plugin.Resx</artifactId> - <versionId>0.14</versionId> - <type>exe</type> - </netDependency> - <netDependency> - <groupId>NMaven.Plugin</groupId> - <artifactId>NMaven.Plugin.Settings</artifactId> - <versionId>0.14</versionId> - <type>exe</type> - </netDependency> + <netDependency> + <groupId>NMaven.Plugin</groupId> + <artifactId>NMaven.Plugin.Resx</artifactId> + <version>0.14</version> + <type>exe</type> + </netDependency> + <netDependency> + <groupId>NMaven.Plugin</groupId> + <artifactId>NMaven.Plugin.Settings</artifactId> + <version>0.14</version> + <type>exe</type> + </netDependency> + <netDependency> + <groupId>NMaven.Plugin</groupId> + <artifactId>NMaven.Plugin.Solution</artifactId> + <version>0.14</version> + <type>exe</type> + <profile>withIde</profile> + </netDependency> </netDependencies> Modified: incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/registry-config.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/registry-config.xml?view=diff&rev=512930&r1=512929&r2=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/registry-config.xml (original) +++ incubator/nmaven/branches/SI_IDE/components/dotnet-core/src/main/resources/META-INF/nmaven/registry-config.xml Wed Feb 28 11:45:25 2007 @@ -37,7 +37,7 @@ </repository> <repository> <repository-name>net-dependencies</repository-name> - <repository-class>org.apache.maven.dotnet.artifact.impl.NetDependenciesRepository</repository-class> + <repository-class>org.apache.maven.dotnet.artifact.impl.NetDependenciesRepositoryImpl</repository-class> <repository-config>/META-INF/nmaven/net-dependencies.xml</repository-config> </repository> </repositories> Modified: incubator/nmaven/branches/SI_IDE/components/dotnet-model/netdependency/netdependency.mdo URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/components/dotnet-model/netdependency/netdependency.mdo?view=diff&rev=512930&r1=512929&r2=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/components/dotnet-model/netdependency/netdependency.mdo (original) +++ incubator/nmaven/branches/SI_IDE/components/dotnet-model/netdependency/netdependency.mdo Wed Feb 28 11:45:25 2007 @@ -33,7 +33,7 @@ <description></description> </field> <field> - <name>versionId</name> + <name>version</name> <version>1.0.0</version> <type>String</type> <description> @@ -47,6 +47,12 @@ </field> <field> <name>type</name> + <version>1.0.0</version> + <type>String</type> + <description></description> + </field> + <field> + <name>profile</name> <version>1.0.0</version> <type>String</type> <description></description> Modified: incubator/nmaven/branches/SI_IDE/maven-dotnet.iml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/maven-dotnet.iml?view=diff&rev=512930&r1=512929&r2=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/maven-dotnet.iml (original) +++ incubator/nmaven/branches/SI_IDE/maven-dotnet.iml Wed Feb 28 11:45:25 2007 @@ -20,9 +20,11 @@ <sourceFolder url="file://$MODULE_DIR$/components/dotnet-vendor/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/plugins/maven-compile-plugin/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/plugins/maven-install-plugin/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/plugins/maven-link-plugin/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/plugins/maven-resgen-plugin/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/plugins/maven-resolver-plugin/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/plugins/maven-settings-plugin/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/plugins/maven-solution-plugin/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/plugins/maven-test-plugin/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/plugins/maven-vstudio-plugin/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/plugins/maven-webapp-plugin/src/main/java" isTestSource="false" /> Modified: incubator/nmaven/branches/SI_IDE/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_IDE/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java?view=diff&rev=512930&r1=512929&r2=512930 ============================================================================== --- incubator/nmaven/branches/SI_IDE/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java (original) +++ incubator/nmaven/branches/SI_IDE/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java Wed Feb 28 11:45:25 2007 @@ -34,7 +34,9 @@ import java.util.ArrayList; import org.apache.maven.dotnet.artifact.AssemblyResolver; -import org.apache.maven.dotnet.artifact.impl.NetDependenciesRepository; +import org.apache.maven.dotnet.artifact.NetDependenciesRepository; +import org.apache.maven.dotnet.artifact.NetDependencyMatchPolicy; +import org.apache.maven.dotnet.model.netdependency.NetDependency; /** * @author Shane Isbell @@ -94,6 +96,8 @@ return; } + String profile = System.getProperty( "Profile" ); + RepositoryRegistry repositoryRegistry; try { @@ -123,7 +127,9 @@ NetDependenciesRepository repository = (NetDependenciesRepository) repositoryRegistry.find( "net-dependencies" ); - dependencies.addAll( repository.getDependencies() ); + List<NetDependencyMatchPolicy> matchPolicies = new ArrayList<NetDependencyMatchPolicy>(); + matchPolicies.add( new ProfileMatchPolicy( profile ) ); + dependencies.addAll( repository.getDependenciesFor( matchPolicies ) ); getLog().info( "NMAVEN-1600-001: Found net dependencies: Number = " + dependencies.size() ); try @@ -139,6 +145,33 @@ { throw new MojoExecutionException( "NMAVEN-1600-003: Unable to resolve assemblies", e ); } + } + + private class ProfileMatchPolicy + implements NetDependencyMatchPolicy + { + private String profile; + + public ProfileMatchPolicy( String profile ) + { + this.profile = profile; + } + + public boolean match( NetDependency netDependency ) + { + //If no profile is specified in net-dependencies.xml, it matches + if ( netDependency.getProfile() == null || netDependency.getProfile().trim().equals( "" ) ) + { + return true; + } + + if ( profile == null ) + { + return false; + } + + return profile.equals( netDependency.getProfile() ); + } } }