From 445e3e2ea156467459c2fe020c013144d7cda7df Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Tue, 19 Feb 2019 21:22:23 +0100 Subject: [PATCH] gitlab4j-api --- CHANGELOG.md | 9 +++++ README.md | 20 +++++++---- build.gradle | 2 +- .../gradle/ViolationCommentsToGitLabTask.java | 36 +++++++++++-------- .../build.gradle | 8 ++++- 5 files changed, 52 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 782dcaa..60b2088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,15 @@ Changelog of Violation comments to gitlab gradle plugin. +## Unreleased +### No issue + +**gitlab4j-api** + + +[d0c6f9c2a8a5b57](https://github.com/tomasbjerre/violation-comments-to-gitlab-gradle-plugin/commit/d0c6f9c2a8a5b57) Tomas Bjerre *2019-02-19 20:22:23* + + ## 1.25 ### No issue diff --git a/README.md b/README.md index 7c90655..5ec4ee7 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ A number of **parsers** have been implemented. Some **parsers** can parse output | [_Checkstyle_](http://checkstyle.sourceforge.net/) | `CHECKSTYLE` | | [_CodeNarc_](http://codenarc.sourceforge.net/) | `CODENARC` | | [_Detekt_](https://github.com/arturbosch/detekt) | `CHECKSTYLE` | With `--output-format xml`. -| [_ERB_](https://www.puppetcookbook.com/posts/erb-template-validation.html) | `CLANG` | With `erb -P -x -T '-' "${it}" \| ruby -c 2>&1 >/dev/null \| grep '^-' \| sed -E 's/^-([a-zA-Z0-9:]+)/${filename}\1 ERROR:/p' > erbfiles.out`. | [_DocFX_](http://dotnet.github.io/docfx/) | `DOCFX` | | [_Doxygen_](https://www.stack.nl/~dimitri/doxygen/) | `CLANG` | +| [_ERB_](https://www.puppetcookbook.com/posts/erb-template-validation.html) | `CLANG` | With `erb -P -x -T '-' "${it}" \| ruby -c 2>&1 >/dev/null \| grep '^-' \| sed -E 's/^-([a-zA-Z0-9:]+)/${filename}\1 ERROR:/p' > erbfiles.out`. | [_ESLint_](https://github.com/sindresorhus/grunt-eslint) | `CHECKSTYLE` | With `format: 'checkstyle'`. | [_Findbugs_](http://findbugs.sourceforge.net/) | `FINDBUGS` | | [_Flake8_](http://flake8.readthedocs.org/en/latest/) | `FLAKE8` | @@ -35,6 +35,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output | [_GoLint_](https://github.com/golang/lint) | `GOLINT` | | [_GoVet_](https://golang.org/cmd/vet/) | `GOLINT` | Same format as GoLint. | [_GoogleErrorProne_](https://github.com/google/error-prone) | `GOOGLEERRORPRONE` | +| [_IAR_](https://www.iar.com/iar-embedded-workbench/) | `IAR` | With `--no_wrap_diagnostics` | [_Infer_](http://fbinfer.com/) | `PMD` | Facebook Infer. With `--pmd-xml`. | [_JCReport_](https://github.com/jCoderZ/fawkez/wiki/JcReport) | `JCREPORT` | | [_JSHint_](http://jshint.com/) | `JSHINT` | @@ -43,6 +44,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output | [_KotlinGradle_](https://github.com/JetBrains/kotlin) | `KOTLINGRADLE` | Output from Kotlin Gradle Plugin. | [_KotlinMaven_](https://github.com/JetBrains/kotlin) | `KOTLINMAVEN` | Output from Kotlin Maven Plugin. | [_Lint_]() | `LINT` | A common XML format, used by different linters. +| [_MSCpp_](https://visualstudio.microsoft.com/vs/features/cplusplus/) | `MSCPP` | | [_Mccabe_](https://pypi.python.org/pypi/mccabe) | `FLAKE8` | | [_MyPy_](https://pypi.python.org/pypi/mypy-lang) | `MYPY` | | [_NullAway_](https://github.com/uber/NullAway) | `GOOGLEERRORPRONE` | Same format as Google Error Prone. @@ -60,6 +62,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output | [_ReSharper_](https://www.jetbrains.com/resharper/) | `RESHARPER` | | [_RubyCop_](http://rubocop.readthedocs.io/en/latest/formatters/) | `CLANG` | With `rubycop -f clang file.rb` | [_SbtScalac_](http://www.scala-sbt.org/) | `SBTSCALAC` | +| [_Scalastyle_](http://www.scalastyle.org/) | `CHECKSTYLE` | | [_Simian_](http://www.harukizaemon.com/simian/) | `SIMIAN` | | [_Spotbugs_](https://spotbugs.github.io/) | `FINDBUGS` | | [_StyleCop_](https://stylecop.codeplex.com/) | `STYLECOP` | @@ -72,15 +75,14 @@ A number of **parsers** have been implemented. Some **parsers** can parse output Missing a format? Open an issue [here](https://github.com/tomasbjerre/violations-lib/issues)! ## Usage ## -There is a running example [here](https://github.com/tomasbjerre/violation-comments-to-gitlab-gradle-plugin/tree/master/violation-comments-to-gitlab-gradle-plugin-example). +There is a running example [here](/violation-comments-to-gitlab-gradle-plugin-example) and it is invoked [here](/build.sh). Here is and example: -``` +`` buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' } - maven { url 'https://jitpack.io' } } dependencies { classpath "se.bjurr.violations:violation-comments-to-gitlab-gradle-plugin:X" @@ -99,14 +101,20 @@ task violationCommentsToGitLab(type: se.bjurr.violations.comments.gitlab.plugin. createSingleFileComments = true; keepOldComments = false; minSeverity = "INFO"; + //commentTemplate = """ + // See https://github.com/tomasbjerre/violation-comments-lib + //""" apiTokenPrivate = true; apiToken = System.properties['GITLAB_APITOKEN']; - authMethodHeader = true; ignoreCertificateErrors = true; shouldSetWip = false; - + + //proxyServer = "" + //proxyUser = "" + //proxyPassword = "" + violations = [ ["FINDBUGS", ".", ".*/findbugs/.*\\.xml\$", "Findbugs"], ["PMD", ".", ".*/pmd/.*\\.xml\$", "PMD"], diff --git a/build.gradle b/build.gradle index 397c2cf..862dc40 100644 --- a/build.gradle +++ b/build.gradle @@ -20,5 +20,5 @@ apply from: project.buildscript.classLoader.getResource('gradle-plugin.gradle'). apply from: project.buildscript.classLoader.getResource('violations.gradle').toURI() dependencies { - compile 'se.bjurr.violations:violation-comments-to-gitlab-lib:1.56' + compile 'se.bjurr.violations:violation-comments-to-gitlab-lib:1.66' } diff --git a/src/main/java/se/bjurr/violations/comments/gitlab/plugin/gradle/ViolationCommentsToGitLabTask.java b/src/main/java/se/bjurr/violations/comments/gitlab/plugin/gradle/ViolationCommentsToGitLabTask.java index 51824dd..0324bac 100644 --- a/src/main/java/se/bjurr/violations/comments/gitlab/plugin/gradle/ViolationCommentsToGitLabTask.java +++ b/src/main/java/se/bjurr/violations/comments/gitlab/plugin/gradle/ViolationCommentsToGitLabTask.java @@ -1,17 +1,12 @@ package se.bjurr.violations.comments.gitlab.plugin.gradle; -import static org.gitlab.api.AuthMethod.HEADER; -import static org.gitlab.api.AuthMethod.URL_PARAMETER; -import static org.gitlab.api.TokenType.ACCESS_TOKEN; -import static org.gitlab.api.TokenType.PRIVATE_TOKEN; import static se.bjurr.violations.comments.gitlab.lib.ViolationCommentsToGitLabApi.violationCommentsToGitLabApi; import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.INFO; import java.util.ArrayList; import java.util.List; -import org.gitlab.api.AuthMethod; -import org.gitlab.api.TokenType; +import org.gitlab4j.api.Constants.TokenType; import org.gradle.api.DefaultTask; import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskExecutionException; @@ -32,11 +27,13 @@ public class ViolationCommentsToGitLabTask extends DefaultTask { private String mergeRequestIid; private Boolean ignoreCertificateErrors = true; private Boolean apiTokenPrivate = true; - private Boolean authMethodHeader = true; private SEVERITY minSeverity = INFO; private Boolean keepOldComments = false; private Boolean shouldSetWip = false; private String commentTemplate; + private String proxyServer; + private String proxyUser; + private String proxyPassword; public void setCommentOnlyChangedContent(final boolean commentOnlyChangedContent) { this.commentOnlyChangedContent = commentOnlyChangedContent; @@ -75,10 +72,6 @@ public void setApiTokenPrivate(final Boolean apiTokenPrivate) { this.apiTokenPrivate = apiTokenPrivate; } - public void setAuthMethodHeader(final Boolean authMethodHeader) { - this.authMethodHeader = authMethodHeader; - } - public void setMinSeverity(final SEVERITY minSeverity) { this.minSeverity = minSeverity; } @@ -99,6 +92,18 @@ public void setCommentTemplate(final String commentTemplate) { this.commentTemplate = commentTemplate; } + public void setProxyServer(final String proxyServer) { + this.proxyServer = proxyServer; + } + + public void setProxyUser(final String proxyUser) { + this.proxyUser = proxyUser; + } + + public void setProxyPassword(final String proxyPassword) { + this.proxyPassword = proxyPassword; + } + @TaskAction public void gitChangelogPluginTasks() throws TaskExecutionException { getProject().getExtensions().findByType(ViolationCommentsToGitLabPluginExtension.class); @@ -134,8 +139,7 @@ public void gitChangelogPluginTasks() throws TaskExecutionException { } try { - final TokenType tokenType = apiTokenPrivate ? PRIVATE_TOKEN : ACCESS_TOKEN; - final AuthMethod authMethod = authMethodHeader ? HEADER : URL_PARAMETER; + final TokenType tokenType = apiTokenPrivate ? TokenType.PRIVATE : TokenType.ACCESS; final Integer mergeRequestIidInteger = Integer.parseInt(mergeRequestIid); violationCommentsToGitLabApi() // .setHostUrl(gitLabUrl) // @@ -143,7 +147,6 @@ public void gitChangelogPluginTasks() throws TaskExecutionException { .setMergeRequestIid(mergeRequestIidInteger) // .setApiToken(apiToken) // .setTokenType(tokenType) // - .setMethod(authMethod) // .setCommentOnlyChangedContent(commentOnlyChangedContent) // .setCreateCommentWithAllSingleFileComments(createCommentWithAllSingleFileComments) // .setCreateSingleFileComments(createSingleFileComments) // @@ -151,7 +154,10 @@ public void gitChangelogPluginTasks() throws TaskExecutionException { .setViolations(allParsedViolations) // .setShouldKeepOldComments(keepOldComments) // .setShouldSetWIP(shouldSetWip) // - .withCommentTemplate(commentTemplate) // + .setCommentTemplate(commentTemplate) // + .setProxyServer(proxyServer) // + .setProxyUser(proxyUser) // + .setProxyPassword(proxyPassword) // .toPullRequest(); } catch (final Exception e) { getLogger().error("", e); diff --git a/violation-comments-to-gitlab-gradle-plugin-example/build.gradle b/violation-comments-to-gitlab-gradle-plugin-example/build.gradle index 722f841..88f0dc9 100644 --- a/violation-comments-to-gitlab-gradle-plugin-example/build.gradle +++ b/violation-comments-to-gitlab-gradle-plugin-example/build.gradle @@ -21,13 +21,19 @@ task violationCommentsToGitLab(type: se.bjurr.violations.comments.gitlab.plugin. createSingleFileComments = true; keepOldComments = false; minSeverity = "INFO"; + //commentTemplate = """ + // See https://github.com/tomasbjerre/violation-comments-lib + //""" apiTokenPrivate = true; apiToken = System.properties['GITLAB_APITOKEN']; - authMethodHeader = true; ignoreCertificateErrors = true; shouldSetWip = false; + + //proxyServer = "" + //proxyUser = "" + //proxyPassword = "" violations = [ ["FINDBUGS", ".", ".*/findbugs/.*\\.xml\$", "Findbugs"],