0

I want to use jQAssistant for our team. I installed it according to https://101.jqassistant.org/setting-up-a-team-server/index.html , so I have an external Neo4j store that is running independently of jQAssistant.

I would like to scan our software during the nightly build and to have the most recent information. So my idea was to use a reset before the nightly build:

<!-- Use this profile to reset the jQAssistant store (database) -->
<profile>
  <id>jqassistant-reset</id>
  <build>
    <plugins>
      <plugin>
        <groupId>com.buschmais.jqassistant</groupId>
        <artifactId>jqassistant-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>reset-store</id>
            <phase>clean</phase>
            <goals>
              <goal>reset</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

And then I would go through every Maven module and scan it:

  <pluginManagement>
    <plugin>
      <groupId>com.buschmais.jqassistant</groupId>
      <artifactId>jqassistant-maven-plugin</artifactId>
      <version>1.9.1</version>
      <configuration>
        <store>
          <uri>bolt://my-neo4j-store.com:7687</uri>
          <username>neo4j</username>
          <password>reallysecret</password>
          <encryption>false</encryption>
        </store>
        <configuration>
          <resetStore>false</resetStore>
        </configuration>
        <continueOnError>true</continueOnError>
      </configuration>
    </plugin>
  </pluginManagement>

...


<!-- Use this profile to gather information using jQAssistant -->
<profile>
  <id>jqassistant</id>
  <build>
    <plugins>
      <plugin>
        <groupId>com.buschmais.jqassistant</groupId>
        <artifactId>jqassistant-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>scan-software</id>
            <phase>package</phase>
            <goals>
              <goal>scan</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

However, I see confusing log messages:

[INFO] --- jqassistant-maven-plugin:1.9.1:scan (scan-software) @ foobar ---
[INFO] Scanning for jQAssistant plugins...
[INFO] [Asciidoc Report, CDI, Common, Core Analysis, Core Report, EJB3, GraphML, GraphQL, JAX-RS, JPA 2, JSON, JUnit, Java, Java EE 6, Maven 2 Repository, Maven 3, OSGi, RDBMS, Spring, TestNG, Tycho, XML, YAML].
[INFO] Connecting to store at 'bolt://my-neo4j-store.com:7687' (username=neo4j)
Jul 12, 2021 9:46:59 AM org.neo4j.driver.internal.logging.JULogger info
INFORMATION: Direct driver instance 839477204 created for server address my-neo4j-store.com:7687
[INFO] Resetting store.
[INFO] Reset finished (removed 0 nodes, 0 relations).
[INFO] Entering /foobar/target/classes
[INFO] Leaving /foobar/target/classes (70 entries, 307558 ms)
[INFO] Entering /foobar/target/test-classes
[INFO] Leaving /foobar/target/test-classes (70 entries, 1422 ms)
[INFO] Entering /foobar/target/surefire-reports
[INFO] Leaving /foobar/target/surefire-reports (46 entries, 1127 ms)

I don't understand why I'm seeing Resetting store. although I have switched this off in the configuration.

However, what's more confusing for me is that when starting the Maven build again, I see this:

[INFO] Resetting store.
[INFO] Reset finished (removed 0 nodes, 0 relations).

I just filled the store with the first build, and now in the second build, the plugin tells me that it resetted the store, but didn't remove any nodes or relations.

Could someone please explain how I could achieve what I'm trying to do?

eerriicc
  • 1,124
  • 4
  • 17
  • 29
  • The answer to the question is probably more related to Maven and plugin configuration than jQAssistant itself. Therefore the question: how do you run the configured setup, i.e. which goal or lifecycle phase are you triggering? In other words: What's your Maven command line? – Dirk Mahler Jul 13 '21 at 14:19
  • Hi Dirk! Sorry to keep you waiting, I was ill for some days... Anyway, my idea was to clean before scanning the software using `mvn clean -Pjqassistant-reset` and then scan using `mvn clean package -Pjqassistant` . Doing this on a Maven project with a parent POM and some modules shows the message that the store is reset only on the parent POM (at the start of the build). The individual modules show no reset message, but `[INFO] Entering /foobar/target/classes` and then how many classes were scanned. – eerriicc Jul 20 '21 at 15:49

2 Answers2

0

The defined behavior is such that the store is reset before scanning the first module of a reactor build. So usually there is no need to explicitly the reset behavior if all required modules can be scanned within the same build reactor.

Vice versa: reset must be deactivated for scans within a build reactor (e.g. a mvn package command) if an existing scan from a previous reactor build shall be extended.

The reset behavior of the scan goal can be controlled via the reset flag:

<plugin>
  <groupId>com.buschmais.jqassistant</groupId>
  <artifactId>jqassistant-maven-plugin</artifactId>
  <configuration>
    <store>
      <uri>bolt://my-neo4j-store.com:7687</uri>
      <username>neo4j</username>
      <password>reallysecret</password>
      <encryption>false</encryption>
    </store>

    <reset>false</reset> <!-- true is the default setting to clear the store at the beginning of each reactor build -->

  </configuration>
</plugin>

Please update your configuration (you used resetStore within another configuration section).

Dirk Mahler
  • 1,186
  • 1
  • 6
  • 7
  • There was a bug in 1.9.x always reporting 0 nodes/relations having been removed during reset. Actually the database was cleaned up, just the log was invalid. This probably lead to confusion - sorry for that. – Dirk Mahler Jul 25 '21 at 11:18
  • Being a newbie, I just tried the following: Scan one Maven project and then execute `MATCH (n:Class) RETURN n LIMIT 25000` This showed all classes of this project. Then I tried the same for a second project, and this shows all classes of the second project, but all the classes of the first project were gone. Is there any more I can do than configure `false` ? I'm still confused... how am I supposed to build a database for *all* our software? I thought that was the idea of setting up a team server. – eerriicc Jul 26 '21 at 08:38
0

Ah, now I see what the problem is: The configuration for resetting the store is called reset and not resetStore. When I use reset as proposed by Dirk Mahler, everything works fine!

Instead of looking at the source I read the documentation, which is wrong. I will write a bug in GitHub.

Dirk, thanks a lot for the suppport!

eerriicc
  • 1,124
  • 4
  • 17
  • 29