Skip to content

Commit

Permalink
Release/1.0.0-beta8 (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarari authored Mar 25, 2023
1 parent 7cf7a8f commit fec4471
Show file tree
Hide file tree
Showing 37 changed files with 304 additions and 169 deletions.
15 changes: 14 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,23 @@ jobs:
- checkout
- run:
name: build
command: ./gradlew validateSourceHeaderLicense detekt assemble test --info --stacktrace
command: ./gradlew clean validateSourceHeaderLicense detekt assemble test --info --stacktrace
- codecov/upload:
file: build/reports/jacoco/test/*.xml
publish:
machine:
image: ubuntu-2004:202201-02
steps:
- checkout
- run:
name: publish
command: ./gradlew publishToGradlePortal --info --stacktrace
workflows:
build-workflow:
jobs:
- build
- publish:
filters:
branches:
only:
- main
15 changes: 15 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ tasks.register("validateSourceHeaderLicense") {
}
}

tasks.register("publishToGradlePortal") {
doLast {
val key = System.getenv("GRADLE_PORTAL_KEY")
val secret = System.getenv("GRADLE_PORTAL_SECRET")
exec {
commandLine(
"./gradlew",
"publishPlugins",
"-Pgradle.publish.key=$key",
"-Pgradle.publish.secret=$secret",
).args("--info")
}
}
}

detekt {
config = files("detekt-config.yml")
buildUponDefaultConfig = true
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

# Changelog

## 1.0.0-beta8
* [Feature 81](https://github.com/janbarari/gradle-analytics-plugin/issues/81)
* Used/Available worker count added in console report
* `upcoming-milestone`, `social-press` added in documentation
* More logs added in the `build logger` and `report logger`

## HotFix - 1.0.0-beta7
* Modules Dependency Graph first node selection bug fixed

Expand Down
10 changes: 8 additions & 2 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ Apply the Gradle Plugin to the root of your project.
=== "Kotlin"
``` kotlin
plugins {
id("io.github.janbarari.gradle-analytics-plugin") version "1.0.0-beta7"
id("io.github.janbarari.gradle-analytics-plugin") version "1.0.0-beta8"
}
```
=== "Groovy"
``` groovy
plugins {
id 'io.github.janbarari.gradle-analytics-plugin' version '1.0.0-beta7'
id 'io.github.janbarari.gradle-analytics-plugin' version '1.0.0-beta8'
}
```
[For legacy plugin application, see the Gradle Plugin Portal.](https://plugins.gradle.org/plugin/io.github.janbarari.gradle-analytics-plugin)
Expand Down Expand Up @@ -87,6 +87,9 @@ Add plugin configuration in the root of your project.
"develop"
)

// Optional: Exclude modules that are not necessary like test or demo modules
excludeModules = setOf()

isTrackAllBranchesEnabled = false // Optional: Default is False.

outputPath = "OUTPUT_REPORT_PATH" // Optional: Default is project /build/ dir.
Expand Down Expand Up @@ -125,6 +128,9 @@ Add plugin configuration in the root of your project.
'master',
'develop'
]

// Optional: Exclude modules that are not necessary like test or demo modules
excludeModules = []

isTrackAllBranchesEnabled = false // Optional: Default is False.

Expand Down
30 changes: 30 additions & 0 deletions docs/social-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
MIT License
Copyright (c) 2022 Mehdi Janbarari (@janbarari)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->

# Social
It's my pleasure that Gradle Analytics Plugin has been introduced in the below links:

- [Gradle Newsletter (Oct 2022)](https://newsletter.gradle.org/2022/10)
- [Open Source Agenda](https://www.opensourceagenda.com/tags/gradle-plugins)
- [Awesome Open Source](https://awesomeopensource.com/project/janbarari/gradle-analytics-plugin)

25 changes: 25 additions & 0 deletions docs/upcoming-milestone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
MIT License
Copyright (c) 2022 Mehdi Janbarari (@janbarari)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->

# Upcoming Milestone
Upcoming milestone planning is in progress.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ pluginTags = kotlin,plugin,analytics,analysis,gradle,gradle-plugin,gradle-plugin
pluginImplementationClass = io.github.janbarari.gradle.analytics.GradleAnalyticsPlugin
pluginDeclarationName = gradleAnalyticsPlugin
pluginGroupPackageName = io.github.janbarari
pluginVersion = 1.0.0-beta7
pluginVersion = 1.0.0-beta8
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ nav:
- Third party: third-party.md
- License: license.md
- Community: community.md
- Social/Press: social-press.md
- Upcoming Milestone: upcoming-milestone.md

theme:
name: material
Expand Down Expand Up @@ -69,6 +71,8 @@ markdown_extensions:
- pymdownx.inlinehilite
- pymdownx.tabbed:
alternate_style: true
- pymdownx.tasklist:
custom_checkbox: true

copyright: Made with 🧡 for everyone | Copyright &copy; 2022

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
package io.github.janbarari.gradle

/**
* In order to have reliable code coverage sometimes it's needed to exclude some
* functions or classes that their lifecycle is based on the framework and not
* in developer hand.
* To ensure reliable code coverage, it may be necessary to exclude certain functions
* or classes from analysis, especially those whose lifecycle is based on the framework
* and not controlled by the developer.
*
* Since Jacoco 0.8.2, developers can exclude classes and methods by annotating
* them with a custom annotation with the following properties:
* Fortunately, as of Jacoco 0.8.2, developers can now exclude classes and methods by
* annotating them with a custom annotation that meets the following criteria:
*
* 1- The name of the annotation should include the 'Generated' keyword.
* 2- The retention policy of annotation should be runtime or class.
* 1. The name of the annotation should include the keyword 'Generated'.
* 2. The retention policy of the annotation should be set to 'runtime' or 'class'.
*/
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,4 @@ class DatabaseConfig @JvmOverloads constructor() : java.io.Serializable {
closure.call()
return temp
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import io.github.janbarari.gradle.ExcludeJacocoGenerated
import io.github.janbarari.gradle.analytics.database.MySqlDatabaseConnection
import io.github.janbarari.gradle.analytics.database.SqliteDatabaseConnection
import io.github.janbarari.gradle.analytics.exception.IncompatibleVersionException
import io.github.janbarari.gradle.analytics.exception.NotAccessibleGitTerminalException
import io.github.janbarari.gradle.analytics.exception.PluginConfigNotValidException
import io.github.janbarari.gradle.analytics.exception.GitUnavailableException
import io.github.janbarari.gradle.analytics.exception.PluginConfigInvalidException
import io.github.janbarari.gradle.analytics.reporttask.ReportAnalyticsTask
import io.github.janbarari.gradle.analytics.scanner.ScannerUtils
import io.github.janbarari.gradle.analytics.scanner.BuildScanner
import io.github.janbarari.gradle.extension.isNull
import io.github.janbarari.gradle.extension.whenNotNull
import io.github.janbarari.gradle.extension.whenTrue
Expand All @@ -42,8 +42,10 @@ import org.gradle.build.event.BuildEventsListenerRegistry
import javax.inject.Inject

/**
* A free Gradle plugin for analytics of your projects. Provides unique visual and
* text metrics in HTML format.
* A free Gradle plugin to analyze your project builds. It provides unique visual and text metrics in HTML format.
*
* Copyright © 2022
* @author Mehdi Janbarari (@janbarari)
*/
@ExcludeJacocoGenerated
class GradleAnalyticsPlugin @Inject constructor(
Expand All @@ -52,20 +54,20 @@ class GradleAnalyticsPlugin @Inject constructor(

companion object {
const val PLUGIN_NAME = "gradleAnalyticsPlugin"
const val PLUGIN_VERSION = "1.0.0-beta7"
const val PLUGIN_VERSION = "1.0.0-beta8"
const val OUTPUT_DIRECTORY_NAME = "gradle-analytics-plugin"
}

/**
* Gradle will invoke this function once the plugin is added into the project build script.
*/
override fun apply(project: Project) {
ensureProjectGradleCompatible()
ensureGitTerminalAccessible()
val config = setupPluginConfig(project)
ensureConfigValid(config)
ensureGradleCompatibility()
ensureGitAvailable()
val config = setupConfig(project)
validateConfig(config)
registerTasks(config)
ScannerUtils.setupScannerServices(config, registry)
BuildScanner.setup(config, registry)
}

/**
Expand All @@ -76,22 +78,22 @@ class GradleAnalyticsPlugin @Inject constructor(
* when the Gradle version is not compatible.
*/
@kotlin.jvm.Throws(IncompatibleVersionException::class)
private fun ensureProjectGradleCompatible() {
private fun ensureGradleCompatibility() {
val requiredGradleVersion = ProjectUtils.GradleVersions.V6_1
if (!ProjectUtils.isCompatibleWith(requiredGradleVersion)) {
if (!ProjectUtils.isProjectCompatibleWith(requiredGradleVersion)) {
throw IncompatibleVersionException(requiredGradleVersion.versionNumber)
}
}

/**
* The plugin only works on projects which use Git. This function ensures the Git terminal accessible in project directory.
*/
@kotlin.jvm.Throws(NotAccessibleGitTerminalException::class)
private fun ensureGitTerminalAccessible() {
@kotlin.jvm.Throws(GitUnavailableException::class)
private fun ensureGitAvailable() {
try {
GitUtils.currentBranch()
} catch (e: Throwable) {
throw NotAccessibleGitTerminalException()
throw GitUnavailableException()
}
}

Expand All @@ -100,7 +102,7 @@ class GradleAnalyticsPlugin @Inject constructor(
*
* Note: extension will be initialized after projectsEvaluated(configuration process).
*/
private fun setupPluginConfig(project: Project): GradleAnalyticsPluginConfig {
private fun setupConfig(project: Project): GradleAnalyticsPluginConfig {
return project.extensions.create(
PLUGIN_NAME,
GradleAnalyticsPluginConfig::class.java,
Expand All @@ -117,36 +119,36 @@ class GradleAnalyticsPlugin @Inject constructor(

/**
* Ensure the plugin config inputs are valid.
* @throws io.github.janbarari.gradle.analytics.exception.PluginConfigNotValidException when something is missing or wrong.
* @throws io.github.janbarari.gradle.analytics.exception.PluginConfigInvalidException when something is missing or wrong.
*/
@kotlin.jvm.Throws(PluginConfigNotValidException::class)
@kotlin.jvm.Throws(PluginConfigInvalidException::class)
@Suppress("ThrowsCount")
private fun ensureConfigValid(config: GradleAnalyticsPluginConfig) {
private fun validateConfig(config: GradleAnalyticsPluginConfig) {
config.project.gradle.projectsEvaluated {
config.getDatabaseConfig().local.whenNotNull {
whenTypeIs<SqliteDatabaseConnection> {
if (path.isNull()) {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`path` is missing in local Sqlite database configuration.",
config.project.buildFile
)
}
if (name.isNull()) {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`name` is missing in local Sqlite database configuration.",
config.project.buildFile
)
}
}
whenTypeIs<MySqlDatabaseConnection> {
if (host.isNull()) {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`host` is missing in local MySql database configuration.",
config.project.buildFile
)
}
if (name.isNull()) {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`name` is missing in local MySql database configuration.",
config.project.buildFile
)
Expand All @@ -156,27 +158,27 @@ class GradleAnalyticsPlugin @Inject constructor(
config.getDatabaseConfig().ci.whenNotNull {
whenTypeIs<SqliteDatabaseConnection> {
if (path.isNull()) {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`path` is missing in ci Sqlite database configuration.",
config.project.buildFile
)
}
if (name.isNull()) {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`name` is missing in ci Sqlite database configuration.",
config.project.buildFile
)
}
}
whenTypeIs<MySqlDatabaseConnection> {
if (host.isNull()) {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`host` is missing in ci MySql database configuration.",
config.project.buildFile
)
}
if (name.isNull()) {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`name` is missing in ci MySql database configuration.",
config.project.buildFile
)
Expand All @@ -185,7 +187,7 @@ class GradleAnalyticsPlugin @Inject constructor(
}

config.trackingTasks.contains("reportAnalytics").whenTrue {
throw PluginConfigNotValidException(
throw PluginConfigInvalidException(
"`reportAnalytics` task is forbidden from being tracked.",
config.project.buildFile
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ open class GradleAnalyticsPluginConfig(val project: Project) {

var trackingBranches: Set<String> = setOf()

var excludeModules: Set<String> = setOf()

/**
* Tracing all branches has disabled by default during to the significant drawback
* it creates in the database, especially for temporary branches.
Expand All @@ -58,5 +60,4 @@ open class GradleAnalyticsPluginConfig(val project: Project) {
}

fun getDatabaseConfig(): DatabaseConfig = databaseConfig

}
Loading

0 comments on commit fec4471

Please sign in to comment.