From 4a2907955307722fcea8de193ee9855be38e553c Mon Sep 17 00:00:00 2001 From: Jonas van Vliet Date: Mon, 10 May 2021 12:29:48 +0200 Subject: [PATCH] MDEP-739 Dependency Plugin go-offline doesn't respect artifact classifier --- .../invoker.properties | 18 +++++++++ .../pom.xml | 38 +++++++++++++++++++ .../verify.groovy | 26 +++++++++++++ .../dependency/resolvers/GoOfflineMojo.java | 2 + 4 files changed, 84 insertions(+) create mode 100644 src/it/projects/mdep-739-go-offline-respect-classifiers/invoker.properties create mode 100644 src/it/projects/mdep-739-go-offline-respect-classifiers/pom.xml create mode 100644 src/it/projects/mdep-739-go-offline-respect-classifiers/verify.groovy diff --git a/src/it/projects/mdep-739-go-offline-respect-classifiers/invoker.properties b/src/it/projects/mdep-739-go-offline-respect-classifiers/invoker.properties new file mode 100644 index 0000000000..e596121937 --- /dev/null +++ b/src/it/projects/mdep-739-go-offline-respect-classifiers/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:go-offline diff --git a/src/it/projects/mdep-739-go-offline-respect-classifiers/pom.xml b/src/it/projects/mdep-739-go-offline-respect-classifiers/pom.xml new file mode 100644 index 0000000000..5c27c42c89 --- /dev/null +++ b/src/it/projects/mdep-739-go-offline-respect-classifiers/pom.xml @@ -0,0 +1,38 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.dependency + mdep-739-go-offline-respect-classifiers + 1.0.0-SNAPSHOT + Test that dependency:go-offline respects classifiers on artifacts + + + org.springframework.cloud + spring-cloud-stream + test + test-jar + test-binder + 3.1.2 + + + diff --git a/src/it/projects/mdep-739-go-offline-respect-classifiers/verify.groovy b/src/it/projects/mdep-739-go-offline-respect-classifiers/verify.groovy new file mode 100644 index 0000000000..fcc7dc0047 --- /dev/null +++ b/src/it/projects/mdep-739-go-offline-respect-classifiers/verify.groovy @@ -0,0 +1,26 @@ +/* + * 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. + */ + +File file = new File( basedir, "build.log" ); +assert file.exists(); + +String buildLog = file.getText( "UTF-8" ); +assert buildLog.contains( 'Resolved dependency: spring-cloud-stream-3.1.2-test-binder.jar' ); + +return true; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index e0e8b1f924..4145b45a99 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -187,6 +187,7 @@ private DependableCoordinate createDependendableCoordinateFromArtifact( final Ar result.setArtifactId( artifact.getArtifactId() ); result.setVersion( artifact.getVersion() ); result.setType( artifact.getType() ); + result.setClassifier( artifact.getClassifier() ); return result; } @@ -198,6 +199,7 @@ private DependableCoordinate createDependendableCoordinateFromDependency( final result.setArtifactId( dependency.getArtifactId() ); result.setVersion( dependency.getVersion() ); result.setType( dependency.getType() ); + result.setClassifier( dependency.getClassifier() ); return result; }