diff --git a/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/AbstractStartMojo.java b/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/AbstractStartMojo.java index d7460180..9a2d6fb9 100644 --- a/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/AbstractStartMojo.java +++ b/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/AbstractStartMojo.java @@ -97,19 +97,9 @@ protected FileSystemServer createFileSystemServer(ArtifactStore artifactStore) { Math.max(0, Math.min(port, 65535)), basePath, new AutoDigestFileSystem(new ArtifactStoreFileSystem(artifactStore)), - getSettingsServletPath(), debugServer); } - /** - * When set, this points to the location from where the settings file can be downloaded. - * - * @return the servlet path to the settings file of {@code null} - */ - protected String getSettingsServletPath() { - return null; - } - /** * Creates an artifact store from the {@link #repositories} configuration. * diff --git a/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/FileSystemServer.java b/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/FileSystemServer.java index 8aeb6a9a..d3fdd4f7 100644 --- a/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/FileSystemServer.java +++ b/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/FileSystemServer.java @@ -16,9 +16,6 @@ * limitations under the License. */ -import java.net.InetAddress; -import java.net.UnknownHostException; - import org.apache.maven.plugin.MojoExecutionException; import org.codehaus.mojo.mrm.api.FileSystem; import org.codehaus.mojo.mrm.servlet.FileSystemServlet; @@ -102,11 +99,6 @@ public class FileSystemServer { */ private final String contextPath; - /** - * The path to settingsFile containing the configuration to connect to this repository manager. - */ - private final String settingsServletPath; - /** * Indicate debug level by Jetty server */ @@ -120,18 +112,11 @@ public class FileSystemServer { * @param fileSystem the file system to serve. * @param debugServer the server debug mode */ - public FileSystemServer( - String name, - int port, - String contextPath, - FileSystem fileSystem, - String settingsServletPath, - boolean debugServer) { + public FileSystemServer(String name, int port, String contextPath, FileSystem fileSystem, boolean debugServer) { this.name = name; this.fileSystem = fileSystem; this.requestedPort = port; this.contextPath = sanitizeContextPath(contextPath); - this.settingsServletPath = settingsServletPath; this.debugServer = debugServer; } @@ -253,17 +238,6 @@ public String getUrl() { return "http://localhost:" + getPort() + (contextPath.equals("/") ? "" : contextPath); } - /** - * Same as {@link #getUrl()}, but now for remote users - * - * @return the scheme + raw IP address + port + contextPath - * @throws UnknownHostException if the local host name could not be resolved into an address. - */ - public String getRemoteUrl() throws UnknownHostException { - return "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + getPort() - + (contextPath.equals("/") ? "" : contextPath); - } - /** * The work to monitor and control the Jetty instance that hosts the file system. */ @@ -282,7 +256,7 @@ public void run() { try { ServletContextHandler context = new ServletContextHandler(); context.setContextPath(contextPath); - context.addServlet(new ServletHolder(new FileSystemServlet(fileSystem, settingsServletPath)), "/*"); + context.addServlet(new ServletHolder(new FileSystemServlet(fileSystem)), "/*"); server.setHandler(context); server.start(); synchronized (lock) { diff --git a/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/RunMojo.java b/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/RunMojo.java index b1b8d70f..be7d445a 100644 --- a/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/RunMojo.java +++ b/mrm-maven-plugin/src/main/java/org/codehaus/mojo/mrm/plugin/RunMojo.java @@ -19,14 +19,9 @@ import javax.inject.Inject; import javax.inject.Named; -import java.net.UnknownHostException; - import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; /** * This goal is used in-situ on a Maven project to allow integration tests based on the Maven Invoker to use a custom @@ -38,11 +33,6 @@ */ @Mojo(name = "run", requiresProject = false, requiresDirectInvocation = true, threadSafe = true) public class RunMojo extends AbstractStartMojo { - /** - * ServletPath for the settings.xml, so it can be downloaded. - */ - @Parameter(property = "mrm.settingsServletPath", defaultValue = "settings-mrm.xml") - private String settingsServletPath; /** * Creates a new instance @@ -69,20 +59,6 @@ public void doExecute() throws MojoExecutionException, MojoFailureException { String url = mrm.getUrl(); try { getLog().info("Mock Repository Manager " + url + " is started."); - if (StringUtils.isNotEmpty(settingsServletPath)) { - String downloadUrl; - try { - downloadUrl = mrm.getRemoteUrl(); - } catch (UnknownHostException e) { - downloadUrl = mrm.getUrl(); - } - - String settings = FileUtils.filename(settingsServletPath); - - getLog().info("To share this repository manager, let users download " + downloadUrl + "/" - + settingsServletPath); - getLog().info("Maven should be started as 'mvn --settings " + settings + " [phase|goal]'"); - } ConsoleScanner consoleScanner = new ConsoleScanner(); consoleScanner.start(); getLog().info("Hit ENTER on the console to stop the Mock Repository Manager and continue the build."); @@ -100,12 +76,4 @@ public void doExecute() throws MojoExecutionException, MojoFailureException { } } } - - /** - * {@inheritDoc} - */ - @Override - protected String getSettingsServletPath() { - return settingsServletPath; - } } diff --git a/mrm-servlet/src/main/java/org/codehaus/mojo/mrm/servlet/FileSystemServlet.java b/mrm-servlet/src/main/java/org/codehaus/mojo/mrm/servlet/FileSystemServlet.java index e67a0758..9709c004 100644 --- a/mrm-servlet/src/main/java/org/codehaus/mojo/mrm/servlet/FileSystemServlet.java +++ b/mrm-servlet/src/main/java/org/codehaus/mojo/mrm/servlet/FileSystemServlet.java @@ -23,18 +23,13 @@ import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.PrintWriter; -import java.io.Reader; import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.UnknownHostException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; -import java.util.Collections; import java.util.Date; import org.apache.commons.io.IOUtils; @@ -45,8 +40,6 @@ import org.codehaus.mojo.mrm.api.FileEntry; import org.codehaus.mojo.mrm.api.FileSystem; import org.codehaus.mojo.mrm.impl.Utils; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.InterpolationFilterReader; /** * Servlet that serves a {@link FileSystem}. @@ -76,27 +69,21 @@ public class FileSystemServlet extends HttpServlet { */ private final FileSystem fileSystem; - /** - * @since 1.0 - */ - private String settingsServletPath; - /** * Constructor that takes a specific file system instance. * * @param fileSystem the file systen to serve. * @since 1.0 */ - public FileSystemServlet(FileSystem fileSystem, String settingsServletPath) { + public FileSystemServlet(FileSystem fileSystem) { this.fileSystem = fileSystem; - this.settingsServletPath = settingsServletPath; } /** * {@inheritDoc} */ @SuppressWarnings("checkstyle:MethodLength") - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String path = req.getPathInfo(); String context; if (path == null) { @@ -106,27 +93,6 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se context = req.getContextPath() + req.getServletPath(); } - if (path.equals("/" + settingsServletPath)) { - resp.setContentType("text/xml"); - PrintWriter w = resp.getWriter(); - - String hostAddress; - try { - hostAddress = InetAddress.getLocalHost().getHostAddress(); - } catch (UnknownHostException e) { - hostAddress = req.getServerName(); - } - - String repositoryProxyUrl = req.getScheme() + "://" + hostAddress + ":" + req.getServerPort(); - - try (Reader in = new InputStreamReader(FileSystemServlet.class.getResourceAsStream("/settings-mrm.xml")); - Reader settingsReader = new InterpolationFilterReader( - in, Collections.singletonMap("repository.proxy.url", repositoryProxyUrl), "@", "@")) { - IOUtil.copy(settingsReader, w); - } - return; - } - Entry entry = fileSystem.get(path); if (entry instanceof FileEntry) { FileEntry fileEntry = (FileEntry) entry; diff --git a/mrm-servlet/src/main/resources/settings-mrm.xml b/mrm-servlet/src/main/resources/settings-mrm.xml deleted file mode 100644 index 80fd9479..00000000 --- a/mrm-servlet/src/main/resources/settings-mrm.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - mrm-maven-plugin - Mock Repository Manager - @repository.proxy.url@ - * - - - - - it-repo - - true - - - - snapshots - @repository.proxy.url@ - - true - ignore - never - - - true - ignore - always - - - - - - snapshots - @repository.proxy.url@ - - true - ignore - never - - - true - ignore - always - - - - - -