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
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 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 voiddoLogging(int resultCode, boolean error, String outLog, String errLog)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 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 Detail
-
GOARTIFACT_PACKAGING
public static final String GOARTIFACT_PACKAGING
- See Also:
- Constant Field Values
-
GO_MOD_FILE_NAME
public static final String GO_MOD_FILE_NAME
- See Also:
- Constant Field Values
-
GO_SUM_FILE_NAME
public static final String GO_SUM_FILE_NAME
- See Also:
- Constant Field Values
-
ENV_GO111MODULE
public static final String ENV_GO111MODULE
- See Also:
- Constant Field Values
-
NAME_PATTERN
public static final String NAME_PATTERN
VERSION, OS, PLATFORM,-OSXVERSION- See Also:
- Constant Field Values
-
buildFlagsToIgnore
protected final Set<String> buildFlagsToIgnore
set of flags to be ignored among build and extra build flags, for inside use
-
settings
@Parameter(defaultValue="${settings}", readonly=true) protected org.apache.maven.settings.Settings settings
-
-
Method Detail
-
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 List<org.apache.maven.artifact.repository.ArtifactRepository> getRemoteRepositories()
-
doesNeedSessionLock
protected boolean doesNeedSessionLock()
-
isFilterEnvPath
public boolean isFilterEnvPath()
-
findMvnProperty
@Nullable protected String findMvnProperty(@Nonnull String key, @Nullable String dflt)
-
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()
-
getConnectionTimeout
public int getConnectionTimeout()
-
isUseEnvVars
public boolean isUseEnvVars()
-
isKeepSdkArchive
public boolean isKeepSdkArchive()
-
isKeepUnarchFolderIfError
public boolean isKeepUnarchFolderIfError()
-
isCheckSdkHash
public boolean isCheckSdkHash()
-
isVerbose
public boolean isVerbose()
-
isDisableSdkLoad
public boolean isDisableSdkLoad()
-
findGoPath
@Nonnull @MustNotContainNull public File[] findGoPath(boolean ensureExist) throws IOException
- Throws:
IOException
-
findGoRootBootstrap
@Nullable public File findGoRootBootstrap(boolean ensureExist) throws IOException
- Throws:
IOException
-
isUseMavenProxy
public boolean isUseMavenProxy()
-
getSupposeSdkArchiveFileName
public boolean getSupposeSdkArchiveFileName()
-
isDisableSslCheck
public boolean isDisableSslCheck()
-
setDisableSslCheck
public void setDisableSslCheck(boolean flag)
-
getProxy
@Nullable public ProxySettings getProxy()
-
getSources
@Nonnull public File getSources(boolean ensureExist) throws IOException
- Throws:
IOException
-
addTmpBuildFlagIfNotPresented
protected void addTmpBuildFlagIfNotPresented(@Nonnull @MustNotContainNull String... flags)
-
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
-
doLogging
protected void doLogging(int resultCode, boolean error, @Nonnull String outLog, @Nonnull String errLog) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.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
protected void printLogs(boolean forcePrint, boolean errorDetected, @Nonnull String outLog, @Nonnull String errLog)
-
isSourceFolderRequired
public boolean isSourceFolderRequired()
-
isMojoMustNotBeExecuted
public boolean isMojoMustNotBeExecuted() throws org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoFailureException
-
getOptionalExtraTailArguments
@Nonnull @MustNotContainNull public String[] getOptionalExtraTailArguments()
-
registerOutputBuffers
protected void registerOutputBuffers(@Nonnull org.zeroturnaround.exec.ProcessExecutor executor)
-
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
@Nonnull protected File getWorkingDirectoryForExecutor() throws IOException
- Throws:
IOException
-
getSpecialPartOfGoPath
@Nonnull protected 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
-
isCommandSupportVerbose
public boolean isCommandSupportVerbose()
-
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
-
-