mirror of https://github.com/apache/maven.git
[MNG-5740]: Add module maven-builder-support
Move Source-code to maven-builder-support and let original classes extend these
This commit is contained in:
parent
fa71e5f5ad
commit
a7ef70181c
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven</artifactId>
|
||||
<version>3.2.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>maven-builder-support</artifactId>
|
||||
|
||||
<name>Maven Settings</name>
|
||||
<description>Maven Builder Support</description>
|
||||
|
||||
<scm><!-- remove when git scm url format can accept artifact-id at the end, as automatically inherited -->
|
||||
<connection>scm:git:https://git-wip-us.apache.org/repos/asf/maven.git</connection>
|
||||
<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/maven.git</developerConnection>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,79 @@
|
|||
package org.apache.maven.building;
|
||||
|
||||
/*
|
||||
* 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.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link File} as a source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class FileSource
|
||||
implements Source
|
||||
{
|
||||
private final File file;
|
||||
|
||||
/**
|
||||
* Creates a new source backed by the specified file.
|
||||
*
|
||||
* @param file The file, must not be {@code null}.
|
||||
*/
|
||||
public FileSource( File file )
|
||||
{
|
||||
if ( file == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no POM file specified" );
|
||||
}
|
||||
this.file = file.getAbsoluteFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return new FileInputStream( file );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation()
|
||||
{
|
||||
return file.getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file of this source.
|
||||
*
|
||||
* @return The underlying file, never {@code null}.
|
||||
*/
|
||||
public File getFile()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package org.apache.maven.building;
|
||||
|
||||
/*
|
||||
* 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.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Provides access to the contents of a source independently of the backing store (e.g. file system, database, memory).
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public interface Source
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a byte stream to the source contents. Closing the returned stream is the responsibility of the caller.
|
||||
*
|
||||
* @return A byte stream to the source contents, never {@code null}.
|
||||
*/
|
||||
InputStream getInputStream()
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Provides a user-friendly hint about the location of the source. This could be a local file path, a URI or just an
|
||||
* empty string. The intention is to assist users during error reporting.
|
||||
*
|
||||
* @return A user-friendly hint about the location of the source, never {@code null}.
|
||||
*/
|
||||
String getLocation();
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package org.apache.maven.building;
|
||||
|
||||
/*
|
||||
* 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.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link CharSequence} as a source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class StringSource
|
||||
implements Source
|
||||
{
|
||||
|
||||
private String content;
|
||||
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* Creates a new source backed by the specified string.
|
||||
*
|
||||
* @param content The String representation, may be empty or {@code null}.
|
||||
*/
|
||||
public StringSource( CharSequence content )
|
||||
{
|
||||
this( content, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new source backed by the specified string.
|
||||
*
|
||||
* @param content The String representation, may be empty or {@code null}.
|
||||
* @param location The location to report for this use, may be {@code null}.
|
||||
*/
|
||||
public StringSource( CharSequence content, String location )
|
||||
{
|
||||
this.content = ( content != null ) ? content.toString() : "";
|
||||
this.location = ( location != null ) ? location : "(memory)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return new ByteArrayInputStream( content.getBytes( "UTF-8" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content of this source.
|
||||
*
|
||||
* @return The underlying character stream, never {@code null}.
|
||||
*/
|
||||
public String getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package org.apache.maven.building;
|
||||
|
||||
/*
|
||||
* 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.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link URL} as a source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class UrlSource
|
||||
implements Source
|
||||
{
|
||||
|
||||
private URL url;
|
||||
|
||||
/**
|
||||
* Creates a new source backed by the specified URL.
|
||||
*
|
||||
* @param url The file, must not be {@code null}.
|
||||
*/
|
||||
public UrlSource( URL url )
|
||||
{
|
||||
if ( url == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no POM URL specified" );
|
||||
}
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return url.openStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation()
|
||||
{
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL of this source.
|
||||
*
|
||||
* @return The underlying URL, never {@code null}.
|
||||
*/
|
||||
public URL getUrl()
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
}
|
||||
|
||||
}
|
|
@ -47,6 +47,10 @@
|
|||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-builder-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.sisu</groupId>
|
||||
|
|
|
@ -20,20 +20,17 @@ package org.apache.maven.model.building;
|
|||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.maven.building.FileSource;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link File} as a model source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class FileModelSource
|
||||
implements ModelSource2
|
||||
public class FileModelSource extends FileSource implements ModelSource2
|
||||
{
|
||||
private final File pomFile;
|
||||
|
||||
/**
|
||||
* Creates a new model source backed by the specified file.
|
||||
|
@ -42,45 +39,27 @@ public class FileModelSource
|
|||
*/
|
||||
public FileModelSource( File pomFile )
|
||||
{
|
||||
if ( pomFile == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no POM file specified" );
|
||||
}
|
||||
this.pomFile = pomFile.getAbsoluteFile();
|
||||
super( pomFile );
|
||||
}
|
||||
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return new FileInputStream( pomFile );
|
||||
}
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return pomFile.getPath();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the POM file of this model source.
|
||||
*
|
||||
* @return The underlying POM file, never {@code null}.
|
||||
*
|
||||
* @return the file of this source
|
||||
*
|
||||
* @deprecated instead use {@link #getFile()}
|
||||
*/
|
||||
@Deprecated
|
||||
public File getPomFile()
|
||||
{
|
||||
return pomFile;
|
||||
return getFile();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
}
|
||||
|
||||
public ModelSource2 getRelatedSource( String relPath )
|
||||
{
|
||||
relPath = relPath.replace( '\\', File.separatorChar ).replace( '/', File.separatorChar );
|
||||
|
||||
File relatedPom = new File( pomFile.getParentFile(), relPath );
|
||||
File relatedPom = new File( getFile().getParentFile(), relPath );
|
||||
|
||||
if ( relatedPom.isDirectory() )
|
||||
{
|
||||
|
@ -96,8 +75,9 @@ public class FileModelSource
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getLocationURI()
|
||||
{
|
||||
return pomFile.toURI();
|
||||
return getFile().toURI();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.apache.maven.model.building;
|
||||
|
||||
import org.apache.maven.building.Source;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
|
@ -19,8 +21,6 @@ package org.apache.maven.model.building;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Provides access to the contents of a POM independently of the backing store (e.g. file system, database, memory).
|
||||
|
@ -30,24 +30,10 @@ import java.io.InputStream;
|
|||
*
|
||||
* @author Benjamin Bentmann
|
||||
* @see ModelSource2
|
||||
* @deprecated instead use {@link Source}
|
||||
*/
|
||||
public interface ModelSource
|
||||
@Deprecated
|
||||
public interface ModelSource extends org.apache.maven.building.Source
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a byte stream to the POM contents. Closing the returned stream is the responsibility of the caller.
|
||||
*
|
||||
* @return A byte stream to the POM contents, never {@code null}.
|
||||
*/
|
||||
InputStream getInputStream()
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Provides a user-friendly hint about the location of the POM. This could be a local file path, a URI or just an
|
||||
* empty string. The intention is to assist users during error reporting.
|
||||
*
|
||||
* @return A user-friendly hint about the location of the POM, never {@code null}.
|
||||
*/
|
||||
String getLocation();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.apache.maven.model.building;
|
||||
|
||||
import org.apache.maven.building.StringSource;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
|
@ -19,23 +21,19 @@ package org.apache.maven.model.building;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link CharSequence} as a model source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*
|
||||
* @deprecated instead use {@link StringSource}
|
||||
*/
|
||||
public class StringModelSource
|
||||
@Deprecated
|
||||
public class StringModelSource extends org.apache.maven.building.StringSource
|
||||
implements ModelSource
|
||||
{
|
||||
|
||||
private String pom;
|
||||
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* Creates a new model source backed by the specified string.
|
||||
*
|
||||
|
@ -54,35 +52,6 @@ public class StringModelSource
|
|||
*/
|
||||
public StringModelSource( CharSequence pom, String location )
|
||||
{
|
||||
this.pom = ( pom != null ) ? pom.toString() : "";
|
||||
this.location = ( location != null ) ? location : "(memory)";
|
||||
super( pom, location );
|
||||
}
|
||||
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return new ByteArrayInputStream( pom.getBytes( "UTF-8" ) );
|
||||
}
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the character sequence of this model source.
|
||||
*
|
||||
* @return The underlying character stream, never {@code null}.
|
||||
*/
|
||||
public String getModel()
|
||||
{
|
||||
return pom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,21 +19,21 @@ package org.apache.maven.model.building;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.maven.building.UrlSource;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link URL} as a model source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*
|
||||
* @deprecated instead use {@link UrlSource}
|
||||
*/
|
||||
public class UrlModelSource
|
||||
@Deprecated
|
||||
public class UrlModelSource extends org.apache.maven.building.UrlSource
|
||||
implements ModelSource
|
||||
{
|
||||
|
||||
private URL pomUrl;
|
||||
|
||||
/**
|
||||
* Creates a new model source backed by the specified URL.
|
||||
*
|
||||
|
@ -41,38 +41,6 @@ public class UrlModelSource
|
|||
*/
|
||||
public UrlModelSource( URL pomUrl )
|
||||
{
|
||||
if ( pomUrl == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no POM URL specified" );
|
||||
}
|
||||
this.pomUrl = pomUrl;
|
||||
super( pomUrl );
|
||||
}
|
||||
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return pomUrl.openStream();
|
||||
}
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return pomUrl.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the POM URL of this model source.
|
||||
*
|
||||
* @return The underlying POM URL, never {@code null}.
|
||||
*/
|
||||
public URL getPomUrl()
|
||||
{
|
||||
return pomUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,11 @@ under the License.
|
|||
</scm>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-builder-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
|
|
|
@ -20,21 +20,21 @@ package org.apache.maven.settings.building;
|
|||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.maven.building.FileSource;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link File} as a settings source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*
|
||||
* @deprecated instead use {@link FileSource}
|
||||
*/
|
||||
public class FileSettingsSource
|
||||
@Deprecated
|
||||
public class FileSettingsSource extends FileSource
|
||||
implements SettingsSource
|
||||
{
|
||||
|
||||
private File settingsFile;
|
||||
|
||||
/**
|
||||
* Creates a new settings source backed by the specified file.
|
||||
*
|
||||
|
@ -42,38 +42,18 @@ public class FileSettingsSource
|
|||
*/
|
||||
public FileSettingsSource( File settingsFile )
|
||||
{
|
||||
if ( settingsFile == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no settings file specified" );
|
||||
}
|
||||
this.settingsFile = settingsFile.getAbsoluteFile();
|
||||
}
|
||||
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return new FileInputStream( settingsFile );
|
||||
}
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return settingsFile.getPath();
|
||||
super( settingsFile );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the settings file of this model source.
|
||||
*
|
||||
* @return The underlying settings file, never {@code null}.
|
||||
* @deprecated instead use {@link #getFile()}
|
||||
*/
|
||||
@Deprecated
|
||||
public File getSettingsFile()
|
||||
{
|
||||
return settingsFile;
|
||||
return getFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,32 +19,17 @@ package org.apache.maven.settings.building;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import org.apache.maven.building.Source;
|
||||
|
||||
/**
|
||||
* Provides access to the contents of settings independently of the backing store (e.g. file system, database, memory).
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*
|
||||
* @deprecated instead use {@link Source}
|
||||
*/
|
||||
public interface SettingsSource
|
||||
@Deprecated
|
||||
public interface SettingsSource extends Source
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets a byte stream to the settings contents. Closing the returned stream is the responsibility of the caller.
|
||||
* Note that each invocation of this method returns a new/fresh stream which represents the entire contents.
|
||||
*
|
||||
* @return A byte stream to the settings contents, never {@code null}.
|
||||
*/
|
||||
InputStream getInputStream()
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Provides a user-friendly hint about the location of the settings. This could be a local file path, a URI or just
|
||||
* an empty string. The intention is to assist users during error reporting.
|
||||
*
|
||||
* @return A user-friendly hint about the location of the settings, never {@code null}.
|
||||
*/
|
||||
String getLocation();
|
||||
|
||||
}
|
||||
|
|
|
@ -19,23 +19,20 @@ package org.apache.maven.settings.building;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import org.apache.maven.building.StringSource;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link CharSequence} as a settings source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*
|
||||
* @deprecated instead use {@link StringSource}
|
||||
*/
|
||||
public class StringSettingsSource
|
||||
@Deprecated
|
||||
public class StringSettingsSource extends StringSource
|
||||
implements SettingsSource
|
||||
{
|
||||
|
||||
private String settings;
|
||||
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* Creates a new settings source backed by the specified string.
|
||||
*
|
||||
|
@ -54,35 +51,19 @@ public class StringSettingsSource
|
|||
*/
|
||||
public StringSettingsSource( CharSequence settings, String location )
|
||||
{
|
||||
this.settings = ( settings != null ) ? settings.toString() : "";
|
||||
this.location = ( location != null ) ? location : "(memory)";
|
||||
}
|
||||
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return new ByteArrayInputStream( settings.getBytes( "UTF-8" ) );
|
||||
}
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return location;
|
||||
super( settings, location );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the character sequence of this settings source.
|
||||
*
|
||||
* @return The underlying character stream, never {@code null}.
|
||||
* @deprecated instead use {@link #getContent()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getSettings()
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
return getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,21 +19,22 @@ package org.apache.maven.settings.building;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.maven.building.UrlSource;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link URL} as a settings source.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*
|
||||
* @deprecated instead use {@link UrlSource}
|
||||
*/
|
||||
public class UrlSettingsSource
|
||||
@Deprecated
|
||||
public class UrlSettingsSource extends UrlSource
|
||||
implements SettingsSource
|
||||
{
|
||||
|
||||
private URL settingsUrl;
|
||||
|
||||
/**
|
||||
* Creates a new model source backed by the specified URL.
|
||||
*
|
||||
|
@ -41,38 +42,19 @@ public class UrlSettingsSource
|
|||
*/
|
||||
public UrlSettingsSource( URL settingsUrl )
|
||||
{
|
||||
if ( settingsUrl == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no settings URL specified" );
|
||||
}
|
||||
this.settingsUrl = settingsUrl;
|
||||
}
|
||||
|
||||
public InputStream getInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return settingsUrl.openStream();
|
||||
}
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return settingsUrl.toString();
|
||||
super( settingsUrl );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the settings URL of this model source.
|
||||
*
|
||||
* @return The underlying settings URL, never {@code null}.
|
||||
* @deprecated instead use {@link #getUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
public URL getSettingsUrl()
|
||||
{
|
||||
return settingsUrl;
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getLocation();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -73,6 +73,7 @@
|
|||
|
||||
<modules>
|
||||
<module>maven-plugin-api</module>
|
||||
<module>maven-builder-support</module>
|
||||
<module>maven-model</module>
|
||||
<module>maven-model-builder</module>
|
||||
<module>maven-core</module>
|
||||
|
@ -197,6 +198,11 @@
|
|||
<artifactId>maven-repository-metadata</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-builder-support</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!--bootstrap-end-comment-->
|
||||
<!-- Plexus -->
|
||||
<dependency>
|
||||
|
@ -488,7 +494,7 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
||||
<version>1.10</version>
|
||||
<version>1.14-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<signature>
|
||||
<groupId>org.codehaus.mojo.signature</groupId>
|
||||
|
|
Loading…
Reference in New Issue