Skip to content

Commit 990fca9

Browse files
authored
docs: update usage (#98)
1 parent 9a7b5e8 commit 990fca9

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

README.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,38 +55,57 @@ mvn clean install -DskipTests
5555

5656
### How to use
5757

58-
In order to achieve runtime dependencies introspection with classport, you have to first embedd and then to run the instrospector together with you application.
58+
In order to achieve runtime dependencies introspection with classport, you have to first embed and then to run the instrospector together with you application.
5959

6060
1. Embed
6161
Inside the target project folder.
62+
63+
Add the following profile to the `pom.xml` file of the project you want to embed.
64+
To try out introspection, you should add this to the `pom.xml` file of the project which generates the executable jar (with `Main-Class` in the manifest).
65+
```xml
66+
<profile>
67+
<id>embed</id>
68+
<build>
69+
<plugins>
70+
<plugin>
71+
<groupId>io.github.project</groupId>
72+
<artifactId>classport-maven-plugin</artifactId>
73+
<version>0.1.0-SNAPSHOT</version>
74+
<executions>
75+
<execution>
76+
<id>classport-embed</id>
77+
<goals>
78+
<goal>embed</goal>
79+
</goals>
80+
</execution>
81+
</executions>
82+
</plugin>
83+
</plugins>
84+
</build>
85+
</profile>
86+
```
87+
Then run the following command to embed the dependencies into the project.
6288
```bash
63-
mvn compile io.github.project:classport-maven-plugin:0.1.0-SNAPSHOT:embed
64-
mvn package -Dmaven.repo.local=classport-files -DskipTests -Dmaven.main.skip
89+
mvn clean package -DskipTests -Pembed
6590
```
66-
> Note: `-Dmaven.main.skip` is used to skip the main class compilation and packaging.
67-
> This is necessary because packaging phase writes the `MANIFEST.MF` file into `target/classes` directory which triggers a recompilation of the main class *for the next submodule* in the reactor phase.
68-
> For a single module project, this `-Dmaven.main.skip` is not needed.
69-
> If you do need to compile the main class, you can run `mvn compile` again.
7091

7192
2. Introspect
7293
```bash
73-
java -javaagent:<path-to-classport-agent-jar>=<name-of-the-project>,<path-to-output-dir>,dependency -jar <path-to-jar-of-the-target-app> [optional-args-of-the-target-app]
94+
java -javaagent:classport-instr-agent/target/classport-instr-agent-0.1.0-SNAPSHOT.jar=<name-of-the-project>,<path-to-output-dir>,dependency -jar <path-to-jar-of-the-target-app> [optional-args-of-the-target-app]
7495
```
7596
Note:
7697
- `name-of-the-project` can be any name and it is used to build the name of the output file.
7798
- `path-to-output-dir` must be a path of an existing folder
7899

79100
### Example of usage
80-
Run the following command from the root folder of Classport
101+
Run the following command from the root folder of Classport to try out the example.
102+
Or you may also see the test under [EmbeddingMojoIT.java](./maven-plugin/src/test/java/io/github/project/classport/plugin/it/EmbeddingMojoIT.java).
81103

82104
```bash
83105
cd resources/simple-app-monitoring
84-
mvn clean
85106

86107
# Embed
87-
mvn compile io.github.project:classport-maven-plugin:0.1.0-SNAPSHOT:embed
88-
mvn package -Dmaven.repo.local=classport-files -DskipTests
89-
> single module project so we do not need to skip the main class compilation.
108+
mvn clean package -DskipTests -Pembed
90109

91110
# Introspect
92111
mkdir output

0 commit comments

Comments
 (0)