Spoon Gradle Plugin

A gradle plugin to run spoon

License

License

Categories

Categories

Gradle Build Tools Spoon Application Testing & Monitoring Code Analysis
GroupId

GroupId

fr.inria.gforge.spoon
ArtifactId

ArtifactId

spoon-gradle-plugin
Last Version

Last Version

1.4
Release Date

Release Date

Type

Type

jar
Description

Description

Spoon Gradle Plugin
A gradle plugin to run spoon
Project URL

Project URL

https://github.com/SpoonLabs/spoon-gradle-plugin
Project Organization

Project Organization

INRIA
Source Code Management

Source Code Management

https://github.com/SpoonLabs/spoon-gradle-plugin

Download spoon-gradle-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/fr.inria.gforge.spoon/spoon-gradle-plugin/ -->
<dependency>
    <groupId>fr.inria.gforge.spoon</groupId>
    <artifactId>spoon-gradle-plugin</artifactId>
    <version>1.4</version>
</dependency>
// https://jarcasting.com/artifacts/fr.inria.gforge.spoon/spoon-gradle-plugin/
implementation 'fr.inria.gforge.spoon:spoon-gradle-plugin:1.4'
// https://jarcasting.com/artifacts/fr.inria.gforge.spoon/spoon-gradle-plugin/
implementation ("fr.inria.gforge.spoon:spoon-gradle-plugin:1.4")
'fr.inria.gforge.spoon:spoon-gradle-plugin:jar:1.4'
<dependency org="fr.inria.gforge.spoon" name="spoon-gradle-plugin" rev="1.4">
  <artifact name="spoon-gradle-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.inria.gforge.spoon', module='spoon-gradle-plugin', version='1.4')
)
libraryDependencies += "fr.inria.gforge.spoon" % "spoon-gradle-plugin" % "1.4"
[fr.inria.gforge.spoon/spoon-gradle-plugin "1.4"]

Dependencies

compile (2)

Group / Artifact Type Version
fr.inria.gforge.spoon : spoon-core jar 7.0.0
com.android.tools.build : gradle jar 2.3.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Build Status

Spoon gradle plugin

A gradle plugin to run source code transformations using spoon on a project built with Gradle.

Basic usage

To use spoon-gradle-plugin, you need to add the plugin classes to the build script's classpath. To do this, you use a buildscript block. The following example shows how you might do this when the JAR containing the plugin has been published to a local repository:

buildscript {
    repositories {
	   mavenLocal()
       mavenCentral()
    }
    dependencies {
        classpath group: 'fr.inria.gforge.spoon',
		          name: 'spoon-gradle-plugin',
		          version:'1.3'
    }
}

apply plugin: 'java'
apply plugin: 'spoon'

Consequently, when gradle build is run on your project, the source code is first rewritten by spoon before compilation.

Note: This project contains two plugins: spoon and spoon-android. The first one is used to compile java source code and the plugin java is required. The second is used to compile android source code and the plugin com.android.application or com.android.library are required.

How to add processors?

Spoon can use processors to analyze and transform source code.

To add processors, one must:

  1. add a dependency in the buildscript block.
  2. configure spoon.processors (you must specify the full qualified name).

In the example below, we add processor fr.inria.gforge.spoon.processors.CountStatementProcessor and the dependency necessary to locate the processor.

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath group: 'fr.inria.gforge.spoon',
			      name: 'spoon-gradle-plugin',
			      version:'1.3'
        classpath group: 'fr.inria.gforge.spoon',
			      name: 'spoon-processors',
			      version:'1.0-SNAPSHOT'
    }
}

apply plugin: 'java'
apply plugin: 'spoon'

spoon {
    processors = ['fr.inria.gforge.spoon.processors.CountStatementProcessor']
}

How to change source folder?

spoon-gradle-plugin analyzes and transforms the standard sourceSets as follows:

sourceSets {
    main {
        java {
            srcDir 'src/main/project'
        }
    }
}

or for android projects:

android {
	sourceSets {
		main {
			java {
				srcDir 'src/main/project'
			}
		}
	}
}

How to compile original sources?

By default, spoon generate your source code and compile these sources but you can specify at the plugin that you want to compile your original sources with compileOriginalSources sets to true.

spoon {
	compileOriginalSources true
}

Download

To use the plugin, you first clone this repository and install it on your maven local repository.

License

Copyright Inria, all rights reserved.

fr.inria.gforge.spoon
The laboratory for Java source code analysis and transformation using Spoon

Versions

Version
1.4
1.3
1.2
1.1
1.0