gradle

package
v1.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrFmtFailedToUpdateProps = `failed to update gradle.properties: %w"`
)
View Source
const (
	ErrFmtMetadataWrongOS = "no applicable metadata found with compatible OS"
)
View Source
const (
	FmtErrorEnableForGradle = "adding Gradle plugins failed: %w"
)
View Source
const GradleConfigCacheMetadataPath = "gradle-config-cache-metadata.json"

Variables

View Source
var ActivateGradleCmd = &cobra.Command{
	Use:   "gradle",
	Short: "Activate Bitrise Plugins for Gradle",
	Long: `Activate Bitrise Plugins for Gradle.
This command will:

- Create a ~/.gradle/init.d/bitrise-build-cache.init.gradle.kts file with the necessary configs. This file will be overwritten.
- Create a ~/.gradle/gradle.properties file with org.gradle.caching=true when adding the caching plugin.

The gradle.properties file will be created if it doesn't exist.
If it already exists a "# [start/end] generated-by-bitrise-build-cache" block will be added to the end of the file.
If the "# [start/end] generated-by-bitrise-build-cache" block is already present in the file then only the block's content will be modified.
`,
	SilenceUsage: true,
	RunE: func(cmd *cobra.Command, _ []string) error {
		logger := log.NewLogger()
		logger.EnableDebugLog(common.IsDebugLogMode)
		logger.TInfof("Activate Bitrise plugins for Gradle")

		gradleHome, err := pathutil.NewPathModifier().AbsPath(gradleHomeNonExpanded)
		if err != nil {
			return fmt.Errorf("expand Gradle home path (%s), error: %w", gradleHome, err)
		}

		allEnvs := utils.AllEnvs()

		if err := ActivateGradleCmdFn(
			logger,
			gradleHome,
			allEnvs,
			activateGradleParams.TemplateInventory,
			func(
				inventory gradleconfig.TemplateInventory,
				path string,
			) error {
				return inventory.WriteToGradleInit(
					logger,
					path,
					utils.DefaultOsProxy{},
					gradleconfig.GradleTemplateProxy(),
				)
			},
			gradleconfig.DefaultGradlePropertiesUpdater(),
		); err != nil {
			return fmt.Errorf("activate plugins for Gradle: %w", err)
		}

		logger.TInfof("✅ Bitrise plugins activated")

		return nil
	},
}

ActivateGradleCmd represents the `gradle` subcommand under `activate`

View Source
var (
	FmtErrorGradleVerification = "adding Gradle plugins failed: %w"
)

Functions

func ActivateGradleCmdFn

func ActivateGradleCmdFn(
	logger log.Logger,
	gradleHomePath string,
	envProvider map[string]string,
	templateInventoryProvider func(log.Logger, map[string]string, bool) (gradleconfig.TemplateInventory, error),
	templateWriter func(gradleconfig.TemplateInventory, string) error,
	updater gradleconfig.GradlePropertiesUpdater,
) error

func EnableForGradleCmdFn

func EnableForGradleCmdFn(logger log.Logger, gradleHomePath string, envProvider map[string]string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL