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 040 @Override 041 protected void doExecute() throws MojoExecutionException, IOException { 042 LOG.atFine().log("Running property-helper:get"); 043 044 createFieldDefinitions(); 045 createFields(); 046 createGroups(); 047 048 if (persist) { 049 LOG.atFine().log("Persisting value cache"); 050 // Now dump the value cache back to the files if necessary. 051 valueCache.persist(); 052 } 053 } 054}