public abstract class AbstractCrowdinMojo
extends org.apache.maven.plugin.AbstractMojo
| Modifier and Type | Field and Description |
|---|---|
protected static String |
API_URL
The crowdin API URL
|
protected org.apache.maven.wagon.authentication.AuthenticationInfo |
authenticationInfo
The
AuthenticationInfo |
protected org.apache.http.impl.client.CloseableHttpClient |
client
The HTTP client
|
protected String |
crowdinServerId
Server id in settings.xml.
|
protected File |
downloadFolder
The folder where the downloaded language files should be placed.
|
protected File |
languageFilesFolder
The folder where the language files are located in the project.
|
protected org.apache.maven.project.MavenProject |
project
The current Maven project
|
protected String |
rootBranch
The git branch that should be treated as root in crowdin versions
management.
|
protected static org.jdom.input.SAXBuilder |
SAX_BUILDER
The static
SAXBuilder instance |
protected File |
statusFile
The file where the translations status/statistics should be stored.
|
protected org.apache.maven.artifact.manager.WagonManager |
wagonManager
The Maven Wagon manager to use when obtaining server authentication details.
|
| Constructor and Description |
|---|
AbstractCrowdinMojo() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
crowdinContainsBranch(org.jdom.Element files,
String branchName)
Checks if the given
Element contains the specified branch. |
protected boolean |
crowdinContainsFile(org.jdom.Element files,
String fileName)
Checks if the given
Element contains the specified file. |
protected boolean |
crowdinContainsFile(org.jdom.Element files,
String fileName,
boolean folder,
boolean branch)
Checks if the given
Element contains the specified file, folder
or branch. |
protected boolean |
crowdinContainsFolder(org.jdom.Element files,
String folderName)
Checks if the given
Element contains the specified folder. |
protected void |
crowdinCreateBranch(String branchName)
Creates a new branch at crowdin.
|
protected void |
crowdinCreateFolder(String folderName)
Creates a new folder at crowdin.
|
protected org.jdom.Element |
crowdinGetBranch(List<org.jdom.Element> items,
String branchName)
Extracts the branch
Element with the given name. |
protected org.jdom.Element |
crowdinGetFolder(List<org.jdom.Element> items,
String folderName)
Extracts the folder
Element with the given name. |
protected org.jdom.Element |
crowdinGetFolder(List<org.jdom.Element> items,
String folderName,
boolean branch)
Extracts the folder or branch
Element with the given name. |
protected boolean |
crowdinIsBranch(org.jdom.Element item)
Verifies whether a given
Element is a crowdin branch. |
protected boolean |
crowdinIsFolder(org.jdom.Element item)
Verifies whether a given
Element is a crowdin folder. |
protected org.jdom.Document |
crowdinRequestAPI(String method,
Map<String,String> parameters,
Map<String,File> files,
boolean mustSucceed)
Makes a request to the crowdin API and returns the result as a
Document. |
protected org.jdom.Document |
crowdinRequestAPI(String method,
Map<String,String> parameters,
Map<String,File> files,
Map<String,String> titles,
Map<String,String> patterns,
boolean mustSucceed)
Makes a request to the crowdin API and returns the result as a
Document. |
void |
execute() |
protected String |
getBranch()
Gets the crowdin branch name that matches the name of the current Git
branch.
|
protected String |
getBranch(boolean create,
org.jdom.Document projectDetails)
Creates or gets the crowdin branch name that matches the name of the
current Git branch.
|
protected org.jdom.Element |
getCrowdinFiles(String branch,
org.jdom.Document projectDetails)
Requests project information including all files and returns the files
element.
|
protected String |
getMavenId(org.apache.maven.artifact.Artifact artifact)
Gets the Maven id from the given
Artifact. |
protected void |
setCrowdinServerId(String serverId)
Sets the
crowdinServerId value. |
protected void |
setDownloadFolder(File folder)
Sets the
downloadFolder value. |
protected void |
setLanguageFilesFolder(File folder)
Sets the
languageFilesFolder value. |
protected void |
setProject(org.apache.maven.project.MavenProject value)
Sets the
project value. |
protected void |
setRootBranch(String branch)
Sets the
rootBranch value. |
protected void |
setStatusFile(File statusFile)
Sets the
statusFile value. |
protected void |
setWagonManager(org.apache.maven.artifact.manager.WagonManager wagonManager)
Sets the
wagonManager value. |
protected static final org.jdom.input.SAXBuilder SAX_BUILDER
SAXBuilder instanceprotected static final String API_URL
protected org.apache.maven.project.MavenProject project
protected File languageFilesFolder
protected File downloadFolder
protected File statusFile
protected String rootBranch
protected org.apache.maven.artifact.manager.WagonManager wagonManager
protected String crowdinServerId
<username> is project identifier,
<password> is API key.protected org.apache.http.impl.client.CloseableHttpClient client
protected org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo
AuthenticationInfoprotected void setProject(org.apache.maven.project.MavenProject value)
project value.value - the MavenProject to set.protected void setLanguageFilesFolder(File folder)
languageFilesFolder value.folder - the File representing a folder to set.protected void setDownloadFolder(File folder)
downloadFolder value.folder - the File representing a folder to set.protected void setStatusFile(File statusFile)
statusFile value.statusFile - the status File to set.protected void setRootBranch(String branch)
rootBranch value.branch - the Git root branch name.protected void setWagonManager(org.apache.maven.artifact.manager.WagonManager wagonManager)
wagonManager value.wagonManager - the WagonManager to set.protected void setCrowdinServerId(String serverId)
crowdinServerId value.serverId - The Maven server id to set.crowdinServerIdpublic void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionprotected boolean crowdinContainsFile(org.jdom.Element files,
String fileName,
boolean folder,
boolean branch)
throws org.apache.maven.plugin.MojoExecutionException
Element contains the specified file, folder
or branch.files - the Element to check.fileName - the file name to look for.folder - whether the check is for a folder instead of a file.branch - whether the check is for a branch instead of a file.true if the file, folder or branch exists in
files, false otherwise.org.apache.maven.plugin.MojoExecutionException - If an error occurs.protected boolean crowdinContainsFile(org.jdom.Element files,
String fileName)
throws org.apache.maven.plugin.MojoExecutionException
Element contains the specified file.files - the Element to check.fileName - the file name to look for.true if the file exists in files, false
otherwise.org.apache.maven.plugin.MojoExecutionException - If an error occurs.protected boolean crowdinContainsFolder(org.jdom.Element files,
String folderName)
throws org.apache.maven.plugin.MojoExecutionException
Element contains the specified folder.files - the Element to check.folderName - the folder name to look for.true if the folder exists in files, false
otherwise.org.apache.maven.plugin.MojoExecutionException - If an error occurs.protected boolean crowdinContainsBranch(org.jdom.Element files,
String branchName)
throws org.apache.maven.plugin.MojoExecutionException
Element contains the specified branch.files - the Element to check.branchName - the file name to look for.true if the branch exists in files, false
otherwise.org.apache.maven.plugin.MojoExecutionException - If an error occurs.protected org.jdom.Element crowdinGetFolder(List<org.jdom.Element> items, String folderName)
Element with the given name.items - the List of Elements to extract from.folderName - the folder name.Element or null.protected org.jdom.Element crowdinGetBranch(List<org.jdom.Element> items, String branchName)
Element with the given name.items - the List of Elements to extract from.branchName - the branch name.Element or null.protected org.jdom.Element crowdinGetFolder(List<org.jdom.Element> items, String folderName, boolean branch)
Element with the given name.items - the List of Elements to extract from.folderName - the branch or folder name.branch - whether to look for a branch instead of a folder.Element or null.protected boolean crowdinIsFolder(org.jdom.Element item)
Element is a crowdin folder.item - the Element to check.item is a crowdin folder, false
otherwise.protected boolean crowdinIsBranch(org.jdom.Element item)
Element is a crowdin branch.item - the Element to check.item is a crowdin branch, false
otherwise.protected void crowdinCreateFolder(String folderName) throws org.apache.maven.plugin.MojoExecutionException
folderName - the name of the new folder.org.apache.maven.plugin.MojoExecutionException - If an error occurs during the operation.protected void crowdinCreateBranch(String branchName) throws org.apache.maven.plugin.MojoExecutionException
branchName - the name of the new branch.org.apache.maven.plugin.MojoExecutionException - If an error occurs during the operation.protected org.jdom.Document crowdinRequestAPI(String method, Map<String,String> parameters, Map<String,File> files, boolean mustSucceed) throws org.apache.maven.plugin.MojoExecutionException
Document.method - the API method to use.parameters - the Map of API parameters to use.files - the Map of files to use.mustSucceed - whether to throw a MojoExecutionException if
the returned Document contains an error code.Document.org.apache.maven.plugin.MojoExecutionException - If an error occurs during the operation.protected org.jdom.Document crowdinRequestAPI(String method, Map<String,String> parameters, Map<String,File> files, Map<String,String> titles, Map<String,String> patterns, boolean mustSucceed) throws org.apache.maven.plugin.MojoExecutionException
Document.method - the API method to use.parameters - the Map of API parameters to use.files - the Map of files to use.titles - the Map of titles to use.patterns - the Map of patterns to use.mustSucceed - whether to throw a MojoExecutionException if
the returned Document contains an error code.Document.org.apache.maven.plugin.MojoExecutionException - If an error occurs during the operation.protected org.jdom.Element getCrowdinFiles(String branch, org.jdom.Document projectDetails) throws org.apache.maven.plugin.MojoExecutionException
null in which case the root files
Element is returned.branch - the branch name.projectDetails - the project details.Element.org.apache.maven.plugin.MojoExecutionException - If an error occurs during the operation.protected String getMavenId(org.apache.maven.artifact.Artifact artifact)
Artifact.artifact - the Artifact whose Maven id to return.protected String getBranch() throws org.apache.maven.plugin.MojoExecutionException
null if the current git branch is the
crowdin root.org.apache.maven.plugin.MojoExecutionException - If an error occurs during the operation.protected String getBranch(boolean create, org.jdom.Document projectDetails) throws org.apache.maven.plugin.MojoExecutionException
create - whether the branch should be created at crowdin if it
doesn't exist.projectDetails - the Document containing the project
details. If null the project details will be retrieved
from crowdin.null if the current git branch is the
crowdin root.org.apache.maven.plugin.MojoExecutionException - If an error occurs during the operation.Copyright © 2018. All rights reserved.