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