1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.api.cli.mvn; 20 21 import java.util.Collection; 22 import java.util.List; 23 import java.util.Map; 24 import java.util.Optional; 25 26 import org.apache.maven.api.annotations.Experimental; 27 import org.apache.maven.api.annotations.Nonnull; 28 import org.apache.maven.api.cli.Options; 29 30 /** 31 * Defines the options specific to Maven operations. 32 * This interface extends the general {@link Options} interface, adding Maven-specific configuration options. 33 * 34 * <p>These options represent the various flags and settings available through the Maven CLI, 35 * as well as those that can be specified in the {@code maven.config} file. They provide fine-grained 36 * control over Maven's behavior during the build process.</p> 37 * 38 * @since 4.0.0 39 */ 40 @Experimental 41 public interface MavenOptions extends Options { 42 43 /** 44 * Returns the path to an alternate POM file. 45 * 46 * @return an {@link Optional} containing the path to the alternate POM file, or empty if not specified 47 */ 48 @Nonnull 49 Optional<String> alternatePomFile(); 50 51 /** 52 * Indicates whether Maven should operate in offline mode. 53 * 54 * @return an {@link Optional} containing true if offline mode is enabled, false if disabled, or empty if not specified 55 */ 56 @Nonnull 57 Optional<Boolean> offline(); 58 59 /** 60 * Indicates whether Maven should operate in non-recursive mode (i.e., not build child modules). 61 * 62 * @return an {@link Optional} containing true if non-recursive mode is enabled, false if disabled, or empty if not specified 63 */ 64 @Nonnull 65 Optional<Boolean> nonRecursive(); 66 67 /** 68 * Indicates whether Maven should force a check for updated snapshots on remote repositories. 69 * 70 * @return an {@link Optional} containing true if snapshot updates should be forced, false if not, or empty if not specified 71 */ 72 @Nonnull 73 Optional<Boolean> updateSnapshots(); 74 75 /** 76 * Returns the list of profiles to activate. 77 * 78 * @return an {@link Optional} containing the list of profile names to activate, or empty if not specified 79 */ 80 @Nonnull 81 Optional<List<String>> activatedProfiles(); 82 83 /** 84 * Indicates whether Maven should suppress SNAPSHOT updates. 85 * 86 * @return an {@link Optional} containing true if SNAPSHOT updates should be suppressed, false if not, or empty if not specified 87 */ 88 @Nonnull 89 Optional<Boolean> suppressSnapshotUpdates(); 90 91 /** 92 * Indicates whether Maven should use strict checksum verification. 93 * 94 * @return an {@link Optional} containing true if strict checksum verification is enabled, false if not, or empty if not specified 95 */ 96 @Nonnull 97 Optional<Boolean> strictChecksums(); 98 99 /** 100 * Indicates whether Maven should use relaxed checksum verification. 101 * 102 * @return an {@link Optional} containing true if relaxed checksum verification is enabled, false if not, or empty if not specified 103 */ 104 @Nonnull 105 Optional<Boolean> relaxedChecksums(); 106 107 /** 108 * Indicates whether Maven should stop at the first failure in a multi-module build. 109 * 110 * @return an {@link Optional} containing true if Maven should stop at the first failure, false if not, or empty if not specified 111 */ 112 @Nonnull 113 Optional<Boolean> failFast(); 114 115 /** 116 * Indicates whether Maven should run all builds but defer error reporting to the end. 117 * 118 * @return an {@link Optional} containing true if error reporting should be deferred to the end, false if not, or empty if not specified 119 */ 120 @Nonnull 121 Optional<Boolean> failAtEnd(); 122 123 /** 124 * Indicates whether Maven should never fail the build, regardless of project result. 125 * 126 * @return an {@link Optional} containing true if the build should never fail, false if it should fail normally, or empty if not specified 127 */ 128 @Nonnull 129 Optional<Boolean> failNever(); 130 131 /** 132 * Indicates whether Maven should resume from the last failed project in a previous build. 133 * 134 * @return an {@link Optional} containing true if Maven should resume from the last failure, false if not, or empty if not specified 135 */ 136 @Nonnull 137 Optional<Boolean> resume(); 138 139 /** 140 * Returns the project to resume the build from. 141 * 142 * @return an {@link Optional} containing the project name to resume from, or empty if not specified 143 */ 144 @Nonnull 145 Optional<String> resumeFrom(); 146 147 /** 148 * Returns the list of specified reactor projects to build instead of all projects. 149 * 150 * @return an {@link Optional} containing the list of project names to build, or empty if not specified 151 */ 152 @Nonnull 153 Optional<List<String>> projects(); 154 155 /** 156 * Indicates whether Maven should also build the specified projects' dependencies. 157 * 158 * @return an {@link Optional} containing true if dependencies should also be built, false if not, or empty if not specified 159 */ 160 @Nonnull 161 Optional<Boolean> alsoMake(); 162 163 /** 164 * Indicates whether Maven should also build the specified projects' dependents. 165 * 166 * @return an {@link Optional} containing true if dependents should also be built, false if not, or empty if not specified 167 */ 168 @Nonnull 169 Optional<Boolean> alsoMakeDependents(); 170 171 /** 172 * Returns the number of threads used for parallel builds. 173 * 174 * @return an {@link Optional} containing the number of threads (or "1C" for one thread per CPU core), or empty if not specified 175 */ 176 @Nonnull 177 Optional<String> threads(); 178 179 /** 180 * Returns the id of the build strategy to use. 181 * 182 * @return an {@link Optional} containing the id of the build strategy, or empty if not specified 183 */ 184 @Nonnull 185 Optional<String> builder(); 186 187 /** 188 * Indicates whether Maven should not display transfer progress when downloading or uploading. 189 * 190 * @return an {@link Optional} containing true if transfer progress should not be displayed, false if it should, or empty if not specified 191 */ 192 @Nonnull 193 Optional<Boolean> noTransferProgress(); 194 195 /** 196 * Indicates whether Maven should cache the "not found" status of artifacts that were not found in remote repositories. 197 * 198 * @return an {@link Optional} containing true if "not found" status should be cached, false if not, or empty if not specified 199 */ 200 @Nonnull 201 Optional<Boolean> cacheArtifactNotFound(); 202 203 /** 204 * Indicates whether Maven should use strict artifact descriptor policy. 205 * 206 * @return an {@link Optional} containing true if strict artifact descriptor policy should be used, false if not, or empty if not specified 207 */ 208 @Nonnull 209 Optional<Boolean> strictArtifactDescriptorPolicy(); 210 211 /** 212 * Indicates whether Maven should ignore transitive repositories. 213 * 214 * @return an {@link Optional} containing true if transitive repositories should be ignored, false if not, or empty if not specified 215 */ 216 @Nonnull 217 Optional<Boolean> ignoreTransitiveRepositories(); 218 219 /** 220 * Returns the list of goals and phases to execute. 221 * 222 * @return an {@link Optional} containing the list of goals and phases to execute, or empty if not specified 223 */ 224 @Nonnull 225 Optional<List<String>> goals(); 226 227 /** 228 * Returns a new instance of {@link MavenOptions} with values interpolated using the given properties. 229 * 230 * @param properties a collection of property maps to use for interpolation 231 * @return a new MavenOptions instance with interpolated values 232 */ 233 @Nonnull 234 MavenOptions interpolate(@Nonnull Collection<Map<String, String>> properties); 235 }