mirror of https://github.com/apache/maven.git
code simplification
This commit is contained in:
parent
ff21286eee
commit
66dc8c6ec1
|
@ -19,7 +19,6 @@ package org.apache.maven.repository.internal;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -27,10 +26,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.maven.artifact.repository.metadata.Versioning;
|
||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.sonatype.aether.RepositoryEvent.EventType;
|
||||
import org.sonatype.aether.RepositorySystemSession;
|
||||
import org.sonatype.aether.RequestTrace;
|
||||
|
@ -244,39 +241,25 @@ public class DefaultVersionRangeResolver
|
|||
{
|
||||
Versioning versioning = null;
|
||||
|
||||
FileInputStream fis = null;
|
||||
try
|
||||
if ( metadata != null )
|
||||
{
|
||||
if ( metadata != null )
|
||||
SyncContext syncContext = syncContextFactory.newInstance( session, true );
|
||||
|
||||
try
|
||||
{
|
||||
SyncContext syncContext = syncContextFactory.newInstance( session, true );
|
||||
syncContext.acquire( null, Collections.singleton( metadata ) );
|
||||
|
||||
try
|
||||
{
|
||||
syncContext.acquire( null, Collections.singleton( metadata ) );
|
||||
|
||||
if ( metadata.getFile() != null && metadata.getFile().exists() )
|
||||
{
|
||||
fis = new FileInputStream( metadata.getFile() );
|
||||
org.apache.maven.artifact.repository.metadata.Metadata m =
|
||||
new MetadataXpp3Reader().read( fis, false );
|
||||
versioning = m.getVersioning();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
syncContext.release();
|
||||
}
|
||||
versioning = DefaultVersionResolver.readMavenRepositoryMetadataVersioning( metadata.getFile() );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
invalidMetadata( session, trace, metadata, repository, e );
|
||||
result.addException( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
syncContext.release();
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
invalidMetadata( session, trace, metadata, repository, e );
|
||||
result.addException( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( fis );
|
||||
}
|
||||
|
||||
return ( versioning != null ) ? versioning : new Versioning();
|
||||
|
|
|
@ -365,7 +365,7 @@ public class DefaultVersionResolver
|
|||
return ( versioning != null ) ? versioning : new Versioning();
|
||||
}
|
||||
|
||||
private Versioning readMavenRepositoryMetadataVersioning( File metadataFile )
|
||||
static Versioning readMavenRepositoryMetadataVersioning( File metadataFile )
|
||||
throws IOException, XmlPullParserException
|
||||
{
|
||||
if ( metadataFile == null ||! metadataFile.exists() )
|
||||
|
|
Loading…
Reference in New Issue