Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: improve getting started #1676

Merged
merged 1 commit into from
Nov 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions doc/first_analysis_processor.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ any elements of the AST (all classes in the Spoon meta model which extends `CtEl
A first implementation of the empty catch processor is:

```java
package fr.inria.gforge.spoon.processors;
// file processors/CatchProcessor.java
package processors;

import org.apache.log4j.Level;
import spoon.processing.AbstractProcessor;
Expand Down Expand Up @@ -69,25 +70,20 @@ all concepts are designed to be instinctive for Java developers.

## Apply the processor

In this "Getting Started", we'll see how we can apply the processor in command line.
First, compile your processor. You can use javac in command line to generate the `.class` file.

First, compile your processor. You can use javac in command line to generate the `.class` file
or Maven to generate the `.jar` file with all of your processors and their dependencies.
javac -cp spoon-core-{{site.spoon_release}}-jar-with-dependencies.jar processors/CatchProcessor.java

You have a processor compiled, you'll apply it on our project. If you are in a Maven or
Gradle project, there are a plugin for these technologies ([here](https://github.com/SpoonLabs/spoon-maven-plugin)
for Maven and [here](https://github.com/SpoonLabs/spoon-gradle-plugin) for Gradle).
You have a processor compiled, you'll apply it on our project.

Second, you must download the latest jar file of Spoon. This archive is available at this [link](https://gforge.inria.fr/frs/download.php/latestzip/86/Spoon-latest.zip).

Execute the archive of Spoon:
Then execute Spoon as follows to analyze all catch blocks in Java files that are in `/path/to/src/of/your/project`:

```bash
$ java -classpath /path/to/binary/of/your/processor.jar:spoon-core-{{site.spoon_release}}-jar-with-dependencies.jar spoon.Launcher -i /path/to/src/of/your/project -p fr.inria.gforge.spoon.processors.CatchProcessor
$ java -classpath /path/to/binary/of/your/processor.jar:spoon-core-{{site.spoon_release}}-jar-with-dependencies.jar spoon.Launcher -i /path/to/src/of/your/project -p processors.CatchProcessor
```

{{site.data.alerts.important}}
1. Specify all dependencies in your classpath. If your processor has dependencies, don't forget to package your processor.jar with all dependencies!
2. Specify spoon in the classpath because we use spoon concepts in our processor.
3. Specify your processors in fully qualified name.
2. Specify your processors in fully qualified name (here `processors.CatchProcessor`).
{{site.data.alerts.end}}