├── .travis.yml ├── gradle.properties ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── resources │ └── META-INF │ │ └── gradle-plugins │ │ └── org.standardout.versioneye.properties │ └── groovy │ └── org │ └── standardout │ └── gradle │ └── plugin │ └── versioneye │ ├── UpdateTask.groovy │ ├── CreateTask.groovy │ ├── VersionEyeExtension.groovy │ ├── Util.groovy │ ├── VersionEyePlugin.groovy │ └── PomTask.groovy ├── .editorconfig ├── LICENSE ├── CHANGES.md ├── gradlew.bat ├── codetemplates.xml ├── gradlew └── README.md /.travis.yml: -------------------------------------------------------------------------------- 1 | language: groovy 2 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # override in gradle user home 2 | bintrayUser= 3 | bintrayApiKey= 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | bin/ 4 | .classpath 5 | .project 6 | .settings/ 7 | *~ 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stempler/gradle-versioneye-plugin/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/org.standardout.versioneye.properties: -------------------------------------------------------------------------------- 1 | implementation-class=org.standardout.gradle.plugin.versioneye.VersionEyePlugin -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jul 24 21:32:30 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-bin.zip 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | trim_trailing_whitespace = true 8 | charset = utf-8 9 | indent_style = space 10 | indent_size = 2 11 | # not supported by eclipseconfig 12 | insert_final_newline = true 13 | 14 | [build.gradle] 15 | indent_style = tab 16 | 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Templer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | ### 1.5.0 2 | 3 | - Fix problems with unresolvable configurations introduced in Gradle 3.4 4 | - Add support for connecting to VersionEye via a proxy 5 | 6 | ### 1.4.0 7 | 8 | - Support for including sub-project dependencies 9 | 10 | ### 1.3.0 11 | 12 | - Added tasks for security and license checks 13 | - Support association to an organisation and team when creating a VersionEye project 14 | - Don't override comments in `gradle.properties` when creating a VersionEye project 15 | - Support for determining dependencies to Gradle plugins 16 | - Generate a `pom.json` instead of a `pom.xml` for upload to VersionEye 17 | - Derive dependency scopes from dependency configuration names 18 | - Define API key via `VERSIONEYE_API_KEY` environment variable (only if Gradle property is not defined) 19 | - Added plugin task group and task descriptions 20 | - Improved error reporting for failed requests to the VersionEye API 21 | 22 | ### 1.2.0 23 | 24 | - Support customizing base URL for use with VersionEye Enterprise 25 | 26 | ### 1.1.0 27 | 28 | - Fix for breaking VersionEye API change (Project key is obsolete) 29 | 30 | ### 1.0.0 31 | 32 | - Qualified plugin ID (`org.standardout.versioneye`) for use with new Gradle plugin repository 33 | - [#2](https://github.com/stempler/gradle-versioneye-plugin/pull/2) Increased log level to lifecycle and added more logging on update 34 | 35 | 36 | ### 0.1.1 37 | 38 | - Fixed failure when build directory was not present 39 | 40 | ### 0.1.0 - initial version 41 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /src/main/groovy/org/standardout/gradle/plugin/versioneye/UpdateTask.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Simon Templer 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.standardout.gradle.plugin.versioneye 26 | 27 | import groovyx.net.http.ContentType 28 | import groovyx.net.http.HTTPBuilder 29 | import groovyx.net.http.Method 30 | import groovyx.net.http.RESTClient 31 | import org.apache.http.entity.mime.MultipartEntityBuilder 32 | import org.apache.http.entity.ContentType as ApacheContentType 33 | import org.gradle.api.DefaultTask 34 | import org.gradle.api.GradleException 35 | import org.gradle.api.artifacts.Dependency 36 | import org.gradle.api.artifacts.ExternalDependency 37 | import org.gradle.api.artifacts.ResolvedArtifact 38 | import org.gradle.api.specs.Spec 39 | import org.gradle.api.tasks.TaskAction 40 | import static Util.* 41 | 42 | /** 43 | * Updates the VersionEye project with the Gradle project dependencies. 44 | * 45 | * @author Simon Templer 46 | */ 47 | class UpdateTask extends DefaultTask { 48 | 49 | def dependencies 50 | 51 | @TaskAction 52 | def update() { 53 | assert dependencies as File && (dependencies as File).exists() 54 | def projectId = project.properties[VersionEyePlugin.PROP_PROJECT_ID] 55 | assert projectId, 'No project ID defined - either define a project ID manually or run the versioneye-create task' 56 | def apiKey = getApiKey(project) 57 | 58 | def http = createHttpBuilder(project) 59 | 60 | http.request( Method.POST, ContentType.JSON ) { req -> 61 | uri.path = '/api/v2/projects/' + projectId 62 | uri.query = [ api_key: apiKey ] 63 | requestContentType = 'multipart/form-data' 64 | def entityBuilder = MultipartEntityBuilder.create() 65 | entityBuilder.addBinaryBody('project_file', dependencies as File, ApacheContentType.APPLICATION_JSON, 'pom.json') 66 | req.entity = entityBuilder.build() 67 | 68 | response.success = { 69 | resp, json -> 70 | assert json, 'Invalid response' 71 | project.logger.lifecycle "Updated VersionEye project $json.name successfully" 72 | logResult(project, json) 73 | } 74 | } 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/groovy/org/standardout/gradle/plugin/versioneye/CreateTask.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Simon Templer 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.standardout.gradle.plugin.versioneye 26 | 27 | import groovyx.net.http.ContentType; 28 | import groovyx.net.http.HTTPBuilder 29 | import groovyx.net.http.Method; 30 | import groovyx.net.http.RESTClient 31 | import org.apache.http.entity.mime.MultipartEntityBuilder 32 | import org.apache.http.entity.ContentType as ApacheContentType 33 | import org.gradle.api.DefaultTask 34 | import org.gradle.api.artifacts.Dependency; 35 | import org.gradle.api.artifacts.ExternalDependency 36 | import org.gradle.api.artifacts.ResolvedArtifact 37 | import org.gradle.api.specs.Spec; 38 | import org.gradle.api.tasks.TaskAction; 39 | import static Util.* 40 | 41 | /** 42 | * Creates a VersionEye project and stores the project key in the 43 | * gradle.properties of a Gradle project. 44 | * 45 | * @author Simon Templer 46 | */ 47 | class CreateTask extends DefaultTask { 48 | 49 | def dependencies 50 | def properties 51 | 52 | @TaskAction 53 | def create() { 54 | File propertiesFile = properties as File 55 | assert propertiesFile 56 | assert dependencies as File && (dependencies as File).exists() 57 | def apiKey = getApiKey(project) 58 | def keyAlreadyThere = project.properties[VersionEyePlugin.PROP_PROJECT_ID] 59 | assert !keyAlreadyThere, 'There is already a project ID defined, run versioneye-update to update the existing project instead' 60 | 61 | def orgName = project.properties[VersionEyePlugin.PROP_ORGANISATION] 62 | def teamName = project.properties[VersionEyePlugin.PROP_TEAM] 63 | if (teamName) { 64 | assert orgName, 'If a team is defined for the VersionEye project, an organisation must be defined as well' 65 | } 66 | 67 | def http = createHttpBuilder(project) 68 | 69 | http.request( Method.POST, ContentType.JSON ) { req -> 70 | uri.path = '/api/v2/projects' 71 | uri.query = [ api_key: apiKey ] 72 | requestContentType = 'multipart/form-data' 73 | def entityBuilder = MultipartEntityBuilder.create() 74 | entityBuilder.addBinaryBody('upload', dependencies as File, ApacheContentType.APPLICATION_JSON, 'pom.json') 75 | entityBuilder.addTextBody('name', project.name) 76 | 77 | if (orgName) { 78 | entityBuilder.addTextBody('orga_name', orgName) 79 | } 80 | if (teamName) { 81 | entityBuilder.addTextBody('team_name', teamName) 82 | } 83 | 84 | req.entity = entityBuilder.build() 85 | 86 | response.success = { 87 | resp, json -> 88 | // extract project ID 89 | assert json, 'Invalid response' 90 | def projectId = json.id 91 | assert projectId, 'Project ID could not be determined from response' 92 | project.logger.lifecycle "Project created with project ID $projectId" 93 | 94 | // save project ID in properties 95 | saveProjectId(project, propertiesFile, projectId) 96 | 97 | logResult(project, json) 98 | } 99 | } 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/groovy/org/standardout/gradle/plugin/versioneye/VersionEyeExtension.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Simon Templer 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.standardout.gradle.plugin.versioneye 26 | 27 | import java.util.Set; 28 | 29 | import org.gradle.api.Project; 30 | 31 | /** 32 | * Extension for configuring VersionEye plugin. 33 | * 34 | * @author Simon Templer 35 | */ 36 | class VersionEyeExtension { 37 | 38 | // dependencies values 39 | public static final String transitive = 'transitive' 40 | public static final String declared = 'declared' 41 | 42 | final Project project 43 | 44 | VersionEyeExtension(Project project) { 45 | this.project = project 46 | } 47 | 48 | /** 49 | * States which dependencies are analyzed - only the defined or all resolved dependencies. 50 | */ 51 | String dependencies = declared 52 | 53 | /** 54 | * Configuration to exclude when calculating the dependencies. 55 | */ 56 | final Set excludeConfigurations = new HashSet() 57 | 58 | /** 59 | * If the license check should fail when unknown licenses are encountered. 60 | */ 61 | boolean licenseCheckBreakByUnknown = false 62 | 63 | /** 64 | * If Gradle plugins should be included in the dependencies. 65 | * 66 | * Gradle plugin dependencies are determined via the build script dependency 67 | * configurations. 68 | */ 69 | boolean includePlugins = true 70 | 71 | /** 72 | * If dependencies from sub-projects should be included. 73 | */ 74 | boolean includeSubProjects = false 75 | 76 | /** 77 | * Specify configurations to exclude. 78 | */ 79 | void exclude(String... configs) { 80 | (configs as List).each { 81 | excludeConfigurations << it 82 | } 83 | } 84 | 85 | /** 86 | * Base URL of the VersionEye API. 87 | */ 88 | String baseUrl = 'https://www.versioneye.com' 89 | 90 | /** 91 | * Default implementation of determining scopes from 92 | * a dependency's configuration names. 93 | * 94 | * - always retains special 'plugin' configuration as scope 95 | * - preferably uses scope 'compile', 'test' or 'runtime' based 96 | * on standard Gradle project setups 97 | * - as fallback uses all configuration names as they are 98 | */ 99 | public static final Closure DEFAULT = { Set configs -> 100 | Set result = new HashSet<>() 101 | 102 | // plugin scope 103 | if (configs.remove('plugin')) { 104 | result.add('plugin') 105 | } 106 | 107 | // best guess based on standard configuration names like for example in the Java plugin 108 | 109 | // prefer compile... 110 | if (configs.any { it.startsWith('compile') }) { 111 | result.add('compile') 112 | } 113 | // ...before test... 114 | else if (configs.any { it.startsWith('test') }) { 115 | result.add('test') 116 | } 117 | // ...before runtime... 118 | else if (configs.any { it.startsWith('runtime') }) { 119 | result.add('runtime') 120 | } 121 | // ...otherwise just use configuration names 122 | else { 123 | result.addAll(configs) 124 | } 125 | 126 | result 127 | } 128 | 129 | /** 130 | * Strategy for determining scopes that simply uses the 131 | * dependency configuration names, as well as the 'plugin' 132 | * scope for any build script dependencies. 133 | */ 134 | public static final Closure CONFIGURATIONS = { Set configs -> 135 | configs 136 | } 137 | 138 | /** 139 | * Strategy to determine dependency scopes. 140 | * 141 | * Input is the set of configuration names a dependency was found in, 142 | * output should be an Iterable of Strings that holds the corresponding 143 | * scope names for the dependency. 144 | * Note that for all build script dependencies the configuration 145 | * name given here is 'plugin'. 146 | * 147 | * See the default implementation for an example. 148 | */ 149 | Closure determineScopeStrategy = DEFAULT 150 | 151 | // internal 152 | 153 | /** 154 | * Test if the given configuration should be excluded. 155 | */ 156 | boolean acceptConfiguration(String name) { 157 | !excludeConfigurations.contains(name) 158 | } 159 | 160 | /** 161 | * Cache the response received from VersionEye with create or update. 162 | */ 163 | def lastVersionEyeResponse 164 | 165 | } 166 | -------------------------------------------------------------------------------- /codetemplates.xml: -------------------------------------------------------------------------------- 1 |