Coder Social home page Coder Social logo

neva-dev / gradle-fork-plugin Goto Github PK

View Code? Open in Web Editor NEW
12.0 5.0 1.0 542 KB

Gradle Fork Plugin - Project generator based on live archetypes (example projects) & interactive gradle.properties file generator

License: Apache License 2.0

Kotlin 93.90% Shell 6.10%
archetype template gradle gui live-archetypes password-encryption maven-archetype properties

gradle-fork-plugin's People

Contributors

github-actions[bot] avatar jean-khechfe-wttech avatar krystian-panek-wttech avatar mierzwid avatar pun-ky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

mierzwid

gradle-fork-plugin's Issues

Cannot use a property if it isn't used in the "config" session

Hi,

I have a property that is used on the controller of other property, like this:

    define("baseDir") {
      defaultValue = "/default/path"
    }
    define("targetPath") {
      enabled = false
      controller {
        value = other("baseDir").value + '/' + other("artifactId").value
      }
    }

The properity "baseDir" isn't used the "config" session, just in the "properties" session.

When I try to run "fork", I get the error Property named 'baseDir' does not exist. This always happen with properties that aren't used in the "config" session. Is there any way to override this behaviour?

Regards,

Rodrigo

Introduce more content manipulating actions

Imagine e.g

fork {
    config {
        cloneFiles()
        // ...
        removeLine("apply from(\"gradle/fork.gradle.kts\")", "/build.gradle.kts") // new action
        removeFile("gradle/fork.gradle.kts") // new action
        copyTemplateFile("README.MD") // will override existing
    }
}

to be able to clean up forking configuration (fork will not be forkable)

NPE in file chooser

Caused by: com.neva.gradle.fork.ForkException: Fork properties GUI dialog cannot be opened!
Please run 'sh gradlew --stop' then try again.
Ultimately run command with '--no-daemon' option.
        at com.neva.gradle.fork.gui.PropertyDialog$Companion.make(PropertyDialog.kt:169)
        at com.neva.gradle.fork.config.Config.promptFillGui(Config.kt:166)
        at com.neva.gradle.fork.config.Config.promptFill(Config.kt:122)
        at com.neva.gradle.fork.config.Config.access$promptFill(Config.kt:21)
        at com.neva.gradle.fork.config.Config$promptedProperties$2.invoke(Config.kt:29)
        at com.neva.gradle.fork.config.Config$promptedProperties$2.invoke(Config.kt:21)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.neva.gradle.fork.config.Config.getPromptedProperties(Config.kt)
        at com.neva.gradle.fork.config.Config.validate(Config.kt:293)
        at com.neva.gradle.fork.config.Config.evaluate(Config.kt:287)
        at com.neva.gradle.fork.tasks.ConfigTask.evaluate(ConfigTask.kt:18)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:49)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:721)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:688)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:539)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:524)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:507)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:258)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:247)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:63)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:34)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:153)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:67)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:41)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:174)
        ... 30 more
Caused by: java.lang.NullPointerException
        at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(WindowsFileChooserUI.java:498)
        at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(WindowsFileChooserUI.java:212)
        at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(WindowsFileChooserUI.java:149)
        at com.neva.gradle.fork.gui.PropertyDialog.<init>(PropertyDialog.kt:112)
        at com.neva.gradle.fork.gui.PropertyDialog$Companion.make(PropertyDialog.kt:163)
        ... 102 more

Properties precedence

the last one has always-win precedence...

expected:

  1. gradle.properties
  2. gradle.user.properties
  3. CMD line -Pkey=value

actual:

  1. gradle.user.properties
  2. gradle.properties
  3. CMD line

actual when setting fork.override=true

  1. gradle.properties
  2. CMD line
  3. gradle.user.properties

Introduce predefined settings task

Imagine

sh gradlew fork -Pfork.config=properties

replaced by just

sh gradlew properties

which will use reserved in-place config named properties

Rule for deleting lines between tags

as of fork config should delete forking related gradle files and contents, dedicated rules for deleting e.g

build.gradle.kts

// fork:start
fork {
    properties {
        /// this lines should not be available in forked project
    }
}
// fork:end

would be nice

Providers for default value, control bugfix

  1. default value should be a callback called as late as it is possible
  2. when controller {} callback is used to assign other field value; such other field value cannot be then changed

