diff --git a/src/it/projects/mdep-1650-scriptable-output-null-classifier/invoker.properties b/src/it/projects/mdep-1650-scriptable-output-null-classifier/invoker.properties new file mode 100644 index 000000000..4bbc5ed10 --- /dev/null +++ b/src/it/projects/mdep-1650-scriptable-output-null-classifier/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 = clean ${project.groupId}:${project.artifactId}:${project.version}:analyze diff --git a/src/it/projects/mdep-1650-scriptable-output-null-classifier/pom.xml b/src/it/projects/mdep-1650-scriptable-output-null-classifier/pom.xml new file mode 100644 index 000000000..7e2ec51cb --- /dev/null +++ b/src/it/projects/mdep-1650-scriptable-output-null-classifier/pom.xml @@ -0,0 +1,63 @@ + + + + + + 4.0.0 + + org.apache.maven.its.dependency + mdep-1650 + 1.0-SNAPSHOT + + Test + + Test dependency:analyze scriptableOutput does not append literal "null" for null classifier + + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + + + + + + maven-dependency-plugin + @project.version@ + + true + true + TESTFLAG + + + + + + diff --git a/src/it/projects/mdep-1650-scriptable-output-null-classifier/src/main/java/test/App.java b/src/it/projects/mdep-1650-scriptable-output-null-classifier/src/main/java/test/App.java new file mode 100644 index 000000000..a2b9cb744 --- /dev/null +++ b/src/it/projects/mdep-1650-scriptable-output-null-classifier/src/main/java/test/App.java @@ -0,0 +1,23 @@ +/* + * 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 test; +import org.apache.maven.model.Model; +public class App { + public Model model = null; +} diff --git a/src/it/projects/mdep-1650-scriptable-output-null-classifier/verify.groovy b/src/it/projects/mdep-1650-scriptable-output-null-classifier/verify.groovy new file mode 100644 index 000000000..a5caf03b3 --- /dev/null +++ b/src/it/projects/mdep-1650-scriptable-output-null-classifier/verify.groovy @@ -0,0 +1,36 @@ +/* + * 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 buildLog = new File( basedir, "build.log" ) +assert buildLog.exists() + +String log = buildLog.getText( "UTF-8" ) + +// verify scriptable output is present +assert log.contains( 'Missing dependencies:' ) +assert log.contains( 'TESTFLAG:' ) + +// verify no scriptable output line contains ":null:" (null classifier) +log.eachLine { line -> + if ( line.contains( 'TESTFLAG:' ) ) { + assert !line.contains( ':null:' ) + } +} + +return true diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 56324c0af..7bb13e64c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -547,7 +547,7 @@ private void writeScriptableOutput(Set artifacts) { .append(":") .append(artifact.getDependencyConflictId()) .append(":") - .append(artifact.getClassifier()) + .append(artifact.getClassifier() != null ? artifact.getClassifier() : "") .append(":") .append(artifact.getBaseVersion()) .append(":")