Coder Social home page Coder Social logo

cat-gradle-plugins's Introduction

Build Status Download

cat-gradle-plugins

A collection of reusable gradle plugins. All the plugins are available on MavenCentral and JCenter, so it's easy to embed them in your projects.

Usage

You can utilize every plugin seperately but we recommend to use the same version of every plugin that you are embedding.

So your build.gradle might look like that:

buildscript {
    repositories {
        jcenter() // or mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
    }

    String catGradleVersion = '0.0.17'

    dependencies {
        classpath "cc.catalysts.gradle:cat-gradle-buildinfo-plugin:${catGradleVersion}"
        classpath "cc.catalysts.gradle:cat-gradle-dmuncle-plugin:${catGradleVersion}"
        classpath "cc.catalysts.gradle:cat-gradle-hibernate-plugin:${catGradleVersion}"
        classpath "cc.catalysts.gradle:cat-gradle-less-plugin:${catGradleVersion}"
        classpath "cc.catalysts.gradle:cat-gradle-sass-plugin:${catGradleVersion}"
        classpath "cc.catalysts.gradle:cat-gradle-systemjs-plugin:${catGradleVersion}"
    }
}

Changelog

The latest stable version is 0.0.29

see CHANGELOG for details

List of plugins

BUILDINFO

Generates a class BuildInfo.java that holds information about the current build like version number and build time.

Example:

buildscript {
  dependencies {
    classpath 'cc.catalysts.gradle:cat-gradle-buildinfo-plugin:' + catGradleVersion
  }
}

apply plugin: 'cc.catalysts.buildinfo'

buildinfo {
    packageName = 'cc.catalysts.mproject'
}

DMUNCLE

Analyses your project and reports dependency information to a configured server.

buildscript {
  dependencies {
    classpath 'cc.catalysts.gradle:cat-gradle-dmuncle-plugin:' + catGradleVersion
  }
}

apply plugin: 'cc.catalysts.dmuncle'

dmuncle {
    server = null
    requestTimeout = 100000
}

HIBERNATE

Generates static metamodel classes for Hibernate JPA. The sources will be generated to (default) 'target/generated-sources/hibernate' (extends compileJava task). This folder will be added to the SourceSet. The 'target/generated-sources/hibernate' directory will be deleted when running 'gradle clean'. To activate the generation for a project, just apply the plugin in the build.gradle file. Additionally you can choose the used hibernate version by defining the hibernateVersion variable on the project (or any parent project).

Example:

buildscript {
  dependencies {
    classpath 'cc.catalysts.gradle:cat-gradle-hibernate-plugin:' + catGradleVersion
  }
}

apply plugin: 'cc.catalysts.hibernate'

Example: Change destination directory to something else then the default value and use a specific hibernate Version

ext.hibernateVersion = '4.3.1.Final'

apply plugin: 'cat-hibernate'

hibernate {
    destinationDir 'PATH'
}

LESS

Takes a set of less files and compiles them to css.

Wejbars are supported by extracting all css and less files from them and by providing special global variables:

webjars-<artifactId> contains the base path of the given webjar (webjars/<artifactId>/<artifactVersion>)

Note: As less doesn't support the '.' character in variable names these will be replaced with a '-'. For example org.webjars.npm:imaginary.lib:1.4.9 will produce the variable webjars-imaginary-lib

These variables can be used anywhere in your less files to import other less or css files from any webjar.

For example you can include the twitter bootstrap styles by adding the following line:

@import "@{webjars-bootstrap}/less/bootstrap";

Configuration:

buildscript {
  dependencies {
    classpath 'cc.catalysts.gradle:cat-gradle-less-plugin:' + catGradleVersion
  }
}

apply plugin: 'cc.catalysts.less'

less {
    // The source directory of your less files
    srcDir = new File(project.projectDir, 'src/main/resources/less')
    // The actual less source files, relative to your srcDir
    srcFiles = ["${project.name}.less"]
    // The destination directory which will be treated as a 'resource' folder when the java plugin is present
    destinationDir = new File(project.buildDir, "generated-resources/cat-less")
    // The base path for all generated css files (default path matches webjar convention)
    cssPath = "META-INF/resources/webjars/${project.name}/${project.rootProject.version}"
    // A map of npm dependencies to use - can be used to change versions and add or remove plugins
    npmDependencies = [
        'less'                  : '2.5.3',
        'less-plugin-autoprefix': '1.5.1',
        'less-plugin-clean-css' : '1.5.1'
    ]
    // A list of less plugins to apply - when null then all npmDependencies starting with 'less-plugin-' will be used
    plugins = null
    // A map where the key corresponds to a less plugin name (eg 'clean-css') and the value are the cli arguments to pass to it (eg. '--s0')
    pluginOptions = [:]
    // A list of additional command line arguments to pass to the lessc
    additionalArguments = [
        '--strict-units=on'
    ]
    // A Closure<String> to transform input file names to output file names
    cssFileName = {return it.replace('.less', '.min.css')}
}

