Package com.igormaznitsa.mvngolang
Class AbstractGolangMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.igormaznitsa.mvngolang.AbstractGolangMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractGoDependencyAwareMojo,AbstractGoPackageAwareMojo
public abstract class AbstractGolangMojo
extends org.apache.maven.plugin.AbstractMojo
-
Field Summary
Fields Modifier and Type Field Description protected Set<String>buildFlagsToIgnoreset of flags to be ignored among build and extra build flags, for inside usestatic StringENV_GO111MODULEstatic StringGO_MOD_FILE_NAMEstatic StringGO_SUM_FILE_NAMEstatic StringGOARTIFACT_PACKAGINGstatic StringNAME_PATTERNVERSION, OS, PLATFORM,-OSXVERSIONprotected org.apache.maven.settings.Settingssettingsprotected List<String>tempBuildFlags -
Constructor Summary
Constructors Constructor Description AbstractGolangMojo() -
Method Summary
Modifier and Type Method Description protected static StringadaptExecNameForOS(String execName)protected voidaddTmpBuildFlagIfNotPresented(String... flags)voidafterExecution(ProxySettings proxySettings, boolean error)voidbeforeExecution(ProxySettings proxySettings)protected booleandoesNeedOneMoreAttempt(org.zeroturnaround.exec.ProcessResult result, String consoleOut, String consoleErr)protected booleandoesNeedSessionLock()voiddoInit()protected booleandoMainBusiness(ProxySettings proxySettings, int maxAttempts)voidexecute()protected List<File>findAllGoModsInFolder(File folder)protected static FilefindExisting(File... files)File[]findGoPath(boolean ensureExist)protected FilefindGoRoot(ProxySettings proxySettings)FilefindGoRootBootstrap(boolean ensureExist)protected StringfindMvnProperty(String key, String dflt)StringgetArch()org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolvergetArtifactResolver()String[]getBuildFlags()abstract String[]getCommandFlags()intgetConnectionTimeout()Map<?,?>getEnv()StringgetErrLogFile()StringgetExec()StringgetExecSubpath()org.apache.maven.plugin.MojoExecutiongetExecution()protected String[]getExtraBuildFlags()StringgetGoBin()StringgetGoCache()abstract StringgetGoCommand()StringgetGoPath()StringgetGoRoot()StringgetGoRootBootstrap()StringgetGoVersion()String[]getOptionalExtraTailArguments()StringgetOs()StringgetOSXVersion()StringgetOutLogFile()org.apache.maven.project.MavenProjectgetProject()ProxySettingsgetProxy()List<org.apache.maven.artifact.repository.ArtifactRepository>getRemoteRepositories()StringgetReportsFolder()StringgetSdkArchiveName()StringgetSdkDownloadUrl()StringgetSdkSite()org.apache.maven.execution.MavenSessiongetSession()protected StringgetSkipMojoPropertySuffix()FilegetSources(boolean ensureExist)protected StringgetSpecialPartOfGoPath()Internal method which returns special part of GOPATH which can be formed by mojos.StringgetStoreFolder()booleangetSupposeSdkArchiveFileName()abstract String[]getTailArguments()StringgetTarget386()StringgetTargetArch()StringgetTargetArm()StringgetTargetOS()protected FilegetTempFileFolder()StringgetUseGoTool()StringgetWorkingDir()protected FilegetWorkingDirectoryForExecutor()protected voidinitConsoleBuffers()booleanisCheckSdkHash()booleanisCommandSupportVerbose()booleanisDisableSdkLoad()booleanisDisableSslCheck()booleanisEnforceGoPathToEnd()booleanisEnforcePrintOutput()booleanisFilterEnvPath()booleanisHideBanner()booleanisIgnoreErrorExitCode()booleanisKeepSdkArchive()booleanisKeepUnarchFolderIfError()booleanisModuleMode()booleanisMojoMustNotBeExecuted()booleanisSkip()booleanisSourceFolderRequired()booleanisUseEnvVars()booleanisUseMavenProxy()booleanisVerbose()protected voidlogOptionally(String message)StringmakeExecutableFileSubpath()protected StringmakePathFromExtraGoPathElements()protected org.zeroturnaround.exec.ProcessExecutorprepareExecutor(ProxySettings proxySettings)protected voidprintLogs(boolean forcePrint, boolean errorDetected, String outLog, String errLog)protected voidprocessConsoleOut(int exitCode, String out, String err)protected voidregisterEnvVars(org.zeroturnaround.exec.ProcessExecutor result, File theGoRoot, String theGoBin, String theGoCache, File sourcesFile, File[] goPathParts)protected voidregisterOutputBuffers(org.zeroturnaround.exec.ProcessExecutor executor)voidsetDisableSslCheck(boolean flag)voidsetModuleMode(boolean value)voidsetWorkingDir(String path)
-
Field Details
-
GOARTIFACT_PACKAGING
- See Also:
- Constant Field Values
-
GO_MOD_FILE_NAME
- See Also:
- Constant Field Values
-
GO_SUM_FILE_NAME
- See Also:
- Constant Field Values
-
ENV_GO111MODULE
- See Also:
- Constant Field Values
-
NAME_PATTERN
VERSION, OS, PLATFORM,-OSXVERSION- See Also:
- Constant Field Values
-
buildFlagsToIgnore
set of flags to be ignored among build and extra build flags, for inside use -
tempBuildFlags
-
settings
@Parameter(defaultValue="${settings}", readonly=true) protected org.apache.maven.settings.Settings settings
-
-
Constructor Details
-
AbstractGolangMojo
public AbstractGolangMojo()
-
-
Method Details
-
adaptExecNameForOS
-
findExisting
-
getWorkingDir
-
setWorkingDir
-
isModuleMode
public boolean isModuleMode() -
setModuleMode
public void setModuleMode(boolean value) -
getArtifactResolver
@Nonnull public org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver getArtifactResolver() -
getRemoteRepositories
-
doesNeedSessionLock
protected boolean doesNeedSessionLock() -
getTempFileFolder
-
isFilterEnvPath
public boolean isFilterEnvPath() -
findMvnProperty
-
isSkip
public boolean isSkip() -
isEnforceGoPathToEnd
public boolean isEnforceGoPathToEnd() -
getProject
-
getExecution
-
getSession
-
isIgnoreErrorExitCode
public boolean isIgnoreErrorExitCode() -
getEnv
-
getSdkDownloadUrl
-
getExecSubpath
-
getConnectionTimeout
public int getConnectionTimeout() -
getExec
-
isUseEnvVars
public boolean isUseEnvVars() -
isKeepSdkArchive
public boolean isKeepSdkArchive() -
isKeepUnarchFolderIfError
public boolean isKeepUnarchFolderIfError() -
getSdkArchiveName
-
getReportsFolder
-
getOutLogFile
-
getErrLogFile
-
isCheckSdkHash
public boolean isCheckSdkHash() -
getStoreFolder
-
getUseGoTool
-
isVerbose
public boolean isVerbose() -
isDisableSdkLoad
public boolean isDisableSdkLoad() -
getSdkSite
-
getBuildFlags
-
getExtraBuildFlags
-
findGoPath
- Throws:
IOException
-
findGoRootBootstrap
- Throws:
IOException
-
getOs
-
getArch
-
getGoRoot
-
getGoCache
-
getGoRootBootstrap
-
getGoBin
-
getGoPath
-
getTargetArm
-
getTarget386
-
getTargetOS
-
getTargetArch
-
isUseMavenProxy
public boolean isUseMavenProxy() -
getSupposeSdkArchiveFileName
public boolean getSupposeSdkArchiveFileName() -
isDisableSslCheck
public boolean isDisableSslCheck() -
setDisableSslCheck
public void setDisableSslCheck(boolean flag) -
getProxy
-
getOSXVersion
-
getGoVersion
-
getSources
- Throws:
IOException
-
addTmpBuildFlagIfNotPresented
-
logOptionally
-
initConsoleBuffers
protected void initConsoleBuffers() -
findGoRoot
@Nonnull protected File findGoRoot(@Nullable ProxySettings proxySettings) throws IOException, org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
IOExceptionorg.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-
isHideBanner
public boolean isHideBanner() -
doesNeedOneMoreAttempt
protected boolean doesNeedOneMoreAttempt(@Nonnull org.zeroturnaround.exec.ProcessResult result, @Nonnull String consoleOut, @Nonnull String consoleErr) throws IOException, org.apache.maven.plugin.MojoExecutionException- Throws:
IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
doMainBusiness
protected boolean doMainBusiness(@Nullable ProxySettings proxySettings, int maxAttempts) throws InterruptedException, org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException, IOException- Throws:
InterruptedExceptionorg.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionExceptionIOException
-
execute
public final void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
doInit
public void doInit() throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-
beforeExecution
public void beforeExecution(@Nullable ProxySettings proxySettings) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-
afterExecution
public void afterExecution(@Nullable ProxySettings proxySettings, boolean error) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-
isEnforcePrintOutput
public boolean isEnforcePrintOutput() -
printLogs
-
isSourceFolderRequired
public boolean isSourceFolderRequired() -
isMojoMustNotBeExecuted
public boolean isMojoMustNotBeExecuted() throws org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoFailureException
-
getTailArguments
-
getOptionalExtraTailArguments
-
makeExecutableFileSubpath
-
getGoCommand
-
getCommandFlags
-
prepareExecutor
@Nullable protected org.zeroturnaround.exec.ProcessExecutor prepareExecutor(@Nullable ProxySettings proxySettings) throws IOException, org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
IOExceptionorg.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-
registerOutputBuffers
-
registerEnvVars
protected void registerEnvVars(@Nonnull org.zeroturnaround.exec.ProcessExecutor result, @Nonnull File theGoRoot, @Nullable String theGoBin, @Nullable String theGoCache, @Nonnull File sourcesFile, @MustNotContainNull @Nonnull File[] goPathParts) throws IOException- Throws:
IOException
-
findAllGoModsInFolder
@Nonnull @MustNotContainNull protected List<File> findAllGoModsInFolder(@Nonnull @MustNotContainNull File folder) throws IOException- Throws:
IOException
-
getWorkingDirectoryForExecutor
- Throws:
IOException
-
getSpecialPartOfGoPath
Internal method which returns special part of GOPATH which can be formed by mojos. Must be either empty or contain folders divided by file path separator.- Returns:
- special part of GOPATH, must not be null, by default must be empty
-
makePathFromExtraGoPathElements
-
isCommandSupportVerbose
public boolean isCommandSupportVerbose() -
getSkipMojoPropertySuffix
-
processConsoleOut
protected void processConsoleOut(int exitCode, @Nonnull String out, @Nonnull String err) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-