Autodecrypt passwords specified in own / user specific properties file

Make Fork decrypt password, so other plugins like GAP don't have to use forkProps extension to pass properties.

When fork generates properties file with password encrypted it adds fp: prefix to them:

fileTransfer.sftp.user=username
fileTransfer.sftp.password={fp:nWVIC40MKSf2ZasfflkOXA==}

knowing the peb template it can decode values on the fly, so build script author don't have to pass through in the build file:

aem {
    fileTransfer {
        sftp {
            user = forkProps["fileTransfer.sftp.user"]
            password = forkProps["fileTransfer.sftp.password"]
        }
    }
}

Bubble up property validation message

image

just "missing or invalid" message is too generic. if possible propagate detailed error message to the exception so be able to easier demystify problems

Post-fork commands

Hi,

Is it possible to execute a command line script inside the forked app's folder, like a git repo initialization? I could do something like fork.finalizedBy gitInit but I don't know how to get the generated folder path.

I also tried the following in 'fork.config' but it didn't work:

action(Action { Runtime.getRuntime().exec("git init") })

Could you help me?

Thanks in advance. Regards!

Introduce `-Pfork.execute` flag

which will be useful for cases when changes from updated TPL need to be applied without updating values already saved on GUI dialog

File in use exception after filling properties

> Task :props FAILED
Build failure
Execution failed for task ':props'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':props'.
> java.nio.file.FileSystemException: C:\Users\krystian.panek\Projects\gradle-aem-multi\gradle.user.properties: Proces nie mo▒e uzyska▒ dost▒pu do pliku, poniewa▒ jest on u▒ywany przez inny proces.

why? when project is open in intellij, it could prevent file saving of 'gradle.user.properties' occassionally

to fix it:

a) close IntelliJ, rerun gradlew props
b) run gradlew --stop then rerun gradlew props

this affects only Windows machines

any ideas how to fix / avoid it?

Providers for default value, control bugfix

  1. default value should be a callback called as late as it is possible
  2. when controller {} callback is used to assign other field value; such other field value cannot be then changed

Encrypt password properties

Design :

  1. implement and use obfuscated (by proguard https://www.guardsquare.com/en/products/proguard ) library that will return hashed encryption passphrase basing on project specific gradle build model details (do not share unobfuscated source code on GH)
  2. provide method fork.property(name) that will just proxy project.findProperty(name) or if property is encrypted (basing on definition #9 #5 ) decrypted value instead of as is (logic similar to https://github.com/etiennestuder/gradle-credentials-plugin ; encrypter with passphrase based on 1) )

sample usage

plugins {
    id ("com.neva.fork")
}

repositories {
    maven { 
        url = uri("http://nexus.xxx.com/groups/private")
        username = fork.prop("nexus.username")
        password = fork.prop("nexus.password")
    }
}

Ability to define default values for properties defined multiple times

There is no way to elegantly define default value for e.g projectGroup. Consider new DSL:

fork {
    config {
        cloneFiles()
        moveFiles([
                "/com/company/x/example": "/{{projectGroup|substitute('.', '/')}}/{{projectName}}",
                "/example": "/{{projectName}}"
        ])
        replaceContents([
                "com.company.x.example": "{{projectGroup}}.{{projectName}}",
                'com.company.x': "{{projectGroup}}",
                "Example": "{{projectLabel}}",
                "example": "{{projectName}}",
        ])
        defineProperties([
                property "projectGroup", "com.company.x"
                property "projectLabel", "Example",
                property "projectName", "example" 

                /* below mostly expected :)
                property "projectName",  { 
                    defaultValue = "example"
                    validator = { !it.value('projectGroup').contains(it.value)) } 
                }
                */
               property "libVersion", { // that property will be used in some template file, not in above sections directly
                    defaultValue = "1.0.0"
                    radio ['1.0.0', '2.00', '3.0.0''] // GUI control type 'radio' instead of default 'textfield'
                    required()
                }
        ])
    }
}

Define a task validating existence of user-specific properties file

Imagine

tasks {
    instanceSetup {
        dependsOn("propsCheck")
    }
}

right now, after cloning a project, we could forget about generating user-specific configuration to run some task

maybe we could introduce separate plugin e.g com.neva.fork.props.check with will allow to run only tasks and props task at first, then after generating gradle.user.properties all others...

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.