Custom Less tasks can also be configured and have access to the same configuration options. If a option is not used the default value will be assumed.

Example for generating an unminified version into the static/css folder:

task unminifiedLess(type: Less) {
    cssPath = 'static/css'
    plugins = ['autoprefix']
}

tasks.less.dependsOn('unminifiedLess')

SASS-SCSS

Takes a set of sass or scss files and compiles them to css.

Wejbars are supported by extracting all css, sass and scss files from them and providing them to you as importable files.

@import "~webjars/bootstrap/sass/bootstrap";

The import statement must follow a special syntax to be recognized as an importable webjar.

  • First it must begin with ~webjars
  • After that there is the name of the webjar (with replaced dots as dashes)
  • After that comes the path to the file INSIDE the webjar

Configuration:

buildscript {
  dependencies {
    classpath 'cc.catalysts.gradle:cat-gradle-sass-plugin:' + catGradleVersion
  }
}
  
apply plugin: 'cc.catalysts.sass'
 
sass {

    // IF the directory `src/main/resources/sass` exists these two settings will be taken by default,
    srcDir = new File(project.projectDir, 'src/main/resources/sass')
    srcFiles = ["${project.name}.sass"]
    
    // ELSE if the the sass directory does not exist AND the directory `src/main/resources/scss` exists
    // these will be the default values
    srcDir = new File(project.projectDir, 'src/main/resources/scss')
    srcFiles = ["${project.name}.scss"]
        
    
    // The destination directory which will be treated as a 'resource' folder when the java plugin is present
    destinationDir = new File(project.buildDir, "generated-resources/cat-sass")
    
    // The base path for all generated css files (default path matches webjar convention)
    cssPath = "META-INF/resources/webjars/${project.name}/${project.rootProject.version}"
    
    // A map of npm dependencies to use - can be used to change versions and add or remove plugins
    npmDependencies = [
        'node-sass': '4.5.3'
    ]
    
    // A list of additional command line arguments to pass to the node-sass compiler
    // Empty by default
    additionalArguments = [ ]
}

SYSTEMJS

Takes all configured files of a configured source folder and creates a systemjs bundle for it.

buildscript {
  dependencies {
    classpath 'cc.catalysts.gradle:cat-gradle-systemjs-plugin:' + catGradleVersion
  }
}

apply plugin: 'cc.catalysts.systemjs'

buildinfo {
    // The source directory of your js files
    srcDir = new File(project.projectDir, 'src/main/resources')
    // A glob pattern to specify which js files to include
    includePath = "**/*.js"
    // The destination directory which will be treated as a 'resource' folder when the java plugin is present
    destinationDir = new File(project.buildDir, "generated-resources/cat-systemjs")
    // The path to where the bundle file will be located
    bundlePath = "META-INF/resources/webjars/${project.name}/${project.rootProject.version}"
    // A map of npm dependencies to use - can be used to change versions
    npmDependencies = [
        'command-line-args': '2.1.4',
        'systemjs-builder' : '0.15.3'
    ]
}

WEBJARS

This feature is considered incubating and may change completely in a future version

This plugin creates a helper class Webjars containing a map which maps from webjar names to artifact information (group, name, version, webjar path).

buildscript {
  dependencies {
    classpath 'cc.catalysts.gradle:cat-gradle-webjars-plugin:' + catGradleVersion
  }
}

apply plugin: 'cc.catalysts.webjars'

webjars {
    // The package to use for the generated 'Webjars' class
    packageName = 'cc.catalysts.gradle'
    // The destination directory which will be treated as a source folder
    destinationDir = new File(project.buildDir, "generated-resources/cat-webjars")
    // a filter closure to customize which resolved artifacts should qualify as webjars
    webjarFilter = { ResolvedArtifact it ->
        return it.moduleVersion.id.group.startsWith('org.webjars')
    }
}

cat-gradle-plugins's People

Contributors

andreasgerstmayr avatar exordian avatar ezylot avatar haraldradi avatar klu2 avatar mangei avatar rknoll avatar tsalzinger avatar wbiller avatar xvinci6 avatar zealin avatar

Stargazers

 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

cat-gradle-plugins's Issues

You can't change configuration 'gwtBuild' because it is already resolved!

Hi,I have set up a multi folder project with build.gradle file as shown in https://github.com/Catalysts/catalysts-gradle-plugins/wiki/cat-gwt ,here is /baseDir/build.gradle

apply plugin: 'cat-gwt'

dependencies {
gwtBuild (
[project(path: ':proj1', configuration: 'gwtCompile')]
)
}

