Giter VIP home page Giter VIP logo

build-server-for-gradle's Introduction

Build Server for Gradle

An implementation of the Build Server Protocol for Gradle.

Requirement

JDK 17 or higher is required to build and launch the Build Server for Gradle.

Supported Requests

Following BSP requests are supported in the current implementation:

  • build/initialize
  • build/initialized
  • build/shutdown
  • build/exit
  • buildTarget/sources
  • buildTarget/resources
  • buildTarget/outputPaths
  • buildTarget/dependencyModules
  • buildTarget/dependencySources
  • buildTarget/compile
  • buildTarget/cleanCache
  • buildTarget/javacOptions
  • buildTarget/scalacOptions
  • buildTarget/test
  • workspace/buildTargets
  • workspace/reload

Architecture

See ARCHITECTURE.md

Launch the Build Server for Gradle

Specify the Plugin Location

The main class of the build server is com.microsoft.java.bs.core.Launcher. When you launch the server, you need to specify the location of the Gradle plugin via the system property plugin.dir. By default, you will find the plugin jar at server/build/libs/plugins/plugin.jar after building the project.

Preferences

A Preferences object can be put into the data field of the build/initialize request for customization. Please check the comments in the code for the meaning of each preference.

Transport Method

The Gradle Build Server supports two types of transport methods: standard input/output and named pipe (unix socket). By default, the server uses the standard input/output transport if no arguments are specified.

To use the named pipe (unix socket) transport, start the server with the argument --pipe=<pipeName>. If the --pipe= option is provided but pipeName left empty, the server defaults to using the standard input/output transport.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Please check CONTRIBUTING.md for more details about how to setup and develop the project.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Telemetry

The Build Server for Gradle will not send telemetry by itself. But it will send telemetry event to its client. If you don't want this behavior, set the system property disableServerTelemetry.

build-server-for-gradle's People

Contributors

jdneo avatar arthurm1 avatar microsoftopensource avatar tanish-ranjan avatar donat avatar jiaaming avatar microsoft-github-operations[bot] avatar

Stargazers

Jonathan Bluett-Duncan avatar Stefano Zanella avatar Igor avatar Max Andreola avatar Harald Weiner avatar Vaidotas Valuckas avatar tuyucheng avatar Ólafur Páll Geirsson avatar Taketoday avatar  avatar Wilfried avatar  avatar ChenRenJie avatar DazeCake avatar Denis Muriungi avatar Max Fröhlich avatar Chris Paleopanos avatar Jesper Skov avatar Oleg Nenashev avatar Antonio Fuller avatar Imaginary Stargazer avatar Nikola Stanković avatar Martin Wittlinger avatar Ashwin Jayaprakash avatar Antonio Muñoz avatar Josh Albrecht avatar  avatar Simon Verhoeven avatar  avatar Christoph avatar Siarhei avatar Ibragimov Ruslan avatar 東 avatar Mercy Ma avatar justwe! avatar Bingerz avatar Anton Sviridov avatar Frank Thomas avatar Jinbo Wang avatar  avatar riag avatar gaurav patel avatar Gayan Perera avatar fwcd avatar Pablo Baxter avatar Rashid Almheiri avatar Richard Willis avatar Rome Li avatar  avatar

Watchers

Frank Thomas avatar James Cloos avatar Oleg Nenashev avatar  avatar  avatar .NET Foundation Contribution License Agreements avatar  avatar  avatar

build-server-for-gradle's Issues

Improve support for Android intermediate generated sources

Android generates a lot of intermediate sources such as AIDL, Render script, C/CPP, etc. Unfortunately AGP doesn't provide any APIs to retrieve these files. R.jar is one of these intermediate sources which is crucial for Android development so as a workaround in #173 I have retrieved the file using the process task for the build variant however, in some cases the task may not be registered during the sync in which case the dependency for R.jar is not provided.

Support debug test.

@jdneo I think Metals used debugSessionStart but for DebugSessionParamsDataKind used the same data kinds we use for tests e.g. scala-test-suites-selection and scala-test.

What's kind of interesting is that different clients might want different debug adapters....

Metals is primarily for Scala development so it uses https://github.com/scalacenter/scala-debug-adapter
For Kotlin there is https://github.com/fwcd/kotlin-debug-adapter
Java has https://github.com/microsoft/java-debug

I imagine the Java one is good enough for all but it would be handy to be able to specify the type in the BSP command and have the build server kick start the relevant one. Another thing to propose to add to BSP spec.

Originally posted by @Arthurm1 in #144 (comment)

java.lang.NoClassDefFoundError: org.gradle.api.internal.file.copy.CopySpecImpl

Caused by: java.lang.NoClassDefFoundError: org.gradle.api.internal.file.copy.CopySpecImpl
	at com.trigonic.gradle.plugins.rpm.RpmPlugin.class$(RpmPlugin.groovy)
	at com.trigonic.gradle.plugins.rpm.RpmPlugin.$get$$class$org$gradle$api$internal$file$copy$CopySpecImpl(RpmPlugin.groovy)
	at com.trigonic.gradle.plugins.rpm.RpmPlugin.apply(RpmPlugin.groovy:34)
	at com.trigonic.gradle.plugins.rpm.RpmPlugin.apply(RpmPlugin.groovy)
	at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:43)
	at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
	at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:190)
	at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:54)
	at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:285)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
	at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:170)
	at org.gradle.internal.code.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
	at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:169)
	at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:148)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:161)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:43)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:98)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:184)
	at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:49)
	at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:37)
	at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
	at build_6qmpmgvrqkfckjn21q7dabzl6.run(<REDACTED: user-file-path>:1)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
	... 172 more
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.gradle.api.internal.file.copy.DefaultCopySpec(org.gradle.api.internal.file.DefaultFileCollectionFactory, org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator, org.gradle.api.tasks.util.internal.PatternSets$PatternSetFactory)
	at org.gradle.internal.classpath.intercept.DefaultCallSiteDecorator$DecoratingCallSite.access$401(DefaultCallSiteDecorator.java:156)
	at org.gradle.internal.classpath.intercept.DefaultCallSiteDecorator$DecoratingCallSite$4.callOriginal(DefaultCallSiteDecorator.java:210)
	at org.gradle.internal.classpath.intercept.DefaultCallSiteDecorator$1.doIntercept(DefaultCallSiteDecorator.java:69)
	at org.gradle.internal.classpath.intercept.DefaultCallSiteDecorator$DecoratingCallSite.callConstructor(DefaultCallSiteDecorator.java:207)
	at com.netflix.gradle.plugins.packaging.ProjectPackagingExtension.<init>(ProjectPackagingExtension.groovy:49)
	at com.netflix.gradle.plugins.packaging.ProjectPackagingExtension_Decorated.<init>(Unknown Source)
	at <REDACTED: user-file-path>(DirectConstructorHandleAccessor.java:62)
	at org.gradle.internal.instantiation.generator.AsmBackedClassGenerator$InvokeConstructorStrategy.newInstance(AsmBackedClassGenerator.java:2105)
	at org.gradle.internal.instantiation.generator.AbstractClassGenerator$GeneratedClassImpl$GeneratedConstructorImpl.newInstance(AbstractClassGenerator.java:528)
	at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.doCreate(DependencyInjectingInstantiator.java:64)
	... 216 more

Improve the performance of the server

The discussion was originally raised at #113 (comment)

What I do think is that this data might have to be cached. Have you tried the plugin on a big project? e.g. Gradle itself. It takes about a minute to respond to build/initialize (which I think should be instant and is slow because the source sets are queried in response to this request but not yet needed). Then, after a compile, the source sets are all queried again. It would be good to delay the building of the sourcesets until the client requests them and do they need to be built again after every compile?

ANDROID_HOME fallback logic

Android Components to be used by an Android project is configured via ANDROID_HOME environment variable. If the property doesn't exist then we are not providing the dependency in #173. This implementation can be improved via fallback logic similar to what we did for JAVA_HOME in #165

Add support for Additional Languages

This initiative will focus on adding support for all the Gradle Supported Languages that are currently unsupported.

There were recent initiatives for Kotlin, Groovy & Scala and this issue will focus on extending the support to other Gradle Supported Languages such as C/C++ and Javascript.

Related Links for more information :

https://gradle.github.io/community/events/gsoc/2024/gradle-build-server-devx/
https://gitlab.eclipse.org/eclipsefdn/emo-team/gsoc-at-the-ef/-/issues/5

