mirror of https://github.com/apache/maven.git
[MNG-7576] Restore compatibility with maven 3.x (#841)
This commit is contained in:
parent
6a27f5f2f6
commit
3f03f0e7b2
|
@ -251,7 +251,7 @@ public class TestRepositorySystem
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Model model = modelReader.read( pomFile, null );
|
Model model = modelReader.read( pomFile, null ).getDelegate();
|
||||||
|
|
||||||
dependencies = Dependency.dependencyToApiV3( model.getDependencies() );
|
dependencies = Dependency.dependencyToApiV3( model.getDependencies() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ public class TestRepositorySystem
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Model model = modelReader.read( pomFile, null );
|
Model model = modelReader.read( pomFile, null ).getDelegate();
|
||||||
|
|
||||||
dependencies = model.getDependencies().stream().map( Dependency::new ).collect( Collectors.toList() );
|
dependencies = model.getDependencies().stream().map( Dependency::new ).collect( Collectors.toList() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -850,7 +850,7 @@ public class DefaultModelBuilder
|
||||||
if ( request.isLocationTracking() )
|
if ( request.isLocationTracking() )
|
||||||
{
|
{
|
||||||
source = new InputSource( null, modelSource.getLocation() );
|
source = new InputSource( null, modelSource.getLocation() );
|
||||||
options.put( ModelProcessor.INPUT_SOURCE, source );
|
options.put( ModelProcessor.INPUT_SOURCE, new org.apache.maven.model.InputSource( source ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -859,7 +859,7 @@ public class DefaultModelBuilder
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
model = modelProcessor.read( modelSource.getInputStream(), options );
|
model = modelProcessor.read( modelSource.getInputStream(), options ).getDelegate();
|
||||||
}
|
}
|
||||||
catch ( ModelParseException e )
|
catch ( ModelParseException e )
|
||||||
{
|
{
|
||||||
|
@ -872,7 +872,7 @@ public class DefaultModelBuilder
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
model = modelProcessor.read( modelSource.getInputStream(), options );
|
model = modelProcessor.read( modelSource.getInputStream(), options ).getDelegate();
|
||||||
}
|
}
|
||||||
catch ( ModelParseException ne )
|
catch ( ModelParseException ne )
|
||||||
{
|
{
|
||||||
|
@ -890,9 +890,11 @@ public class DefaultModelBuilder
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
org.apache.maven.api.model.InputSource v4src
|
||||||
|
= model.getLocation( "" ).getSource();
|
||||||
Field field = InputSource.class.getDeclaredField( "modelId" );
|
Field field = InputSource.class.getDeclaredField( "modelId" );
|
||||||
field.setAccessible( true );
|
field.setAccessible( true );
|
||||||
field.set( source, ModelProblemUtils.toId( model ) );
|
field.set( v4src, ModelProblemUtils.toId( model ) );
|
||||||
}
|
}
|
||||||
catch ( Throwable t )
|
catch ( Throwable t )
|
||||||
{
|
{
|
||||||
|
@ -974,14 +976,14 @@ public class DefaultModelBuilder
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// must implement TransformContext, but should use request to access properties/model cache
|
// must implement TransformContext, but should use request to access properties/model cache
|
||||||
org.apache.maven.api.model.Model transformedFileModel = modelProcessor.read( pomFile,
|
Model transformedFileModel = modelProcessor.read( pomFile,
|
||||||
Collections.singletonMap( ModelReader.TRANSFORMER_CONTEXT, context ) );
|
Collections.singletonMap( ModelReader.TRANSFORMER_CONTEXT, context ) );
|
||||||
|
|
||||||
// rawModel with locationTrackers, required for proper feedback during validations
|
// rawModel with locationTrackers, required for proper feedback during validations
|
||||||
|
|
||||||
// Apply enriched data
|
// Apply enriched data
|
||||||
rawModel = new Model( modelMerger.merge( rawModel.getDelegate(),
|
rawModel = new Model( modelMerger.merge( rawModel.getDelegate(),
|
||||||
transformedFileModel, false, null ) );
|
transformedFileModel.getDelegate(), false, null ) );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.apache.maven.api.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.io.ModelReader;
|
import org.apache.maven.model.io.ModelReader;
|
||||||
import org.apache.maven.model.locator.ModelLocator;
|
import org.apache.maven.model.locator.ModelLocator;
|
||||||
import org.eclipse.sisu.Typed;
|
import org.eclipse.sisu.Typed;
|
||||||
|
|
|
@ -31,8 +31,8 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.apache.maven.api.model.InputSource;
|
import org.apache.maven.model.InputSource;
|
||||||
import org.apache.maven.api.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.building.ModelSourceTransformer;
|
import org.apache.maven.model.building.ModelSourceTransformer;
|
||||||
import org.apache.maven.model.building.TransformerContext;
|
import org.apache.maven.model.building.TransformerContext;
|
||||||
import org.apache.maven.model.v4.MavenXpp3Reader;
|
import org.apache.maven.model.v4.MavenXpp3Reader;
|
||||||
|
@ -72,7 +72,9 @@ public class DefaultModelReader
|
||||||
{
|
{
|
||||||
Model model = read( in, input.toPath(), options );
|
Model model = read( in, input.toPath(), options );
|
||||||
|
|
||||||
return model.withPomFile( input.toPath() );
|
model.setPomFile( input );
|
||||||
|
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,11 +111,6 @@ public class DefaultModelReader
|
||||||
private InputSource getSource( Map<String, ?> options )
|
private InputSource getSource( Map<String, ?> options )
|
||||||
{
|
{
|
||||||
Object value = ( options != null ) ? options.get( INPUT_SOURCE ) : null;
|
Object value = ( options != null ) ? options.get( INPUT_SOURCE ) : null;
|
||||||
if ( value instanceof org.apache.maven.model.InputSource )
|
|
||||||
{
|
|
||||||
org.apache.maven.model.InputSource src = ( org.apache.maven.model.InputSource ) value;
|
|
||||||
return new InputSource( src.getModelId(), src.getLocation() );
|
|
||||||
}
|
|
||||||
return (InputSource) value;
|
return (InputSource) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,14 +161,15 @@ public class DefaultModelReader
|
||||||
throws XmlPullParserException, IOException
|
throws XmlPullParserException, IOException
|
||||||
{
|
{
|
||||||
MavenXpp3Reader mr = new MavenXpp3Reader();
|
MavenXpp3Reader mr = new MavenXpp3Reader();
|
||||||
return mr.read( parser, strict );
|
return new Model( mr.read( parser, strict ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model readModelEx( XmlPullParser parser, InputSource source, boolean strict )
|
private Model readModelEx( XmlPullParser parser, InputSource source, boolean strict )
|
||||||
throws XmlPullParserException, IOException
|
throws XmlPullParserException, IOException
|
||||||
{
|
{
|
||||||
MavenXpp3ReaderEx mr = new MavenXpp3ReaderEx();
|
MavenXpp3ReaderEx mr = new MavenXpp3ReaderEx();
|
||||||
return mr.read( parser, strict, source );
|
return new Model( mr.read( parser, strict,
|
||||||
|
new org.apache.maven.api.model.InputSource( source.getModelId(), source.getLocation() ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,7 @@ import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.maven.api.model.InputSource;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.api.model.Model;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles deserialization of a model from some kind of textual format like XML.
|
* Handles deserialization of a model from some kind of textual format like XML.
|
||||||
|
@ -44,7 +43,7 @@ public interface ModelReader
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key for the option to enable tracking of line/column numbers. This option is of type
|
* The key for the option to enable tracking of line/column numbers. This option is of type
|
||||||
* {@link InputSource} and defaults to {@code null}. Providing an input source enables
|
* {@link org.apache.maven.model.InputSource} and defaults to {@code null}. Providing an input source enables
|
||||||
* location tracking.
|
* location tracking.
|
||||||
*/
|
*/
|
||||||
String INPUT_SOURCE = "org.apache.maven.model.io.inputSource";
|
String INPUT_SOURCE = "org.apache.maven.model.io.inputSource";
|
||||||
|
|
|
@ -80,9 +80,9 @@ public class DefaultSuperPomProvider
|
||||||
+ this.getClass().getPackage().getImplementationVersion() + ":super-pom";
|
+ this.getClass().getPackage().getImplementationVersion() + ":super-pom";
|
||||||
InputSource inputSource = new InputSource(
|
InputSource inputSource = new InputSource(
|
||||||
modelId, getClass().getResource( resource ).toExternalForm() );
|
modelId, getClass().getResource( resource ).toExternalForm() );
|
||||||
options.put( ModelProcessor.INPUT_SOURCE, inputSource );
|
options.put( ModelProcessor.INPUT_SOURCE, new org.apache.maven.model.InputSource( inputSource ) );
|
||||||
|
|
||||||
superModel = modelProcessor.read( is, options );
|
superModel = modelProcessor.read( is, options ).getDelegate();
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class DefaultInheritanceAssemblerTest
|
||||||
private Model getModel( String name )
|
private Model getModel( String name )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
return reader.read( getPom( name ), null );
|
return reader.read( getPom( name ), null ).getDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue