diff --git a/src/it/projects/mdep-839-list/invoker.properties b/src/it/projects/mdep-839-list/invoker.properties new file mode 100644 index 000000000..55afe77c1 --- /dev/null +++ b/src/it/projects/mdep-839-list/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}:list diff --git a/src/it/projects/mdep-839-list/pom.xml b/src/it/projects/mdep-839-list/pom.xml new file mode 100644 index 000000000..f6cd86069 --- /dev/null +++ b/src/it/projects/mdep-839-list/pom.xml @@ -0,0 +1,54 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:list-repositories + + + + UTF-8 + + + + + fake-remote-repository + http://localhost:2345 + + + + + + org.apache.maven + maven-core + 3.9.9 + + + + \ No newline at end of file diff --git a/src/it/projects/mdep-839-list/test.properties b/src/it/projects/mdep-839-list/test.properties new file mode 100644 index 000000000..406dd9aba --- /dev/null +++ b/src/it/projects/mdep-839-list/test.properties @@ -0,0 +1,19 @@ +# 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. + +outputFile = classpath.txt + diff --git a/src/it/projects/mdep-839-list/verify.groovy b/src/it/projects/mdep-839-list/verify.groovy new file mode 100644 index 000000000..50cd4ea0f --- /dev/null +++ b/src/it/projects/mdep-839-list/verify.groovy @@ -0,0 +1,28 @@ +/* + * 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, "classpath.txt" ) +assert file.exists() : "output file $file does not exist" + +String output = file.getText( "UTF-8" ) +assert output.startsWith( 'The following files have been resolved:') +// no escape codes +assert !output.contains( '\u001B' ) + + diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index 6f49a4767..c939ec4d8 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -142,7 +142,9 @@ protected ArtifactsFilter getMarkedArtifactFilter() { */ public String getOutput(boolean outputAbsoluteArtifactFilename, boolean theOutputScope, boolean theSort) { StringBuilder sb = new StringBuilder(); - sb.append(System.lineSeparator()); + if (outputFile == null) { + sb.append(System.lineSeparator()); + } sb.append("The following files have been resolved:"); sb.append(System.lineSeparator()); if (results.getResolvedDependencies() == null @@ -182,9 +184,13 @@ private StringBuilder buildArtifactListOutput( Set artifacts, boolean outputAbsoluteArtifactFilename, boolean theOutputScope, boolean theSort) { StringBuilder sb = new StringBuilder(); List artifactStringList = new ArrayList<>(); + /* if (outputFile != null) { + MessageUtils.setColorEnabled(false); + } else { + MessageUtils.setColorEnabled(true); + } */ for (Artifact artifact : artifacts) { MessageBuilder messageBuilder = MessageUtils.buffer(); - messageBuilder.a(" "); if (theOutputScope) { @@ -224,7 +230,7 @@ private StringBuilder buildArtifactListOutput( } } } - artifactStringList.add(messageBuilder + System.lineSeparator()); + artifactStringList.add(messageBuilder.build() + System.lineSeparator()); } if (theSort) { Collections.sort(artifactStringList);