diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/TransferListenerAdapter.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/TransferListenerAdapter.java deleted file mode 100644 index 179175b112..0000000000 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/TransferListenerAdapter.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.apache.maven.artifact.resolver; - -/* - * 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 org.apache.maven.repository.ArtifactTransferEvent; -import org.apache.maven.repository.ArtifactTransferListener; -import org.apache.maven.repository.MavenArtifact; -import org.apache.maven.wagon.events.TransferEvent; -import org.apache.maven.wagon.events.TransferListener; -import org.apache.maven.wagon.resource.Resource; - -public class TransferListenerAdapter - implements TransferListener -{ - - private ArtifactTransferListener listener; - - public static TransferListener newAdapter( ArtifactTransferListener listener ) - { - if ( listener == null ) - { - return null; - } - else - { - return new TransferListenerAdapter( listener ); - } - } - - private TransferListenerAdapter( ArtifactTransferListener listener ) - { - this.listener = listener; - } - - public void debug( String message ) - { - } - - public void transferCompleted( TransferEvent transferEvent ) - { - listener.transferCompleted( wrap( transferEvent ) ); - } - - public void transferError( TransferEvent transferEvent ) - { - } - - public void transferInitiated( TransferEvent transferEvent ) - { - listener.transferInitiated( wrap( transferEvent ) ); - } - - public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length ) - { - listener.transferProgress( wrap( transferEvent ), buffer, length ); - } - - public void transferStarted( TransferEvent transferEvent ) - { - } - - private ArtifactTransferEvent wrap( TransferEvent event ) - { - if ( event == null ) - { - return null; - } - else - { - String wagon = event.getWagon().getRepository().getUrl(); - - MavenArtifact artifact = wrap( event.getResource() ); - - if ( event.getException() != null ) - { - return new ArtifactTransferEvent( wagon, event.getException(), event.getRequestType(), artifact ); - } - else - { - return new ArtifactTransferEvent( wagon, event.getEventType(), event.getRequestType(), artifact ); - } - } - } - - private MavenArtifact wrap( Resource resource ) - { - if ( resource == null ) - { - return null; - } - else - { - return new MavenArtifact( resource.getName(), resource.getContentLength() ); - } - } - -} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java index 8aa8489387..8cc860ed44 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java @@ -588,7 +588,9 @@ public class LegacyRepositorySystem { try { - wagonManager.getRemoteFile( repository, destination, remotePath, new TransferListenerAdapter( transferListener ), ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, true ); + wagonManager.getRemoteFile( repository, destination, remotePath, + TransferListenerAdapter.newAdapter( transferListener ), + ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, true ); } catch ( org.apache.maven.wagon.TransferFailedException e ) { @@ -605,7 +607,8 @@ public class LegacyRepositorySystem { try { - wagonManager.putRemoteFile( repository, source, remotePath, new TransferListenerAdapter( transferListener ) ); + wagonManager.putRemoteFile( repository, source, remotePath, + TransferListenerAdapter.newAdapter( transferListener ) ); } catch ( org.apache.maven.wagon.TransferFailedException e ) { diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java index 053d94206b..f3716028c0 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/TransferListenerAdapter.java @@ -1,40 +1,114 @@ package org.apache.maven.repository.legacy; +/* + * 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 org.apache.maven.repository.ArtifactTransferEvent; import org.apache.maven.repository.ArtifactTransferListener; +import org.apache.maven.repository.MavenArtifact; import org.apache.maven.wagon.events.TransferEvent; import org.apache.maven.wagon.events.TransferListener; +import org.apache.maven.wagon.resource.Resource; public class TransferListenerAdapter implements TransferListener { - private ArtifactTransferListener transferListener; - public TransferListenerAdapter( ArtifactTransferListener transferListener ) + private ArtifactTransferListener listener; + + public static TransferListener newAdapter( ArtifactTransferListener listener ) { - this.transferListener = transferListener; + if ( listener == null ) + { + return null; + } + else + { + return new TransferListenerAdapter( listener ); + } } - public void debug( String arg0 ) + private TransferListenerAdapter( ArtifactTransferListener listener ) + { + this.listener = listener; + } + + public void debug( String message ) { } - public void transferCompleted( TransferEvent arg0 ) + public void transferCompleted( TransferEvent transferEvent ) + { + listener.transferCompleted( wrap( transferEvent ) ); + } + + public void transferError( TransferEvent transferEvent ) { } - public void transferError( TransferEvent arg0 ) + public void transferInitiated( TransferEvent transferEvent ) + { + listener.transferInitiated( wrap( transferEvent ) ); + } + + public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length ) + { + listener.transferProgress( wrap( transferEvent ), buffer, length ); + } + + public void transferStarted( TransferEvent transferEvent ) { } - public void transferInitiated( TransferEvent arg0 ) + private ArtifactTransferEvent wrap( TransferEvent event ) { + if ( event == null ) + { + return null; + } + else + { + String wagon = event.getWagon().getRepository().getUrl(); + + MavenArtifact artifact = wrap( event.getResource() ); + + if ( event.getException() != null ) + { + return new ArtifactTransferEvent( wagon, event.getException(), event.getRequestType(), artifact ); + } + else + { + return new ArtifactTransferEvent( wagon, event.getEventType(), event.getRequestType(), artifact ); + } + } } - public void transferProgress( TransferEvent arg0, byte[] arg1, int arg2 ) + private MavenArtifact wrap( Resource resource ) { + if ( resource == null ) + { + return null; + } + else + { + return new MavenArtifact( resource.getName(), resource.getContentLength() ); + } } - public void transferStarted( TransferEvent arg0 ) - { - } } diff --git a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java index 2faa41cb87..64641b1a0f 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultProjectDependenciesResolver.java @@ -34,12 +34,12 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; import org.apache.maven.artifact.resolver.ResolutionErrorHandler; -import org.apache.maven.artifact.resolver.TransferListenerAdapter; import org.apache.maven.artifact.resolver.filter.CumulativeScopeArtifactFilter; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifact; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.repository.legacy.TransferListenerAdapter; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 75c58ef0f9..bc7d6a6f23 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -26,7 +26,6 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ResolutionErrorHandler; -import org.apache.maven.artifact.resolver.TransferListenerAdapter; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.model.Profile; @@ -43,6 +42,7 @@ import org.apache.maven.model.building.UrlModelSource; import org.apache.maven.model.resolution.ModelResolver; import org.apache.maven.project.artifact.ProjectArtifact; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.repository.legacy.TransferListenerAdapter; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.Os; diff --git a/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java index 23ee91ecb0..795973af94 100644 --- a/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java +++ b/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ResolutionErrorHandler; -import org.apache.maven.artifact.resolver.TransferListenerAdapter; import org.apache.maven.model.Repository; import org.apache.maven.model.building.FileModelSource; import org.apache.maven.model.building.ModelSource; @@ -38,6 +37,7 @@ import org.apache.maven.model.resolution.InvalidRepositoryException; import org.apache.maven.model.resolution.ModelResolver; import org.apache.maven.model.resolution.UnresolvableModelException; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.repository.legacy.TransferListenerAdapter; /** * Implements a model resolver backed by the Maven Repository API and the reactor.