在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):SpoonLabs/spoon-maven-plugin开源软件地址(OpenSource Url):https://github.com/SpoonLabs/spoon-maven-plugin开源编程语言(OpenSource Language):Java 99.9%开源软件介绍(OpenSource Introduction):Spoon-maven-pluginSpoon-maven-plugin is a maven plugin for performing code analysis or transformation during build. It can be used for instance:
To report an issue, please use the main Spoon issue tracker: https://github.com/INRIA/spoon/issues. GoalsThe plugin provided two goals:
Please note that the two goals take exactly the same arguments and configuration.
The only change is that Basic usageTo use spoon-maven-plugin, you need to declare it on the The usage below is the minimum to execute the plugin and run spoon on your project. <build>
<plugins>
<plugin>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-maven-plugin</artifactId>
<version>LATEST</version><!-- replace LATEST by the value of the badge at the top of the README -->
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> Consequently, when How to add processors?Spoon can use processors to analyse and transform source code. To add processors, one must:
In the example below, we add processor <configuration>
<processors>
<processor>
fr.inria.gforge.spoon.processors.CountStatementProcessor
</processor>
</processors>
</configuration>
<dependencies>
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-processors</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies> How to pass properties to a processor?Spoon allow to pass custom properties to the processor you want to use, directly in the For passing properties, one must:
For example, let us consider the following Processor that changes the name of a specific class. The usage of package my.app.pkg;
import spoon.processing.AbstractProcessor;
import spoon.processing.Property;
import spoon.reflect.declaration.CtClass;
public class ProcessorWithProperty extends AbstractProcessor<CtClass> {
@Property
String oldClassName;
@Property
String newClassName;
@Override
public void process(CtClass element) {
if (element.getSimpleName().equals(this.oldClassName)) {
element.setSimpleName(this.newClassName);
}
}
} Then the following configuration sets the processor's fields: <plugin>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-maven-plugin</artifactId>
<configuration>
<processors>
<processor>my.app.pkg.ProcessorWithProperty</processor>
</processors>
<processorProperties>
<processorProperty>
<name>my.app.pkg.ProcessorWithProperty</name>
<properties>
<property>
<name>oldClassName</name>
<value>App</value>
</property>
<property>
<name>newClassName</name>
<value>NewName</value>
</property>
</properties>
</processorProperty>
</processorProperties>
</configuration>
</plugin> Please note that you have to specify for which processor the properties should be used with the <value>["one","two","three","value containing a, comma"]</value> Maps and objects are created like this: <value>{"one":1,"two":2,"three":"a value with a,comma"}</value> How to change source and output folder?By default, spoon-maven-plugin considers the source folders configured in the pom.xml.
Input folders are configured with two parameters: 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 the tag How to specify a custom version for Spoon?Spoon maven plugin defines a default value for spoon's version but you can override it to another one. For example, if you would like the version 2.4 of spoon and not the version 3.0, you must add the dependency below. <plugin>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</plugin> How to make the build fail?If you want to use a custom Processor for assessing properties (checkstyle-like, architectural rule checking, pattern checking, etc) and make the build fail if those properties are not verified, throw a How to analyze the plugin execution?The plugin creates some reports about its context and the execution of spoon on your project. These reports are available according to your definition of the plugin.
How to skip generated sources?If you want Spoon to not pass generated sources as input, just provide the following configuration: <plugin>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-maven-plugin</artifactId>
<version>LATEST</version>
<configuration>
<skipGeneratedSources>true</skipGeneratedSources>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin> or in command line: It's also possible to skip the plugin execution using <plugin>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin> or from command line using How to set Spoon in NOCLASSPATH mode?Add Command-line usageIf you add the following to your <pluginGroups>
<pluginGroup>fr.inria.gforge.spoon</pluginGroup>
</pluginGroups> Then, the plugin is automatically discovered (through prefix resolution), and you can simply run Releases
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论