subprojects {
// apply plugin: 'xxx'

sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
}
}

gwt {
modules {
projectX {
modulename = 'cc.catalysts.gwt.example.projectX'
}
}

eclipse {
codeSrvStartupUrl 'http://localhost:8888/index.html'
}
}

but while running the gradle build I get the following error.

D:\Spring3HibernateApp>gradle build
:catalysts-gradle-plugins:compileJava UP-TO-DATE
:catalysts-gradle-plugins:compileGroovy UP-TO-DATE
:catalysts-gradle-plugins:processResources UP-TO-DATE
:catalysts-gradle-plugins:classes UP-TO-DATE
:catalysts-gradle-plugins:jar UP-TO-DATE
:catalysts-gradle-plugins:assemble UP-TO-DATE
:catalysts-gradle-plugins:compileTestJava UP-TO-DATE
:catalysts-gradle-plugins:compileTestGroovy UP-TO-DATE
:catalysts-gradle-plugins:processTestResources UP-TO-DATE
:catalysts-gradle-plugins:testClasses UP-TO-DATE
:catalysts-gradle-plugins:test UP-TO-DATE
:catalysts-gradle-plugins:check UP-TO-DATE
:catalysts-gradle-plugins:build UP-TO-DATE

FAILURE: Build failed with an exception.

  • Where:
    Build file 'D:\Spring3HibernateApp\build.gradle' line: 5

  • What went wrong:
    A problem occurred evaluating root project 'Spring3HibernateApp'.

    You can't change configuration 'gwtBuild' because it is already resolved!

  • 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: 11.901 secs

please help :(

Plugin with id 'cat-gwt' not found placing catalysts-gradle-plugins in buildSrc

While putting catalysts-gradle-plugins to buildSrc of my root project, I get following error

C:\Users\user\Desktop\demopro>gradlew.bat clean
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
: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 UP-TO-DATE

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\user\Desktop\demopro\build.gradle' line: 7

* What went wrong:
A problem occurred evaluating root project 'demopro'.
> Plugin with id 'cat-gwt' not found.

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

BUILD FAILED

Total time: 4.727 secs

C:\Users\user\Desktop\demopro>

My build.gradle is

description = 'demo'

version = '1.0'

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'cat-gwt'

dependencies {
 //classpath group: 'cc.catalysts', name: 'catalysts-gradle-plugins', version: 2.0
 compile 'com.google.gwt:gwt-servlet:2.4.0'
}

unable to resolve class org.gradle.api.inter nal.tasks.testing.DefaultTestTaskReports

I have this problem,when I try to gradlew eclipse in command prompt.Is this the problem of plugin or I am missing something

D:\Tomcat 7.0\webapps\HelloWeb1>gradlew eclipse
:catalysts-gradle-plugins:clean
:catalysts-gradle-plugins:compileJava UP-TO-DATE
:catalysts-gradle-plugins:compileGroovy
startup failed:
D:\Tomcat 7.0\webapps\HelloWeb1\buildSrc\src\main\groovy\cc\catalysts\gradle\plu
gins\grails\GrailsPlugin.groovy: 8: unable to resolve class org.gradle.api.inter
nal.tasks.testing.DefaultTestTaskReports
@ line 8, column 1.
import org.gradle.api.internal.tasks.testing.DefaultTestTaskReports
^

1 error

:catalysts-gradle-plugins:compileGroovy FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileGroovy'.

    Compilation failed; see the compiler error output for details.

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

BUILD FAILED

Total time: 8.232 secs

java.io.File cannot be cast to org.gradle.api.artifacts.Configuration

hi I have been stuck with this problem for a long while

D:\Tomcat 7.0\webapps\HelloWeb1>gradlew eclipse
:catalysts-gradle-plugins:compileJava UP-TO-DATE
:catalysts-gradle-plugins:compileGroovy UP-TO-DATE
:catalysts-gradle-plugins:processResources UP-TO-DATE
:catalysts-gradle-plugins:classes UP-TO-DATE
:catalysts-gradle-plugins:jar UP-TO-DATE
:catalysts-gradle-plugins:assemble UP-TO-DATE
:catalysts-gradle-plugins:compileTestJava UP-TO-DATE
:catalysts-gradle-plugins:compileTestGroovy UP-TO-DATE
:catalysts-gradle-plugins:processTestResources UP-TO-DATE
:catalysts-gradle-plugins:testClasses UP-TO-DATE
:catalysts-gradle-plugins:test UP-TO-DATE
:catalysts-gradle-plugins:check UP-TO-DATE
:catalysts-gradle-plugins:build UP-TO-DATE
:eclipseClasspath FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':eclipseClasspath'.

    java.io.File 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: 7.971 secs

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.