Support early version of Gradle protobuf plugin

The early version of protobuf Gradle plugin does not adds its generated java sources into the java source set. To make them be compiled correctly. The plugin add them as the input of the compileJava task. See:

https://github.com/google/protobuf-gradle-plugin/blob/3f28b0fc307293b86f267e71a7d1de9a8e564095/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy#L117-L119

Because the generated java files are not in the java source set, this makes some trouble to get all the source roots from the customized plugin. To mitigate this issue, one possible solution is to infer the source roots according to the input of the compileJava task:

project.getTasks().getByName("compileJava").getInputs()

And then find all the common ancestor folders - If the current file path does not belong to a source root. Get the source root according to the files package declaration, and add into the source root set.

Support Cancellation

Investigte how to add more language/framework support

Today, the Gradle build server only supports pure Java project, while in the real world, Kotlin/Groovy/Android project may also be built by Gradle. So, we need to figure out a contribution point that allow different Gradle plugins to contribute their own build targets.

Action required: migrate or opt-out of migration to GitHub inside Microsoft

Migrate non-Open Source or non-External Collaboration repositories to GitHub inside Microsoft

In order to protect and secure Microsoft, private or internal repositories in GitHub for Open Source which are not related to open source projects or require collaboration with 3rd parties (customer, partners, etc.) must be migrated to GitHub inside Microsoft a.k.a GitHub Enterprise Cloud with Enterprise Managed User (GHEC EMU).

Action

✍️ Please RSVP to opt-in or opt-out of the migration to GitHub inside Microsoft.

❗Only users with admin permission in the repository are allowed to respond. Failure to provide a response will result to your repository getting automatically archived.🔒

Instructions

Reply with a comment on this issue containing one of the following optin or optout command options below.

✅ Opt-in to migrate

@gimsvc optin --date <target_migration_date in mm-dd-yyyy format>

Example: @gimsvc optin --date 03-15-2023

OR

❌ Opt-out of migration

@gimsvc optout --reason <staging|collaboration|delete|other>

Example: @gimsvc optout --reason staging

Options:

  • staging : This repository will ship as Open Source or go public
  • collaboration : Used for external or 3rd party collaboration with customers, partners, suppliers, etc.
  • delete : This repository will be deleted because it is no longer needed.
  • other : Other reasons not specified

Need more help? 🖐️

Code Documentation (JavaDocs)

It seems as of now, most of the javaDocs have been added just to prevent checkstyle warnings and does not provide the purpose of the given classes or methods clearly.

Build for Java 8

Since Gradle can run on Java 8 and so do some BSP clients, it would be good to build the plugin/server/model for java 8

Currently the project requires Java 17 but I think there are only a few instances of use of java syntax > version 8 and these could be easily changed.

Provide an easy way to create BSP Connection Details

I'd like to experiment with this project in combination with Scala Steward to extract dependencies from Gradle builds (scala-steward-org/scala-steward#2640). Other BSP server implementations provide a way to create BSP Connection Details so that BSP clients can launch the server easily. For example, connection details for bazel-bsp can be created with Coursier in a single command: cs launch org.jetbrains.bsp:bazel-bsp:<version> -M org.jetbrains.bsp.bazel.install.Install. For using BSP in Scala Steward I've collected how different build servers create connection details here. It would be nice if the Build Server for Gradle would also have a simple command to create connection details so that I can experiment with it in Scala Steward.

Revisit the logic to set the java source/target compatibility

Full context can be found here: redhat-developer/vscode-java#3721

In short, simply check the compilation options may have some issue for some cases, An example is the project in the linked issue.

User can set the source level to 17, and target level to 8. Meanwhile, use [--release, 8] as the compilation arguments. Normally, this should fail during compilation. But the project uses a annotation processor to make it work.

Which says, maybe we should just simply get the source compatibility from the property, not infer it from the compilation options?

@Arthurm1, WDYT?

Developer documentation

This repository is currently missing developer documentation to assist anyone trying to utilize Gradle Build Server.
This may contain:

  • information about implemented features in GBS and their limitations (if any)
  • steps for troubleshooting
  • diagrams and examples

Action required: self-attest your goal for this repository

It's time to review and renew the intent of this repository

