o adding method to the maven project builder that takes a transfer listener

as a parameter. this method is currently being used in the embedder

o see MNG-1015 for notes on where the monitor may be bested placed. if
everything eventually uses the embedder then it won't matter so much.



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@291499 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2005-09-26 00:23:33 +00:00
parent 4cc524c904
commit 853028dfab
8 changed files with 111 additions and 14 deletions

View File

@ -509,7 +509,7 @@ public class DefaultMaven
wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), server.getPassword(),
server.getPrivateKey(), server.getPassphrase() );
wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(),
server.getDirectoryPermissions() );
}

View File

@ -32,6 +32,7 @@ import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.RuntimeInfo;
import org.apache.maven.wagon.events.TransferListener;
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.classworlds.DuplicateRealmException;
import org.codehaus.plexus.PlexusContainerException;
@ -171,6 +172,12 @@ public class MavenEmbedder
return mavenProjectBuilder.build( mavenProject, localRepository, profileManager );
}
public MavenProject readProjectWithDependencies( File mavenProject, TransferListener transferListener )
throws ProjectBuildingException, ArtifactResolutionException
{
return mavenProjectBuilder.buildWithDependencies( mavenProject, localRepository, profileManager, transferListener );
}
public MavenProject readProjectWithDependencies( File mavenProject )
throws ProjectBuildingException, ArtifactResolutionException
{

View File

@ -18,6 +18,7 @@ package org.apache.maven.project;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactStatus;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
@ -55,6 +56,7 @@ import org.apache.maven.project.interpolation.ModelInterpolator;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
import org.apache.maven.wagon.events.TransferListener;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@ -126,6 +128,14 @@ public class DefaultMavenProjectBuilder
private ArtifactTransformationManager transformationManager;
// ----------------------------------------------------------------------
// I am making this available for use with a new method that takes a
// a monitor wagon monitor as a parameter so that tools can use the
// methods here and receive callbacks. MNG-1015
// ----------------------------------------------------------------------
private WagonManager wagonManager;
private final Map modelCache = new HashMap();
public static final String MAVEN_MODEL_VERSION = "4.0.0";
@ -141,11 +151,21 @@ public class DefaultMavenProjectBuilder
// MavenProjectBuilder Implementation
// ----------------------------------------------------------------------
public MavenProject buildWithDependencies( File projectDescriptor,
ArtifactRepository localRepository,
ProfileManager profileManager )
throws ProjectBuildingException, ArtifactResolutionException
{
return buildWithDependencies( projectDescriptor, localRepository, profileManager, null );
}
/**
* @todo move to metadatasource itself?
*/
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
ProfileManager profileManager )
public MavenProject buildWithDependencies( File projectDescriptor,
ArtifactRepository localRepository,
ProfileManager profileManager,
TransferListener transferListener )
throws ProjectBuildingException, ArtifactResolutionException
{
MavenProject project = buildFromSourceFile( projectDescriptor, localRepository, profileManager );
@ -177,6 +197,12 @@ public class DefaultMavenProjectBuilder
{
throw new ProjectBuildingException( "Error in dependency version", e );
}
if ( transferListener != null )
{
wagonManager.setDownloadMonitor( transferListener );
}
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
projectArtifact, managedVersions,
localRepository,
@ -184,6 +210,7 @@ public class DefaultMavenProjectBuilder
artifactMetadataSource );
project.setArtifacts( result.getArtifacts() );
return project;
}

View File

@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.wagon.events.TransferListener;
import java.io.File;
import java.util.List;
@ -43,9 +44,25 @@ public interface MavenProjectBuilder
MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager )
throws ProjectBuildingException;
MavenProject buildWithDependencies( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager )
// ----------------------------------------------------------------------
// These methods are used by the MavenEmbedder
// ----------------------------------------------------------------------
MavenProject buildWithDependencies( File project,
ArtifactRepository localRepository,
ProfileManager globalProfileManager,
TransferListener transferListener )
throws ProjectBuildingException, ArtifactResolutionException;
MavenProject buildWithDependencies( File project,
ArtifactRepository localRepository,
ProfileManager globalProfileManager )
throws ProjectBuildingException, ArtifactResolutionException;
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
/**
* Build the artifact from the local repository, resolving it if necessary.
*

View File

@ -83,6 +83,9 @@
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement>
</requirements>
</component>
<!--

View File

@ -311,12 +311,27 @@ Merged:
System vars are accessed implicitly in m2...try:
+-----+
<configuration>
<debug>${build.debug}</debug>
<source>${build.jdk}</source>
<target>${build.jdk}</target>
</configuration>
==
How to attach sources to a release?
> How does the sources plugin realize that it is part of a snapshot
> build, and therefore not generate a sources JAR?
>
> I didn't notice anything obvious in the source code for the Mojo at
It only does so when the release profile (see the root POM) is activated.
==
How do I get the list of artifacts within my plugin?
You must use the @requiresDependencyResolution tag in your plugin.
+-----+

View File

@ -19,6 +19,14 @@
<entry name=".+\.(properties|xml|html)" />
<entry name=".+\.(gif|png|jpeg)" />
</resourceExtensions>
<wildcardResourcePatterns>
<entry name="?*.properties" />
<entry name="?*.xml" />
<entry name="?*.html" />
<entry name="?*.gif" />
<entry name="?*.png" />
<entry name="?*.jpeg" />
</wildcardResourcePatterns>
</component>
<component name="DataSourceManager" />
<component name="DataSourceManagerImpl" />
@ -184,7 +192,7 @@
<module fileurl="file://$PROJECT_DIR$/maven-acm.iml" filepath="$PROJECT_DIR$/maven-acm.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" assert-keyword="false" jdk-15="false" project-jdk-name="java version 1.4.2_09" />
<component name="ProjectRootManager" version="2" assert-keyword="false" jdk-15="false" project-jdk-name="java version &quot;1.4.2&quot;" />
<component name="RmicSettings">
<option name="IS_EANABLED" value="false" />
<option name="DEBUGGING_INFO" value="true" />

View File

@ -176,7 +176,19 @@
</favorites_list>
<option name="myCurrentFavoritesList" value="maven-acm" />
</component>
<component name="FileEditorManager" />
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="PropertiesComparator.java" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/org/apache/maven/acm/PropertiesComparator.java">
<provider selected="true" editor-type-id="text-editor">
<state line="21" column="40" selection-start="554" selection-end="554" vertical-scroll-proportion="0.19441675">
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FindManager">
<FindUsagesManager>
<setting name="OPEN_NEW_TAB" value="false" />
@ -215,8 +227,8 @@
<option name="ADD_LABEL_ON_UNIT_TEST_FAILED" value="true" />
</component>
<component name="ModuleEditorState">
<option name="LAST_EDITED_MODULE_NAME" />
<option name="LAST_EDITED_TAB_NAME" />
<option name="LAST_EDITED_MODULE_NAME" value="maven-acm" />
<option name="LAST_EDITED_TAB_NAME" value="Libraries (Classpath)" />
</component>
<component name="NamedScopeManager" />
<component name="PackagesPane">
@ -510,12 +522,12 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-2" y="29" width="1610" height="1154" extended-state="1" />
<editor active="false" />
<frame x="-2" y="29" width="1610" height="1154" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="7" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.25" order="0" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.25" order="0" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="1" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" />
@ -602,7 +614,15 @@
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager" />
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/main/java/org/apache/maven/acm/PropertiesComparator.java">
<provider selected="true" editor-type-id="text-editor">
<state line="21" column="40" selection-start="554" selection-end="554" vertical-scroll-proportion="0.19441675">
<folding />
</state>
</provider>
</entry>
</component>
<component name="editorManager" />
</project>