Giter VIP home page Giter VIP logo

gradle-in-action-source's Introduction

Source code for "Gradle in Action" Build Status

Book cover

Building the code

All source code used in the book is based on Gradle 1.7. Please use the checked-in Wrapper to execute the samples. Please be aware that a later version of Gradle might not be compatible with the source code.

The source code is organized into individual chapters. Chapter 1 contains Ant and Maven build scripts. Please refer to the build tool's online manual for instructions to install the runtime and execute the build script. You can find more information here:

Starting with chapter 2, all source code can be run using the Gradle Wrapper which means no runtime will have to be installed. For example to run the "Hello World" build script from chapter 2 open a shell/command prompt and navigate to the directory. You can execute the build script by referencing the Gradle Wrapper command line script and providing the task you would like to run.

Windows:

> cd gradle-in-action-source/chapter02/helloworld-task-doLast
> ../../gradlew.bat helloWorld

*nix:

$ cd gradle-in-action-source/chapter02/helloworld-task-doLast 
$ ../../gradlew helloWorld

Putting it all together

Gradle in Action demonstrates how to implement build logic needed for various stages of a Continuous Delivery pipeline. While the book discusses specific functionality step by step, you might want to see it all put together. You can find the sample To Do application extended by typical project automation functionality (like testing strategies, publishing and deployment logic etc.) in a dedicated repository. Furthermore, you can find an updated version of the To Do application implemented with Spring Boot, built on a declarative Jenkins pipeline and deployed to Heroku in the blog post "Build pipelines with Jenkins 2 by example".

Going further

The book discusses how to integrate third-party functionality by writing custom tasks or plugins. Some of the examples have been developed further and are available as full-fledged binary plugins ready to be used in your own projects.

Unfortunately, I could not cover all topics readers were interested in. Here's a list of example projects that should get you started:

Continuous Integration

Most of the source code listings are automatically executed with the help of the Gradle tooling API. Whenever there's a change to the code, a corresponding job is triggered. Each build works through a list of predefined tasks for each chapter and verifies the expected outcome.

gradle-in-action-source's People

Contributors

bmuschko avatar enil avatar

Stargazers

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

Watchers

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

gradle-in-action-source's Issues

In 2022, can't get examples to work in

First, thank you for writing this book!

Is it possible to run the code examples in a recent version of IntelliJ IDEA? I'm using 2021.3 Ultimate Edition. I'm using the gradle wrapper with the version set (see image below, note that the s is now required unlike a few years ago) as you suggest in your README, and I followed the tips you mentioned in this issue, but I get this output:

11:32 PM	Gradle sync failed: This version of Android Studio requires projects to use Gradle 4.8.1 or newer. This project is using Gradle 1.7.
			Change to minimum versions (plugin 3.2.0, Gradle 4.8.1) and sync project
			Change to latest versions (plugin 7.0.0, Gradle 7.0.2) and sync project
			Open build file (16 s 601 ms)

My settings look like this:

image
image
image
image

Now that it's 2022, should I just give up on getting the code to work, and instead follow the book content as best as possible, following up with something like the Udemy Gradle Masterclass?

gradle build failed

I've been running through gradle in action examples,they don't work,A problem occurred evaluating script.(chapter07 #listing_07_06-test-report-aggregation )

gradle :repositotry:test

Zihuatanejo@localhost listing_07_06-test-report-aggregation (master) $ gradle :repository:test --daemon
:model:compileJava UP-TO-DATE
:model:processResources UP-TO-DATE
:model:classes UP-TO-DATE
:model:jar UP-TO-DATE
:repository:compileJava UP-TO-DATE
:repository:compileGroovy UP-TO-DATE
:repository:processResources UP-TO-DATE
:repository:classes UP-TO-DATE
:repository:compileTestJava

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':repository:testCompileClasspath'.
> Could not resolve org.testng:testng:6.8.
 Required by:
     com.manning.gia:repository:0.1
  > Could not resolve org.testng:testng:6.8.
     > Could not get resource 'https://repo1.maven.org/maven2/org/testng/testng/6.8/testng-6.8.pom'.
        > Could not GET 'https://repo1.maven.org/maven2/org/testng/testng/6.8/testng-6.8.pom'.
           > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve org.codehaus.groovy:groovy:2.0.6.
 Required by:
     com.manning.gia:repository:0.1
  > Could not resolve org.codehaus.groovy:groovy:2.0.6.
     > Could not get resource 'https://repo1.maven.org/maven2/org/codehaus/groovy/groovy/2.0.6/groovy-2.0.6.pom'.
        > Could not GET 'https://repo1.maven.org/maven2/org/codehaus/groovy/groovy/2.0.6/groovy-2.0.6.pom'.
           > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve org.spockframework:spock-core:0.7-groovy-2.0.
 Required by:
     com.manning.gia:repository:0.1
  > Could not resolve org.spockframework:spock-core:0.7-groovy-2.0.
     > Could not get resource 'https://repo1.maven.org/maven2/org/spockframework/spock-core/0.7-groovy-2.0/spock-core-0.7-groovy-2.0.pom'.
        > Could not GET 'https://repo1.maven.org/maven2/org/spockframework/spock-core/0.7-groovy-2.0/spock-core-0.7-groovy-2.0.pom'.
           > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Test report aggregation

The HTML files for both the unit and the integration test are generated into the tests folder but the index file is only linking into the unit tests

Can't get examples working

As I've been running through gradle in action examples using this code, they don't work. I've been using the gradle wrapper, but it complains about:
A problem occurred evaluating script.

java/util/HashMap$Entry

If I try to upgrade to 2.1, then I get this error:
D:\work\todo>gradle wrapper --gradle-version 2.1
:buildSrc:clean
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes
:buildSrc:jar
:buildSrc:assemble
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build
Loading configuration for environment 'test'.

FAILURE: Build failed with an exception.

  • Where:
    Script 'D:\work\todo\gradle\jacoco.gradle' line: 11

  • What went wrong:
    A problem occurred evaluating script.

    Failed to apply plugin [class 'org.ajoberstar.gradle.jacoco.plugins.JacocoPlugin']
    java.lang.String cannot be cast to org.gradle.api.artifacts.Configuration

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.662 secs

D:\work\todo>

Is there any kind of way to migrate forward so I can make it through the examples in your book?

listing_08_11-14-cloudbees-extensions

org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'listing_08_11-14-cloudbees-extensions'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:148)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:59)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:504)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:83)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: groovy.lang.MissingPropertyException: Could not find property 'apiKey' on root project 'listing_08_11-14-cloudbees-extensions'.
at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:94)
at org.gradle.api.internal.project.DefaultProject_Decorated.getProperty(Unknown Source)
at build_59xa6eod6cbsn7ddxx37qy40r$_run_closure1.doCall(/Users/Marshall/Documents/Books/Gradle/Gradle in action/gradle-in-action-source-master/chapter08/listing_08_11-14-cloudbees-extensions/build.gradle:13)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:63)
at org.gradle.api.internal.plugins.ExtensionsStorage$ExtensionHolder.configure(ExtensionsStorage.java:145)
at org.gradle.api.internal.plugins.ExtensionsStorage.configureExtension(ExtensionsStorage.java:69)
at org.gradle.api.internal.plugins.DefaultConvention$ExtensionsDynamicObject.invokeMethod(DefaultConvention.java:207)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_59xa6eod6cbsn7ddxx37qy40r.run(/Users/Marshall/Documents/Books/Gradle/Gradle in action/gradle-in-action-source-master/chapter08/listing_08_11-14-cloudbees-extensions/build.gradle:11)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 32 more

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.