Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for gradle ecosystem metrics collection #11030

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

amazimbe
Copy link
Contributor

@amazimbe amazimbe commented Nov 29, 2024

What are you trying to accomplish?

Update the Gradle ecosystem to add support for gathering ecosystem metrics.

Anything you want to highlight for special attention from reviewers?

As agreed at standup, in this PR, I'm returning jvm_based_languages as the language name. In addition, NOT-AVAILABLE is being returned for the language and gradle versions as there is no consistent way to extract this data based on the Gradle dependency file alone. In future, we might be able to improve on this but that will have to await the completion of install Gradle on docker images.

How will you know you've accomplished your goal?

  • I'll be able to see Gradle ecosystem metrics in datadog

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@github-actions github-actions bot added the L: java:gradle Maven packages via Gradle label Nov 29, 2024
@amazimbe amazimbe self-assigned this Nov 29, 2024
@amazimbe amazimbe marked this pull request as ready for review November 29, 2024 12:56
@amazimbe amazimbe requested a review from a team as a code owner November 29, 2024 12:56
@amazimbe amazimbe assigned markhallen and unassigned markhallen Nov 29, 2024

module Dependabot
module Gradle
LANGUAGE = "jvm_languages"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Gradle can build non-JVM projects like C++ and JavaScript, is jvm_languages is the right value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, perhaps, I should just use unknown / not available

Copy link
Contributor

@thavaahariharangit thavaahariharangit Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI

To identify the programming language from a Gradle build file, you can look for specific plugins and configurations that are commonly associated with certain languages. Here are some key indicators:

  1. Java: Look for the java plugin.
plugins {
    id 'java'
}
  1. Kotlin: Look for the kotlin plugin.
plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.5.21'
}
  1. Groovy: Look for the groovy plugin.
plugins {
    id 'groovy'
}
  1. Scala: Look for the scala plugin.
plugins {
    id 'scala'
}
  1. Android: Look for the com.android.application or com.android.library plugins.
plugins {
    id 'com.android.application'
}

By examining the plugins section of the build.gradle file, you can determine the primary programming language used in the project.

And for
6. C++

plugins {
    id 'cpp'
}
  1. Javacript
plugins {
    id 'com.github.node-gradle.node' version '3.0.1'
}

If this information is not there then we can say unknown. This is my reading, Nonblocking comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thavaahariharangit can you provide a doc for this, it might be useful for @amazimbe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no plugins.id in the build.gradle file, you can look for other indicators to identify the programming language. Here are some additional clues:

  1. Java: Look for apply plugin: 'java' or dependencies like implementation 'org.springframework.boot:spring-boot-starter'.
  2. Kotlin: Look for apply plugin: 'kotlin' or dependencies like implementation "org.jetbrains.kotlin:kotlin-stdlib".
  3. Groovy: Look for apply plugin: 'groovy' or dependencies like implementation 'org.codehaus.groovy:groovy-all'.
  4. Scala: Look for apply plugin: 'scala' or dependencies like implementation 'org.scala-lang:scala-library'.
  5. Android: Look for apply plugin: 'com.android.application' or apply plugin: 'com.android.library'.

By examining these elements, you can determine the primary programming language used in the project.

JavaScript

Look for:
apply plugin: 'node'
apply plugin: 'com.github.node-gradle.node'
Dependencies like implementation 'org.nodejs:node' or implementation 'com.github.node-gradle:node'

C++

Look for:
apply plugin: 'cpp'
Dependencies like implementation 'org.gradle.cpp:cpp-library'
By examining these elements, you can determine if the project is using JavaScript or C++.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this but will create another PR if I manage to do the parsing consistently and reliably.

@amazimbe amazimbe force-pushed the amazimbe/gradle-metadata branch from fd3b646 to 221d912 Compare December 2, 2024 10:05
@amazimbe amazimbe merged commit f63bebb into main Dec 2, 2024
59 checks passed
@amazimbe amazimbe deleted the amazimbe/gradle-metadata branch December 2, 2024 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: java:gradle Maven packages via Gradle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants