001/* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014 015package org.basepom.mojo.propertyhelper; 016 017import java.io.IOException; 018 019import com.google.common.flogger.FluentLogger; 020import org.apache.maven.plugin.MojoExecutionException; 021import org.apache.maven.plugins.annotations.Mojo; 022import org.apache.maven.plugins.annotations.Parameter; 023 024/** 025 * Fetches the defined numbers and add properties. 026 */ 027@Mojo(name = "get", threadSafe = true) 028public final class GetMojo extends AbstractPropertyHelperMojo { 029 030 private static final FluentLogger LOG = FluentLogger.forEnclosingClass(); 031 032 /** 033 * If set to true, all fields that have a {@code <propertyFile>} configuration 034 * attribute are persisted to disk. 035 */ 036 @Parameter(defaultValue = "false") 037 boolean persist = false; 038 039 @Override 040 protected void doExecute() throws MojoExecutionException, IOException { 041 LOG.atFine().log("Running property-helper:get"); 042 043 createFieldDefinitions(); 044 createFields(); 045 createGroups(); 046 047 if (persist) { 048 LOG.atFine().log("Persisting value cache"); 049 // Now dump the value cache back to the files if necessary. 050 valueCache.persist(); 051 } 052 } 053}