From 441534f0e8151978ac461775e289b8b362b20ee3 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Sat, 10 Dec 2022 10:40:10 +0100 Subject: [PATCH] Drop FileTransformer API --- ...ractForwardingRepositorySystemSession.java | 7 -- .../DefaultRepositorySystemSession.java | 36 ---------- .../aether/RepositorySystemSession.java | 11 --- .../aether/transform/FileTransformer.java | 57 --------------- .../transform/FileTransformerManager.java | 52 -------------- .../aether/transform/TransformException.java | 72 ------------------- .../basic/BasicRepositoryConnector.java | 52 +------------- .../aether/internal/impl/DefaultDeployer.java | 30 ++------ .../internal/impl/DefaultInstaller.java | 56 +++------------ .../internal/impl/DefaultDeployerTest.java | 36 ---------- .../internal/impl/DefaultInstallerTest.java | 46 ------------ .../impl/StubFileTransformerManager.java | 50 ------------- .../aether/spi/connector/ArtifactUpload.java | 42 +---------- 13 files changed, 16 insertions(+), 531 deletions(-) delete mode 100644 maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformer.java delete mode 100644 maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformerManager.java delete mode 100644 maven-resolver-api/src/main/java/org/eclipse/aether/transform/TransformException.java delete mode 100644 maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java 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 b1ace216a..45de4ac0b 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 @@ -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; /** * A special repository system session to enable decorating or proxying another session. To do so, clients have to @@ -211,10 +210,4 @@ 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 4c0163e81..ed866a7bf 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 @@ -19,12 +19,10 @@ * under the License. */ -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; @@ -45,8 +43,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; @@ -78,8 +74,6 @@ public final class DefaultRepositorySystemSession private LocalRepositoryManager localRepositoryManager; - private FileTransformerManager fileTransformerManager; - private WorkspaceReader workspaceReader; private RepositoryListener repositoryListener; @@ -137,7 +131,6 @@ public DefaultRepositorySystemSession() proxySelector = NullProxySelector.INSTANCE; authenticationSelector = NullAuthenticationSelector.INSTANCE; artifactTypeRegistry = NullArtifactTypeRegistry.INSTANCE; - fileTransformerManager = NullFileTransformerManager.INSTANCE; data = new DefaultSessionData(); } @@ -175,7 +168,6 @@ public DefaultRepositorySystemSession( RepositorySystemSession session ) setDependencySelector( session.getDependencySelector() ); setVersionFilter( session.getVersionFilter() ); setDependencyGraphTransformer( session.getDependencyGraphTransformer() ); - setFileTransformerManager( session.getFileTransformerManager() ); setData( session.getData() ); setCache( session.getCache() ); } @@ -336,23 +328,6 @@ public DefaultRepositorySystemSession setLocalRepositoryManager( LocalRepository 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() { @@ -889,15 +864,4 @@ public ArtifactType get( String typeId ) } } - - 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 df6b2fbfa..0f89cff51 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 @@ -37,7 +37,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 @@ -260,14 +259,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 45c0b5b14..000000000 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformer.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.eclipse.aether.transform; - -/* - * 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.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 1a472e597..000000000 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/FileTransformerManager.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.eclipse.aether.transform; - -/* - * 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.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 748b39d2c..000000000 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/transform/TransformException.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.eclipse.aether.transform; - -/* - * 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. - */ - -/** - * 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 6dd3e6804..9a696bc42 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 @@ -21,10 +21,8 @@ import static java.util.Objects.requireNonNull; -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; @@ -67,7 +65,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.RunnableErrorForwarder; @@ -300,8 +297,7 @@ public void put( Collection artifactUploads, 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 ); task.run(); } @@ -504,64 +500,22 @@ class PutTaskRunner private final File file; - private final FileTransformer fileTransformer; - private final Collection checksumLocations; PutTaskRunner( URI path, 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 f582f50dd..625b762f9 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 @@ -74,8 +74,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; /** */ @@ -243,8 +241,6 @@ private DeployResult deploy( SyncContext syncContext, RepositorySystemSession se { List generators = getMetadataGenerators( session, request ); - FileTransformerManager fileTransformerManager = session.getFileTransformerManager(); - List artifactUploads = new ArrayList<>(); List metadataUploads = new ArrayList<>(); IdentityHashMap processedMetadata = new IdentityHashMap<>(); @@ -274,28 +270,10 @@ private DeployResult deploy( SyncContext syncContext, RepositorySystemSession se 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 6b3f7a7d1..ac10cd305 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 @@ -22,7 +22,6 @@ import static java.util.Objects.requireNonNull; import java.io.File; -import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.IdentityHashMap; @@ -56,7 +55,6 @@ import org.eclipse.aether.spi.io.FileProcessor; import org.eclipse.aether.spi.locator.Service; import org.eclipse.aether.spi.locator.ServiceLocator; -import org.eclipse.aether.transform.FileTransformer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -235,42 +233,12 @@ private List getMetadataGenerators( RepositorySyste 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(); - File srcFile = artifact.getFile(); + File dstFile = new File( lrm.getRepository().getBasedir(), lrm.getPathForLocalArtifact( artifact ) ); - 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 @@ -281,38 +249,30 @@ private void install( RepositorySystemSession session, RequestTrace trace, Artif } boolean copy = - "pom".equals( targetArtifact.getExtension() ) || srcFile.lastModified() != dstFile.lastModified() + "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(), + 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 6664d28bb..7b66f716a 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 @@ -25,11 +25,8 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; -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; @@ -58,8 +55,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; @@ -392,35 +387,4 @@ public void close() 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 0fb0e567d..a1f09388c 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 @@ -26,13 +26,8 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -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; @@ -50,8 +45,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; @@ -420,43 +413,4 @@ public void testSetArtifactTimestamps() assertEquals( "artifact timestamp was not set to src file", 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 a079a2ae1..000000000 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/StubFileTransformerManager.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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.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 90323b17d..eacd5f9b1 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 @@ -25,7 +25,6 @@ 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 @@ -34,8 +33,6 @@ public final class ArtifactUpload extends ArtifactTransfer { - private FileTransformer fileTransformer; - /** * Creates a new uninitialized upload. */ @@ -56,24 +53,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 ) { @@ -108,30 +87,11 @@ public ArtifactUpload setTrace( RequestTrace trace ) super.setTrace( 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(); } }