An owner or administrator of this repository has previously indicated that this repository can not be migrated to GitHub inside Microsoft because it is going public, open source, or it is used to collaborate with external parties (customers, partners, suppliers, etc.).

Action

👀 ✍️ In order to keep Microsoft secure, we require repository owners and administrators to review this repository and regularly renew the intent to either opt-in or opt-out of migration to GitHub inside Microsoft which is specifically intended for private or internal projects.

❗Only users with admin permission in the repository are allowed to respond. Failure to provide a response will result to your repository getting automatically archived. 🔒

Instructions

❌ Opt-out of migration

If this repository can not be migrated to GitHub inside Microsoft, you can opt-out of migration by replying with a comment on this issue containing one of the following optout command options below.

@gimsvc optout --reason <staging|collaboration|delete|other>

Example: @gimsvc optout --reason staging

Options:

  • staging : My project will ship as Open Source
  • collaboration : Used for external or 3rd party collaboration with customers, partners, suppliers, etc.
  • delete : This repository will be deleted because it is no longer needed.
  • other : Other reasons not specified

✅ Opt-in to migrate

If the circumstances of this repository has changed and you decide that you need to migrate, then you can specify the optin command below. For example, the repository is no longer going public, open source or require external collaboration.

@gimsvc optin --date <target_migration_date in mm-dd-yyyy format>

Example: @gimsvc optin --date 03-15-2023

Click here for more information about optin and optout command options and examples

Opt-in

@gimsvc optin --date <target_migration_date>

When opting-in to migrate your repository, the --date option is required followed by your specified migration date using the format: mm-dd-yyyy

@gimsvc optin --date 03-15-2023

Opt-out

@gimsvc optout --reason <staging|collaboration|delete|other>

When opting-out of migration, you need to specify the --reason.

  • staging
    • My project will ship as Open Source
  • collaboration
    • Used for external or 3rd party collaboration with customers, partners, suppliers, etc.
  • delete
    • This repository will be deleted because it is no longer needed.
  • other
    • Other reasons not specified

Examples:

@gimsvc optout --reason staging

@gimsvc optout --reason collaboration

@gimsvc optout --reason delete

@gimsvc optout --reason other

Need more help? 🖐️

The compile of build action

We introduced the build action to solve composite build in #154. There is a problem that the build action class is in the server project, which is compiled by jdk 17. But in real, the build action class runs inside the gradle daemon, so if the gradle daemon is not running on jdk >= 17, error like Unsupported class file major version 61 will be thrown.

Looks like we should move GetSourceSetsAction into the model module.

I guess this is something we need to do before the parallel work @Arthurm1. I'll raise a PR soon.

Enhance Gradle BSP by implementing the BSP requests that are currently unsupported

In order to provide extensive feature support for Gradle Projects, we will enhance the Gradle Build Server by implementing all the necessary BSP requests that are currently unsupported.

BuildTargetRun
BuildTargetTest
DebugSessionStart
BuildTargetInverseSources

Related Links for more information :

https://gradle.github.io/community/events/gsoc/2024/gradle-build-server-devx/
https://gitlab.eclipse.org/eclipsefdn/emo-team/gsoc-at-the-ef/-/issues/5

Support for different types of Android projects

There are various kinds of projects that come under Android development such as Application, Library, Instant App, Dynamic Modules, Android Test, etc. I have added support for the most commonly used projects - Application and Library in #173 but the current implementation may require further enhancements to support other kinds of projects.

Reconsider to extend the JvmBuildTarget

Currently the definition of JvmBuildTarget is:

export interface JvmBuildTarget {
  /** Uri representing absolute path to jdk
   * For example: file:///usr/lib/jvm/java-8-openjdk-amd64 */
  javaHome?: URI;

  /** The java version this target is supposed to use.
   * For example: 1.8 */
  javaVersion?: string;
}

We can use javaHome to be the JDK path used to launch the project, and javaVersion to be the version of javaHome.

This implies that it is the server's responsibility to search the proper JDK to launch the Gradle daemon.

Based on that, add following fields:

  • sourceCompatibility - source level
  • targetCompatibility - target level

    Note that, sourceCompatibility and targetCompatibility might be different values so we can not use javaVersion to represent them both.

  • compileArgs - arguments used for compilation.

@testforstephen WDYT?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.