diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java index 4583b065c..b2d6bd67c 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java @@ -35,7 +35,6 @@ import org.eclipse.aether.resolution.ArtifactDescriptorPolicy; import org.eclipse.aether.resolution.ResolutionErrorPolicy; import org.eclipse.aether.transfer.TransferListener; -import org.eclipse.aether.transform.FileTransformerManager; /** * A special repository system session to enable decorating or proxying another session. To do so, clients have to @@ -186,9 +185,4 @@ public SessionData getData() { public RepositoryCache getCache() { return getSession().getCache(); } - - @Override - public FileTransformerManager getFileTransformerManager() { - return getSession().getFileTransformerManager(); - } } diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java index 9738d9a07..6bcf1be72 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java @@ -18,12 +18,10 @@ */ package org.eclipse.aether; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.ArtifactType; import org.eclipse.aether.artifact.ArtifactTypeRegistry; import org.eclipse.aether.collection.DependencyGraphTransformer; @@ -44,8 +42,6 @@ import org.eclipse.aether.resolution.ArtifactDescriptorPolicy; import org.eclipse.aether.resolution.ResolutionErrorPolicy; import org.eclipse.aether.transfer.TransferListener; -import org.eclipse.aether.transform.FileTransformer; -import org.eclipse.aether.transform.FileTransformerManager; import static java.util.Objects.requireNonNull; @@ -77,8 +73,6 @@ public final class DefaultRepositorySystemSession implements RepositorySystemSes private LocalRepositoryManager localRepositoryManager; - private FileTransformerManager fileTransformerManager; - private WorkspaceReader workspaceReader; private RepositoryListener repositoryListener; @@ -135,7 +129,6 @@ public DefaultRepositorySystemSession() { proxySelector = NullProxySelector.INSTANCE; authenticationSelector = NullAuthenticationSelector.INSTANCE; artifactTypeRegistry = NullArtifactTypeRegistry.INSTANCE; - fileTransformerManager = NullFileTransformerManager.INSTANCE; data = new DefaultSessionData(); } @@ -173,7 +166,6 @@ public DefaultRepositorySystemSession(RepositorySystemSession session) { setDependencySelector(session.getDependencySelector()); setVersionFilter(session.getVersionFilter()); setDependencyGraphTransformer(session.getDependencyGraphTransformer()); - setFileTransformerManager(session.getFileTransformerManager()); setData(session.getData()); setCache(session.getCache()); } @@ -341,20 +333,6 @@ public DefaultRepositorySystemSession setLocalRepositoryManager(LocalRepositoryM return this; } - @Override - public FileTransformerManager getFileTransformerManager() { - return fileTransformerManager; - } - - public DefaultRepositorySystemSession setFileTransformerManager(FileTransformerManager fileTransformerManager) { - verifyStateForMutation(); - this.fileTransformerManager = fileTransformerManager; - if (this.fileTransformerManager == null) { - this.fileTransformerManager = NullFileTransformerManager.INSTANCE; - } - return this; - } - @Override public WorkspaceReader getWorkspaceReader() { return workspaceReader; @@ -814,13 +792,4 @@ public ArtifactType get(String typeId) { return null; } } - - static final class NullFileTransformerManager implements FileTransformerManager { - public static final FileTransformerManager INSTANCE = new NullFileTransformerManager(); - - @Override - public Collection getTransformersForArtifact(Artifact artifact) { - return Collections.emptyList(); - } - } } diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java index 581161119..66ce8bfff 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java @@ -36,7 +36,6 @@ import org.eclipse.aether.resolution.ArtifactDescriptorPolicy; import org.eclipse.aether.resolution.ResolutionErrorPolicy; import org.eclipse.aether.transfer.TransferListener; -import org.eclipse.aether.transform.FileTransformerManager; /** * Defines settings and components that control the repository system. Once initialized, the session object itself is @@ -270,14 +269,4 @@ public interface RepositorySystemSession { * @return The repository cache or {@code null} if none. */ RepositoryCache getCache(); - - /** - * Get the file transformer manager - * - * @return the manager, never {@code null} - * @deprecated Without any direct replacement for now. This API is OOM-prone, and also lacks a lot of context about - * transforming. - */ - @Deprecated - FileTransformerManager getFileTransformerManager(); } diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformer.java b/maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformer.java deleted file mode 100644 index bf45d9755..000000000 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformer.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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. - */ -package org.eclipse.aether.transform; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -import org.eclipse.aether.artifact.Artifact; - -/** - * Can transform a file while installing/deploying - * - * @author Robert Scholte - * @since 1.3.0 - * @deprecated Without any direct replacement for now. This API is OOM-prone, and also lacks a lot of context about - * transforming. - */ -@Deprecated -public interface FileTransformer { - /** - * Transform the target location - * - * @param artifact the original artifact - * @return the transformed artifact - */ - Artifact transformArtifact(Artifact artifact); - - /** - * Transform the data - * - * @param file the file with the original data - * @return the transformed data - * @throws IOException If an I/O error occurred - * @throws TransformException If the file could not be transformed - */ - InputStream transformData(File file) throws IOException, TransformException; -} diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformerManager.java b/maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformerManager.java deleted file mode 100644 index 7b7c87d7d..000000000 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformerManager.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ -package org.eclipse.aether.transform; - -import java.util.Collection; - -import org.eclipse.aether.artifact.Artifact; - -/** - * Manager the FileTransformers - * - * @author Robert Scholte - * @since 1.3.0 - * @deprecated Without any direct replacement for now. This API is OOM-prone, and also lacks a lot of context about - * transforming. - */ -@Deprecated -public interface FileTransformerManager { - /** - *

- * All transformers for this specific artifact. Be aware that if you want to create additional files, but also want - * to the original to be deployed, you must add an explicit transformer for that file too (one that doesn't - * transform the artifact and data). - *

- * - *

IMPORTANT When using a fileTransformer, the content of the file is stored in memory to ensure - * that file content and checksums stay in sync! - *

- * - * @param artifact the artifact - * @return a collection of FileTransformers to apply on the artifact, never {@code null} - */ - Collection getTransformersForArtifact(Artifact artifact); -} diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/TransformException.java b/maven-resolver-api/src/main/java/org/eclipse/aether/transform/TransformException.java deleted file mode 100644 index 9e24b1d3d..000000000 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/TransformException.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - */ -package org.eclipse.aether.transform; - -/** - * Thrown when transformation failed. - * - * @deprecated Without any direct replacement for now. This API is OOM-prone, and also lacks a lot of context about - * transforming. - */ -@Deprecated -public class TransformException extends Exception { - - /** - * Creates a new exception with default detail message. - */ - public TransformException() { - super("Transformation failed"); - } - - /** - * Creates a new exception with the specified detail message. - * - * @param message The detail message, may be {@code null}. - */ - public TransformException(String message) { - super(message); - } - - /** - * Creates a new exception with the specified cause. - * - * @param cause The exception that caused this one, may be {@code null}. - */ - public TransformException(Throwable cause) { - super(cause); - } - - /** - * Creates a new exception with the specified detail message and cause. - * - * @param message The detail message, may be {@code null}. - * @param cause The exception that caused this one, may be {@code null}. - */ - public TransformException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java index 11e9a9133..051d679ce 100644 --- a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java +++ b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java @@ -18,10 +18,8 @@ */ package org.eclipse.aether.connector.basic; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.UncheckedIOException; import java.net.URI; import java.util.ArrayList; @@ -61,7 +59,6 @@ import org.eclipse.aether.transfer.NoTransporterException; import org.eclipse.aether.transfer.TransferEvent; import org.eclipse.aether.transfer.TransferResource; -import org.eclipse.aether.transform.FileTransformer; import org.eclipse.aether.util.ConfigUtils; import org.eclipse.aether.util.FileUtils; import org.eclipse.aether.util.concurrency.ExecutorUtils; @@ -291,8 +288,7 @@ public void put( List checksumLocations = layout.getChecksumLocations(transfer.getArtifact(), true, location); - Runnable task = new PutTaskRunner( - location, transfer.getFile(), transfer.getFileTransformer(), checksumLocations, listener); + Runnable task = new PutTaskRunner(location, transfer.getFile(), checksumLocations, listener); if (first) { task.run(); first = false; @@ -509,8 +505,6 @@ class PutTaskRunner extends TaskRunner { private final File file; - private final FileTransformer fileTransformer; - private final Collection checksumLocations; PutTaskRunner( @@ -518,52 +512,16 @@ class PutTaskRunner extends TaskRunner { File file, List checksumLocations, TransferTransportListener listener) { - this(path, file, null, checksumLocations, listener); - } - - /** - * IMPORTANT When using a fileTransformer, the content of the file is stored in memory to - * ensure that file content and checksums stay in sync! - * - * @param path - * @param file - * @param fileTransformer - * @param checksumLocations - * @param listener - */ - PutTaskRunner( - URI path, - File file, - FileTransformer fileTransformer, - List checksumLocations, - TransferTransportListener listener) { super(path, listener); this.file = requireNonNull(file, "source file cannot be null"); - this.fileTransformer = fileTransformer; this.checksumLocations = safe(checksumLocations); } @SuppressWarnings("checkstyle:innerassignment") @Override protected void runTask() throws Exception { - if (fileTransformer != null) { - // transform data once to byte array, ensure constant data for checksum - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - - try (InputStream transformData = fileTransformer.transformData(file)) { - for (int read; (read = transformData.read(buffer, 0, buffer.length)) != -1; ) { - baos.write(buffer, 0, read); - } - } - - byte[] bytes = baos.toByteArray(); - transporter.put(new PutTask(path).setDataBytes(bytes).setListener(listener)); - uploadChecksums(file, bytes); - } else { - transporter.put(new PutTask(path).setDataFile(file).setListener(listener)); - uploadChecksums(file, null); - } + transporter.put(new PutTask(path).setDataFile(file).setListener(listener)); + uploadChecksums(file, null); } /** diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java index e451fa1a4..ea4158204 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java @@ -71,8 +71,6 @@ import org.eclipse.aether.transfer.RepositoryOfflineException; import org.eclipse.aether.transfer.TransferCancelledException; import org.eclipse.aether.transfer.TransferEvent; -import org.eclipse.aether.transform.FileTransformer; -import org.eclipse.aether.transform.FileTransformerManager; import static java.util.Objects.requireNonNull; @@ -221,8 +219,6 @@ private DeployResult deploy(SyncContext syncContext, RepositorySystemSession ses try { List generators = getMetadataGenerators(session, request); - FileTransformerManager fileTransformerManager = session.getFileTransformerManager(); - List artifactUploads = new ArrayList<>(); List metadataUploads = new ArrayList<>(); IdentityHashMap processedMetadata = new IdentityHashMap<>(); @@ -249,23 +245,10 @@ private DeployResult deploy(SyncContext syncContext, RepositorySystemSession ses iterator.set(artifact); - Collection fileTransformers = - fileTransformerManager.getTransformersForArtifact(artifact); - if (!fileTransformers.isEmpty()) { - for (FileTransformer fileTransformer : fileTransformers) { - Artifact targetArtifact = fileTransformer.transformArtifact(artifact); - - ArtifactUpload upload = new ArtifactUpload(targetArtifact, artifact.getFile(), fileTransformer); - upload.setTrace(trace); - upload.setListener(new ArtifactUploadListener(catapult, upload)); - artifactUploads.add(upload); - } - } else { - ArtifactUpload upload = new ArtifactUpload(artifact, artifact.getFile()); - upload.setTrace(trace); - upload.setListener(new ArtifactUploadListener(catapult, upload)); - artifactUploads.add(upload); - } + ArtifactUpload upload = new ArtifactUpload(artifact, artifact.getFile()); + upload.setTrace(trace); + upload.setListener(new ArtifactUploadListener(catapult, upload)); + artifactUploads.add(upload); } connector.put(artifactUploads, null); diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java index c30f75a2e..842975662 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java @@ -23,7 +23,6 @@ import javax.inject.Singleton; import java.io.File; -import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.IdentityHashMap; @@ -53,7 +52,6 @@ import org.eclipse.aether.spi.locator.Service; import org.eclipse.aether.spi.locator.ServiceLocator; import org.eclipse.aether.spi.synccontext.SyncContextFactory; -import org.eclipse.aether.transform.FileTransformer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -211,39 +209,11 @@ private List getMetadataGenerators( private void install(RepositorySystemSession session, RequestTrace trace, Artifact artifact) throws InstallationException { - LocalRepositoryManager lrm = session.getLocalRepositoryManager(); + final LocalRepositoryManager lrm = session.getLocalRepositoryManager(); + final File srcFile = artifact.getFile(); + final File dstFile = new File(lrm.getRepository().getBasedir(), lrm.getPathForLocalArtifact(artifact)); - File srcFile = artifact.getFile(); - - Collection fileTransformers = - session.getFileTransformerManager().getTransformersForArtifact(artifact); - if (fileTransformers.isEmpty()) { - install(session, trace, artifact, lrm, srcFile, null); - } else { - for (FileTransformer fileTransformer : fileTransformers) { - install(session, trace, artifact, lrm, srcFile, fileTransformer); - } - } - } - - private void install( - RepositorySystemSession session, - RequestTrace trace, - Artifact artifact, - LocalRepositoryManager lrm, - File srcFile, - FileTransformer fileTransformer) - throws InstallationException { - final Artifact targetArtifact; - if (fileTransformer != null) { - targetArtifact = fileTransformer.transformArtifact(artifact); - } else { - targetArtifact = artifact; - } - - File dstFile = new File(lrm.getRepository().getBasedir(), lrm.getPathForLocalArtifact(targetArtifact)); - - artifactInstalling(session, trace, targetArtifact, dstFile); + artifactInstalling(session, trace, artifact, dstFile); Exception exception = null; try { @@ -251,29 +221,24 @@ private void install( throw new IllegalStateException("cannot install " + dstFile + " to same path"); } - boolean copy = "pom".equals(targetArtifact.getExtension()) + boolean copy = "pom".equals(artifact.getExtension()) || srcFile.lastModified() != dstFile.lastModified() || srcFile.length() != dstFile.length() || !srcFile.exists(); if (!copy) { LOGGER.debug("Skipped re-installing {} to {}, seems unchanged", srcFile, dstFile); - } else if (fileTransformer != null) { - try (InputStream is = fileTransformer.transformData(srcFile)) { - fileProcessor.write(dstFile, is); - dstFile.setLastModified(srcFile.lastModified()); - } } else { fileProcessor.copy(srcFile, dstFile); dstFile.setLastModified(srcFile.lastModified()); } - lrm.add(session, new LocalArtifactRegistration(targetArtifact)); + lrm.add(session, new LocalArtifactRegistration(artifact)); } catch (Exception e) { exception = e; - throw new InstallationException("Failed to install artifact " + targetArtifact + ": " + e.getMessage(), e); + throw new InstallationException("Failed to install artifact " + artifact + ": " + e.getMessage(), e); } finally { - artifactInstalled(session, trace, targetArtifact, dstFile, exception); + artifactInstalled(session, trace, artifact, dstFile, exception); } } diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDeployerTest.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDeployerTest.java index 499f3107b..aa739fe5a 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDeployerTest.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDeployerTest.java @@ -18,11 +18,8 @@ */ package org.eclipse.aether.internal.impl; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -51,8 +48,6 @@ import org.eclipse.aether.spi.connector.MetadataUpload; import org.eclipse.aether.spi.connector.RepositoryConnector; import org.eclipse.aether.transfer.MetadataNotFoundException; -import org.eclipse.aether.transform.FileTransformer; -import org.eclipse.aether.util.artifact.SubArtifact; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -339,31 +334,4 @@ public void close() {} TestFileUtils.readProps(metadataFile, props); assertNull(props.toString(), props.get("old")); } - - @Test - public void testFileTransformer() throws Exception { - final Artifact transformedArtifact = new SubArtifact(artifact, null, "raj"); - FileTransformer transformer = new FileTransformer() { - @Override - public InputStream transformData(File file) { - return new ByteArrayInputStream("transformed data".getBytes(StandardCharsets.UTF_8)); - } - - @Override - public Artifact transformArtifact(Artifact artifact) { - return transformedArtifact; - } - }; - - StubFileTransformerManager fileTransformerManager = new StubFileTransformerManager(); - fileTransformerManager.addFileTransformer("jar", transformer); - session.setFileTransformerManager(fileTransformerManager); - - request = new DeployRequest(); - request.addArtifact(artifact); - deployer.deploy(session, request); - - Artifact putArtifact = connector.getActualArtifactPutRequests().get(0); - assertEquals(transformedArtifact, putArtifact); - } } diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultInstallerTest.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultInstallerTest.java index 9313c6925..f923388b1 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultInstallerTest.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultInstallerTest.java @@ -18,13 +18,8 @@ */ package org.eclipse.aether.internal.impl; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileReader; import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; import java.util.List; import org.eclipse.aether.DefaultRepositorySystemSession; @@ -42,8 +37,6 @@ import org.eclipse.aether.metadata.DefaultMetadata; import org.eclipse.aether.metadata.Metadata; import org.eclipse.aether.metadata.Metadata.Nature; -import org.eclipse.aether.transform.FileTransformer; -import org.eclipse.aether.util.artifact.SubArtifact; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -376,39 +369,4 @@ public void testSetArtifactTimestamps() throws InstallationException { artifact.getFile().lastModified(), localArtifactFile.lastModified()); } - - @Test - public void testFileTransformer() throws Exception { - final Artifact transformedArtifact = new SubArtifact(artifact, null, "raj"); - FileTransformer transformer = new FileTransformer() { - @Override - public InputStream transformData(File file) { - return new ByteArrayInputStream("transformed data".getBytes(StandardCharsets.UTF_8)); - } - - @Override - public Artifact transformArtifact(Artifact artifact) { - return transformedArtifact; - } - }; - - StubFileTransformerManager fileTransformerManager = new StubFileTransformerManager(); - fileTransformerManager.addFileTransformer("jar", transformer); - session.setFileTransformerManager(fileTransformerManager); - - request = new InstallRequest(); - request.addArtifact(artifact); - installer.install(session, request); - - assertFalse(localArtifactFile.exists()); - - String transformedArtifactPath = - session.getLocalRepositoryManager().getPathForLocalArtifact(transformedArtifact); - File transformedArtifactFile = new File(session.getLocalRepository().getBasedir(), transformedArtifactPath); - assertTrue(transformedArtifactFile.exists()); - - try (BufferedReader r = new BufferedReader(new FileReader(transformedArtifactFile))) { - assertEquals("transformed data", r.readLine()); - } - } } diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java deleted file mode 100644 index 808f60537..000000000 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ -package org.eclipse.aether.internal.impl; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.transform.FileTransformer; -import org.eclipse.aether.transform.FileTransformerManager; - -public class StubFileTransformerManager implements FileTransformerManager { - private Map> fileTransformers = new HashMap<>(); - - @Override - public Collection getTransformersForArtifact(Artifact artifact) { - return fileTransformers.get(artifact.getExtension()); - } - - public void addFileTransformer(String extension, FileTransformer fileTransformer) { - if (!fileTransformers.containsKey(extension)) { - fileTransformers.put(extension, new HashSet<>()); - } - fileTransformers.get(extension).add(fileTransformer); - } -} diff --git a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactUpload.java b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactUpload.java index 8c1fa7950..81530621a 100644 --- a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactUpload.java +++ b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactUpload.java @@ -24,15 +24,12 @@ import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.transfer.ArtifactTransferException; import org.eclipse.aether.transfer.TransferListener; -import org.eclipse.aether.transform.FileTransformer; /** * An upload of an artifact to a remote repository. A repository connector processing this upload has to use * {@link #setException(ArtifactTransferException)} to report the results of the transfer. */ public final class ArtifactUpload extends ArtifactTransfer { - private FileTransformer fileTransformer; - /** * Creates a new uninitialized upload. */ @@ -51,23 +48,6 @@ public ArtifactUpload(Artifact artifact, File file) { setFile(file); } - /** - *

Creates a new upload with the specified properties.

- * - *

IMPORTANT When using a fileTransformer, the - * content of the file is stored in memory to ensure that file content and checksums stay in sync! - *

- * - * @param artifact The artifact to upload, may be {@code null}. - * @param file The local file to upload the artifact from, may be {@code null}. - * @param fileTransformer The file transformer, may be {@code null}. - */ - public ArtifactUpload(Artifact artifact, File file, FileTransformer fileTransformer) { - setArtifact(artifact); - setFile(file); - setFileTransformer(fileTransformer); - } - @Override public ArtifactUpload setArtifact(Artifact artifact) { super.setArtifact(artifact); @@ -98,21 +78,8 @@ public ArtifactUpload setTrace(RequestTrace trace) { return this; } - public ArtifactUpload setFileTransformer(FileTransformer fileTransformer) { - this.fileTransformer = fileTransformer; - return this; - } - - public FileTransformer getFileTransformer() { - return fileTransformer; - } - @Override public String toString() { - if (getFileTransformer() != null) { - return getArtifact() + " >>> " + getFileTransformer().transformArtifact(getArtifact()) + " - " + getFile(); - } else { - return getArtifact() + " - " + getFile(); - } + return getArtifact() + " - " + getFile(); } } diff --git a/pom.xml b/pom.xml index ea95b910e..dc18e3ce4 100644 --- a/pom.xml +++ b/pom.xml @@ -244,14 +244,14 @@ com.github.siom79.japicmp japicmp-maven-plugin - 0.17.2 + 0.18.1 ${project.groupId} ${project.artifactId} - 1.8.0 + 1.9.16 ${project.packaging} @@ -285,7 +285,19 @@ org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider org.eclipse.aether.spi.connector.transport.TransporterProvider + + org.eclipse.aether.RepositorySystemSession#getFileTransformerManager() + org.eclipse.aether.DefaultRepositorySystemSession#getFileTransformerManager() + org.eclipse.aether.DefaultRepositorySystemSession#setFileTransformerManager(org.eclipse.aether.transform.FileTransformerManager) + org.eclipse.aether.AbstractForwardingRepositorySystemSession#getFileTransformerManager() + org.eclipse.aether.transform.TransformException + org.eclipse.aether.transform.FileTransformer + org.eclipse.aether.transform.FileTransformerManager + org.eclipse.aether.spi.connector.ArtifactUpload#getFileTransformer() + org.eclipse.aether.spi.connector.ArtifactUpload#setFileTransformer(org.eclipse.aether.transform.FileTransformer) + org.eclipse.aether.spi.connector.ArtifactUpload#ArtifactUpload(org.eclipse.aether.artifact.Artifact,java.io.File,org.eclipse.aether.transform.FileTransformer) + true false true @@ -299,6 +311,20 @@ verify + + + org.eclipse.aether.RepositorySystemSession#getFileTransformerManager() + org.eclipse.aether.DefaultRepositorySystemSession#getFileTransformerManager() + org.eclipse.aether.DefaultRepositorySystemSession#setFileTransformerManager(org.eclipse.aether.transform.FileTransformerManager) + org.eclipse.aether.AbstractForwardingRepositorySystemSession#getFileTransformerManager() + org.eclipse.aether.transform.TransformException + org.eclipse.aether.transform.FileTransformer + org.eclipse.aether.transform.FileTransformerManager + org.eclipse.aether.spi.connector.ArtifactUpload#getFileTransformer() + org.eclipse.aether.spi.connector.ArtifactUpload#setFileTransformer(org.eclipse.aether.transform.FileTransformer) + org.eclipse.aether.spi.connector.ArtifactUpload#ArtifactUpload(org.eclipse.aether.artifact.Artifact,java.io.File,org.eclipse.aether.transform.FileTransformer) + + true true false