![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.maven.cling.invoker.mvn.LayeredMavenOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-cli Show documentation
Show all versions of maven-cli Show documentation
Maven CLI component, with CLI and logging support.
The newest version!
/*
* 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 org.apache.maven.cling.invoker.mvn;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.apache.maven.api.cli.mvn.MavenOptions;
import org.apache.maven.cling.invoker.LayeredOptions;
/**
* Options that are "layered" by precedence order.
*
* @param the specific type of Maven Options that are layered
*/
public class LayeredMavenOptions extends LayeredOptions implements MavenOptions {
public static MavenOptions layerMavenOptions(Collection options) {
List o = options.stream().filter(Objects::nonNull).toList();
if (o.isEmpty()) {
throw new IllegalArgumentException("No options specified (or all were null)");
} else if (o.size() == 1) {
return o.get(0);
} else {
return new LayeredMavenOptions<>(o);
}
}
protected LayeredMavenOptions(List options) {
super(options);
}
@Override
public Optional alternatePomFile() {
return returnFirstPresentOrEmpty(MavenOptions::alternatePomFile);
}
@Override
public Optional offline() {
return returnFirstPresentOrEmpty(MavenOptions::offline);
}
@Override
public Optional nonRecursive() {
return returnFirstPresentOrEmpty(MavenOptions::nonRecursive);
}
@Override
public Optional updateSnapshots() {
return returnFirstPresentOrEmpty(MavenOptions::updateSnapshots);
}
@Override
public Optional> activatedProfiles() {
return collectListIfPresentOrEmpty(MavenOptions::activatedProfiles);
}
@Override
public Optional suppressSnapshotUpdates() {
return returnFirstPresentOrEmpty(MavenOptions::suppressSnapshotUpdates);
}
@Override
public Optional strictChecksums() {
return returnFirstPresentOrEmpty(MavenOptions::strictChecksums);
}
@Override
public Optional relaxedChecksums() {
return returnFirstPresentOrEmpty(MavenOptions::relaxedChecksums);
}
@Override
public Optional failFast() {
return returnFirstPresentOrEmpty(MavenOptions::failFast);
}
@Override
public Optional failAtEnd() {
return returnFirstPresentOrEmpty(MavenOptions::failAtEnd);
}
@Override
public Optional failNever() {
return returnFirstPresentOrEmpty(MavenOptions::failNever);
}
@Override
public Optional resume() {
return returnFirstPresentOrEmpty(MavenOptions::resume);
}
@Override
public Optional resumeFrom() {
return returnFirstPresentOrEmpty(MavenOptions::resumeFrom);
}
@Override
public Optional> projects() {
return collectListIfPresentOrEmpty(MavenOptions::projects);
}
@Override
public Optional alsoMake() {
return returnFirstPresentOrEmpty(MavenOptions::alsoMake);
}
@Override
public Optional alsoMakeDependents() {
return returnFirstPresentOrEmpty(MavenOptions::alsoMakeDependents);
}
@Override
public Optional threads() {
return returnFirstPresentOrEmpty(MavenOptions::threads);
}
@Override
public Optional builder() {
return returnFirstPresentOrEmpty(MavenOptions::builder);
}
@Override
public Optional noTransferProgress() {
return returnFirstPresentOrEmpty(MavenOptions::noTransferProgress);
}
@Override
public Optional cacheArtifactNotFound() {
return returnFirstPresentOrEmpty(MavenOptions::cacheArtifactNotFound);
}
@Override
public Optional strictArtifactDescriptorPolicy() {
return returnFirstPresentOrEmpty(MavenOptions::strictArtifactDescriptorPolicy);
}
@Override
public Optional ignoreTransitiveRepositories() {
return returnFirstPresentOrEmpty(MavenOptions::ignoreTransitiveRepositories);
}
@Override
public Optional> goals() {
return collectListIfPresentOrEmpty(MavenOptions::goals);
}
@Override
public MavenOptions interpolate(Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy