Giter Site home page Giter Site logo

walkmod-gradle-plugin's Introduction

walkmod-gradle-plugin

Build Status

This is a walkmod plugin to load the classpath of a gradle project.

Usage

Walkmod >= 2.2.3

You don’t need to do extra work to execute your plugins. However, you can force to execute it before executing any code transformation with the following command.

walkmod add-provider gradle

If you have multiple gradle flavors, you need to specify which flavor is the valid one to use as the classpath of the project as follows:

walkmod add-provider -Dflavor="MYFLAVOR" gradle

In case of using local libraries (that do not belong to the maven local repo), you should specify them manually as follows:

walkmod add-provider -DlocalLibs="[\"libDir/\", \"lib2.jar\"]" gradle

Older versions

  1. Add the walkmod-gradle-plugin into your walkmod.xml as a configuration provider. This component will interpret your classpath accoding your build.gradle and will compile your code.

  2. Add other Walkmod plugins and your transformations that depend on having the classpath resolved.

<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD"  "http://www.walkmod.com/dtd/walkmod-1.1.dtd" >
<walkmod>
  <conf-providers>
    <conf-provider type="gradle"></conf-provider>
  </conf-providers>
  <chain name="main-chain">
    <transformation type="...."/>
  </chain>
</walkmod>

You can apply walkmod-gradle-plugin via walkmod.

$ walkmod apply

Or, you can also check which would be the modified classes typing:

$ walkmod check

Contributing

If you want to hack on this, fork it, improve it and send me a pull request.

To get started using it, just clone it and call mvn install.

walkmod-gradle-plugin's People

Contributors

cal101 avatar rpau avatar rubenaranamorera avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

walkmod-gradle-plugin's Issues

unable to run walkmod checkstyle plugin on android project

On runnning the walkmod apply with the following walkmod.xml, I am Invalid configuration error as below:

<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD" "http://www.walkmod.com/dtd/walkmod-1.1.dtd">
<walkmod>
    <conf-providers>
        <conf-provider type="gradle">
            <param name="flavor">myflavor</param>
        </conf-provider>
    </conf-providers>
    <transformation type="imports-cleaner"/>
    <transformation type="checkstyle"/>
</walkmod>
ERROR [main] - Invalid configuration
java.lang.IllegalArgumentException: character to be escaped is missing
	at java.util.regex.Matcher.appendReplacement(Matcher.java:809)
	at java.util.regex.Matcher.replaceAll(Matcher.java:955)
	at java.lang.String.replaceAll(String.java:2223)
	at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.resolveArtifacts(ClassLoaderConfigurationProvider.java:456)
	at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.getClassPathFiles(ClassLoaderConfigurationProvider.java:342)
	at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.load(ClassLoaderConfigurationProvider.java:535)
	at org.walkmod.impl.DefaultConfigurationAdapter.prepare(DefaultConfigurationAdapter.java:55)
	at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:76)
	at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:81)
	at org.walkmod.WalkModFacade.apply(WalkModFacade.java:330)
	at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
	at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:171)
	at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:196)

Please advice how can I rectify this.

ArrayIndexOutOfBoundsException: 2 on ClassLoaderConfigurationProvider.resolveArtifacts

I'm trying to apply walkmod in an Android project.

walkmod.xml
<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD" "http://www.walkmod.com/dtd/walkmod-1.1.dtd"> <walkmod> <modules> <module>wibmoSDK</module> <module>appvirality</module> <module>mobile</module> <module>wibmosdklib</module> </modules> <conf-providers> <conf-provider type="gradle"/> </conf-providers> <transformation type="imports-cleaner"/> <transformation type="sonar:AddCurlyBrackets"/> <transformation type="sonar:AddSwitchDefaultCase"/> <transformation type="sonar:ArrayDesignatorOnType"/> <transformation type="sonar:CollapsibleIfStatements"/> <transformation type="sonar:DeclarationsShouldUseCollectionInterfaces"/> <transformation type="sonar:LocalVarsShouldComplyWithNamingConvention"/> <transformation type="sonar:PrimitiveInstantiationForToString"/> <transformation type="sonar:RedundantCastsShouldNotBeUsed"/> <transformation type="sonar:RemoveCodeComment"/> <transformation type="sonar:RemoveEmptyMethod"/> <transformation type="sonar:RemoveEmptyStatement"/> <transformation type="sonar:RemoveLiteralBoolean"/> <transformation type="sonar:RemoveUnusedMethodParameters"/> <transformation type="sonar:RemoveUselessImports"/> <transformation type="sonar:RemoveUselessParentheses"/> <transformation type="sonar:RemoveUselessVariables"/> <transformation type="sonar:StaticInitializedFieldToFinal"/> <transformation type="sonar:StringCheckOnLeft"/> <transformation type="sonar:UseCollectionIsEmpty"/> <transformation type="sonar:UseStringEquals"/> <transformation type="sonar:VariableImmediatelyReturned"/> </walkmod>

Output is
ERROR [main] - Invalid configuration java.lang.ArrayIndexOutOfBoundsException: 2 at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.resolveArtifacts(ClassLoaderConfigurationProvider.java:442) at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.getClassPathFiles(ClassLoaderConfigurationProvider.java:342) at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.load(ClassLoaderConfigurationProvider.java:535) at org.walkmod.impl.DefaultConfigurationAdapter.prepare(DefaultConfigurationAdapter.java:55) at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:76) at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:81) at org.walkmod.WalkModFacade.apply(WalkModFacade.java:330) at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40) at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:171) at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:196)

Is flavor mandatory for Android projects?

I'm trying to apply walkmod in an Android project that does not have flavors specified in its gradle configuration.
I've added this plugin as follows:

walkmod add-provider gradle

However, I'm getting the following error after running apply -e:

[...]
BUILD SUCCESSFUL

Total time: 3.867 secs
ERROR [main] - Invalid configuration
org.walkmod.conf.ConfigurationException: Please, select one flavour with the command: walkmod add-provider -Dflavor="YOUR_FLAVOR" gradle
        at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.getClassPathFiles(ClassLoaderConfigurationProvider.java:313)
        at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.load(ClassLoaderConfigurationProvider.java:535)
        at org.walkmod.impl.DefaultConfigurationAdapter.prepare(DefaultConfigurationAdapter.java:55)
        at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:76)
        at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:81)
        at org.walkmod.WalkModFacade.apply(WalkModFacade.java:330)
        at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
        at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:171)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:196)

Running with Android project

I'm trying to apply walkmod to an Android project.
It builds with success but when I apply walkmod it fails:

Total time: 7.15 secs
Missing property storeFile
ERROR [main] - Invalid configuration
java.lang.NumberFormatException: For input string: "'android-23'"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:569)
        at java.lang.Integer.parseInt(Integer.java:615)
        at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.getCompileAndroidSDKVersion(ClassLoaderConfigurationProvider.java:245)
        at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.getClassPathFiles(ClassLoaderConfigurationProvider.java:332)
        at org.walkmod.gradle.providers.ClassLoaderConfigurationProvider.load(ClassLoaderConfigurationProvider.java:535)
        at org.walkmod.impl.DefaultConfigurationAdapter.prepare(DefaultConfigurationAdapter.java:55)
        at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:76)
        at org.walkmod.conf.ConfigurationManager.<init>(ConfigurationManager.java:81)
        at org.walkmod.WalkModFacade.apply(WalkModFacade.java:330)
        at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
        at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:171)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:196)

Apparently the error seems to be project specific, but I am able to build the project, which makes me believe there's something wrong when I run Walkmod.

Here's my procedure:

walkmod add java-formatter
walkmod add-provider gradle
walkmod apply -e

Any idea?

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.