gradle-release icon indicating copy to clipboard operation
gradle-release copied to clipboard

Custom version property

Open Fodoj opened this issue 6 years ago • 7 comments

I tried setting this:

    versionProperties = ['myVersion']

But plugin seems to still require 'version' to be defined:

contains no 'version' property. Expression: 'properties.version'

Is there a way to use custom version property?

Fodoj avatar Jun 07 '18 15:06 Fodoj

Hm for me it works. Is it an error and the build breaks up or just a message? If it's an error it would be nice to get the stacktrace otherwise a debug run would be good to check where that message comes from because it could be possible that something else relies on that property that is not part of the release plugin

Hillkorn avatar Jun 13 '18 12:06 Hillkorn

I figured problem was on git repo hosting side, which resulted in this weird behaviour. Sorry for the noise.

Fodoj avatar Jun 13 '18 12:06 Fodoj

I have the same problem. Maybe I did not understood how versionProperties works.

In my gradle.properties, I am using a custom version property:

mainversion=1.0.1-SNAPSHOT

In my build.gradle I set the version based on this property. Simplified it could look like this:

version = "$mainversion"

I was hoping that it would be possible to configure the release plugin like this:

release {
    versionPropertyFile = 'gradle.properties'
    versionProperties = ['mainversion']
}

But then I get the same error as described here.

> Task :http-request-recorder:unSnapshotVersion FAILED

> Task :release FAILED
Release process failed, reverting back any changes made by Release Plugin.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':http-request-recorder:unSnapshotVersion'.
> [___/gradle.properties] contains no 'version' property. Expression: properties.version

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':http-request-recorder:unSnapshotVersion'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
        at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
        at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.AssertionError: [___/gradle.properties] contains no 'version' property. Expression: properties.version
        at net.researchgate.release.ReleasePlugin.checkPropertiesFile(ReleasePlugin.groovy:278)
        at net.researchgate.release.ReleasePlugin.unSnapshotVersion(ReleasePlugin.groovy:197)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:737)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:712)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
        ... 31 more

As a workaround, I now have a version entry in my gradle.properties:

version=1.0.1-SNAPSHOT
mainversion=1.0.1-SNAPSHOT

and this configuration build.gradle:

release {
    versionPropertyFile = 'gradle.properties'
    versionProperties = ['version', 'mainversion']
}

Thank you in advance for your feedback.

jmini avatar Nov 21 '18 09:11 jmini

True it's a bug https://github.com/researchgate/gradle-release/blob/master/src/main/groovy/net/researchgate/release/ReleasePlugin.groovy#L319

Hillkorn avatar Nov 26 '18 14:11 Hillkorn

@Hillkorn is there an update on this Issue? I tried to use the custom Version property and i get the same Error as jmini.

Roni1993 avatar Mar 05 '19 11:03 Roni1993

@Roni1993 No update on this from my side. But I will reopen this.

Hillkorn avatar Mar 06 '19 09:03 Hillkorn

@Hillkorn do you have any thoughts about what it would take to suport a configurable property name? I skimmed the code and it seems that it makes two assumptions:

  1. That project property is called version
  2. That gradle.properties property is called version

If the plugin did support a configurable version name, would you expect it to be explicitly configured or derived from versionProperties (eg first element)?

I'm currently weighing making a PR against simply adding a dummy version=X redundant entry in my project, that the plugin will keep in sync with the property that the project uses.

akomakom avatar Nov 27 '23 21:11 akomakom