Search code examples
mavenivy

How to add Walkmod plugin to eclipse?


I followed this documentation to add Walkmod to eclipse but found that there is issue with the ivy-2.4.0. Previously I have tried Walkmod with CMD and its working. The steps I followed to make Walkmod commands recognizable in CMD are

  1. Download the walkmod-Installer from https://walkmod.com
  2. In environment variable added "WALKMOD_HOME" and "MAVEN_HOME" are added along with corresponding system path variables also added. i.e "%WALKMOD_HOME/bin%"
  3. After this walkmod --version will be working but it will throw a issue with the command $ walkmod apply . It shows dependency issues. This issue can be fixed by replacing Walkmod_dir/Walkmod-3.0.0/lib/ivy-2.4.0 inside the walkmod-Installer you have downloaded from https://walkmod.com with ivy-2.5.0.

After the above three steps the Walkmod is making changes as per the requirement. The CMD output after $ walkmod check

C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master>walkmod check
 INFO [main] - Java version: 1.8.0_291
 INFO [main] - Java Home: C:\Program Files\Java\jdk1.8.0_291\jre
 INFO [main] - OS: Windows 10, Vesion: 10.0
--------------------------------------------------------------------------------
                     _    _       _ _   ___  ___          _
                    | |  | |     | | |  |  \/  |         | |
                    | |  | | __ _| | | _| .  . | ___   __| |
                    | |/\| |/ _` | | |/ / |\/| |/ _ \ / _` |
                    \  /\  / (_| | |   <| |  | | (_) | (_| |
                     \/  \/ \__,_|_|_|\_\_|  |_/\___/ \__,_|
--------------------------------------------------------------------------------
An open source tool to apply code conventions
version 3.0 - February 2017 -
--------------------------------------------------------------------------------
 INFO [main] - C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\walkmod.xml [ok]
:: loading settings :: url = file:/C:/Soft/Walkmod/walkmod-3.0.0-installer/walkmod-3.0.0/config/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Soft/Walkmod/walkmod-3.0.0-installer/walkmod-3.0.0/lib/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: org.walkmod#walkmod-imports-cleaner-plugin-caller;working
        confs: [default]
        found org.walkmod#walkmod-imports-cleaner-plugin;2.0.3 in maven2
        [2.0.3] org.walkmod#walkmod-imports-cleaner-plugin;latest.integration
        found org.walkmod#javalang;3.2.0 in maven2
        [3.2.0] org.walkmod#javalang;[3.0.0, 4.0.0)
        found org.walkmod#merger;1.0.1 in maven2
        [1.0.1] org.walkmod#merger;[1.0.1, 2.0)
        found junit#junit;4.5 in maven2
        found org.walkmod#walkmod-maven-plugin;2.1.7 in maven2
        [2.1.7] org.walkmod#walkmod-maven-plugin;latest.integration
        found org.walkmod#javalang;4.8.8 in maven2
        [4.8.8] org.walkmod#javalang;[2.0, 5.0)
        found org.walkmod#model-checker;1.1 in maven2
        [1.1] org.walkmod#model-checker;[1.0, 2.0)
        found org.jboss.shrinkwrap.resolver#shrinkwrap-resolver-api;2.2.1 in maven2
        found org.jboss.shrinkwrap.resolver#shrinkwrap-resolver-api-maven;2.2.1 in maven2
        found org.jboss.shrinkwrap.resolver#shrinkwrap-resolver-spi;2.2.1 in maven2
        found org.jboss.shrinkwrap.resolver#shrinkwrap-resolver-impl-maven;2.2.1 in maven2
        found org.jboss.shrinkwrap.resolver#shrinkwrap-resolver-spi-maven;2.2.1 in maven2
        found org.eclipse.aether#aether-api;1.0.0.v20140518 in maven2
        found org.eclipse.aether#aether-impl;1.0.0.v20140518 in maven2
        found org.eclipse.aether#aether-spi;1.0.0.v20140518 in maven2
        found org.eclipse.aether#aether-util;1.0.0.v20140518 in maven2
        found org.eclipse.aether#aether-connector-basic;1.0.0.v20140518 in maven2
        found org.eclipse.aether#aether-transport-wagon;1.0.0.v20140518 in maven2
        found org.apache.maven#maven-aether-provider;3.2.5 in maven2
        found org.apache.maven#maven-model;3.2.5 in maven2
        found org.codehaus.plexus#plexus-utils;3.0.20 in maven2
        found org.apache.maven#maven-model-builder;3.2.5 in maven2
        found org.codehaus.plexus#plexus-interpolation;1.21 in maven2
        found org.codehaus.plexus#plexus-component-annotations;1.5.5 in maven2
        found org.apache.maven#maven-repository-metadata;3.2.5 in maven2
        found org.apache.maven#maven-settings;3.2.5 in maven2
        found org.apache.maven#maven-settings-builder;3.2.5 in maven2
        found org.sonatype.plexus#plexus-sec-dispatcher;1.3 in maven2
        found org.sonatype.plexus#plexus-cipher;1.7 in maven2
        found com.google.guava#guava;18.0 in maven2
        found org.apache.maven.wagon#wagon-provider-api;2.6 in maven2
        found org.apache.maven.wagon#wagon-file;2.6 in maven2
        found commons-lang#commons-lang;2.6 in maven2
        found org.apache.maven.wagon#wagon-http-lightweight;2.6 in maven2
        found org.apache.maven.wagon#wagon-http-shared;2.6 in maven2
        found org.jsoup#jsoup;1.7.2 in maven2
        found commons-io#commons-io;2.2 in maven2
        found org.jboss.shrinkwrap.resolver#shrinkwrap-resolver-impl-maven-archive;2.2.1 in maven2
        found org.jboss.shrinkwrap#shrinkwrap-impl-base;1.2.1 in maven2
        found org.jboss.shrinkwrap#shrinkwrap-api;1.2.1 in maven2
        found org.jboss.shrinkwrap#shrinkwrap-spi;1.2.1 in maven2
        found org.jboss.shrinkwrap.resolver#shrinkwrap-resolver-api-maven-archive;2.2.1 in maven2
        found org.jboss.shrinkwrap.resolver#shrinkwrap-resolver-spi-maven-archive;2.2.1 in maven2
        found org.eclipse.sisu#org.eclipse.sisu.plexus;0.3.0.M1 in maven2
        found javax.enterprise#cdi-api;1.0 in maven2
        found javax.annotation#jsr250-api;1.0 in maven2
        found javax.inject#javax.inject;1 in maven2
        found org.eclipse.sisu#org.eclipse.sisu.inject;0.3.0.M1 in maven2
        found org.codehaus.plexus#plexus-compiler-javac;2.3 in maven2
        found org.codehaus.plexus#plexus-compiler-api;2.3 in maven2
        found org.apache.maven#maven-embedder;3.2.5 in maven2
        found org.apache.maven#maven-core;3.2.5 in maven2
        found org.apache.maven#maven-artifact;3.2.5 in maven2
        found org.apache.maven#maven-plugin-api;3.2.5 in maven2
        found org.sonatype.sisu#sisu-guice;3.2.3 in maven2
        found aopalliance#aopalliance;1.0 in maven2
        found org.codehaus.plexus#plexus-classworlds;2.5.2 in maven2
        found org.slf4j#slf4j-api;1.7.5 in maven2
        found commons-cli#commons-cli;1.2 in maven2
        found org.apache.maven#maven-compat;3.2.5 in maven2
        found org.apache.maven.wagon#wagon-provider-api;2.8 in maven2
        found junit#junit;4.12 in maven2
        found org.hamcrest#hamcrest-core;1.3 in maven2
        found org.slf4j#slf4j-log4j12;1.7.5 in maven2
        found log4j#log4j;1.2.17 in maven2
        found org.walkmod#walkmod-sonar-plugin;1.2.3 in maven2
        [1.2.3] org.walkmod#walkmod-sonar-plugin;latest.integration
        found org.walkmod#javalang-compiler;2.3.10 in maven2
        [2.3.10] org.walkmod#javalang-compiler;[2.2, 3.0)
        found org.walkmod#javalang;4.8.8 in maven2
        [4.8.8] org.walkmod#javalang;[4.1.0, 5.0.0)
        found org.walkmod#walkmod-refactor-plugin;2.3.3 in maven2
        [2.3.3] org.walkmod#walkmod-refactor-plugin;[2.3.3,3.0.0)
        found com.mashape.unirest#unirest-java;1.4.9 in maven2
        found org.apache.httpcomponents#httpclient;4.5.2 in maven2
        found org.apache.httpcomponents#httpcore;4.4.4 in maven2
        found commons-logging#commons-logging;1.2 in maven2
        found commons-codec#commons-codec;1.9 in maven2
        found org.apache.httpcomponents#httpasyncclient;4.1.1 in maven2
        found org.apache.httpcomponents#httpcore-nio;4.4.4 in maven2
        found org.apache.httpcomponents#httpmime;4.5.2 in maven2
        found org.json#json;20160212 in maven2
        found org.walkmod#walkmod-cfg;2.0 in maven2
        found org.walkmod#walkmod-javalang-plugin;3.0.6 in maven2
        [3.0.6] org.walkmod#walkmod-javalang-plugin;[2.0, 4.0)
        found org.walkmod#javalang;4.8.8 in maven2
        [4.8.8] org.walkmod#javalang;[3.1.0, 5.0.0)
        found com.squareup#javapoet;1.8.0 in maven2
        found org.walkmod#javalang-compiler;2.3.10 in maven2
        [2.3.10] org.walkmod#javalang-compiler;[2.0.0, 3.0.0)
        found org.mockito#mockito-core;2.7.0 in maven2
        found net.bytebuddy#byte-buddy;1.6.5 in maven2
        found net.bytebuddy#byte-buddy-agent;1.6.5 in maven2
        found org.objenesis#objenesis;2.5 in maven2
downloading https://repo1.maven.org/maven2/org/walkmod/walkmod-imports-cleaner-plugin/2.0.3/walkmod-imports-cleaner-plugin-2.0.3-sources.jar ...
        [SUCCESSFUL ] org.walkmod#walkmod-imports-cleaner-plugin;2.0.3!walkmod-imports-cleaner-plugin.jar(source) (1394ms)
downloading https://repo1.maven.org/maven2/org/walkmod/walkmod-imports-cleaner-plugin/2.0.3/walkmod-imports-cleaner-plugin-2.0.3.jar ...
        [SUCCESSFUL ] org.walkmod#walkmod-imports-cleaner-plugin;2.0.3!walkmod-imports-cleaner-plugin.jar (1525ms)
downloading https://repo1.maven.org/maven2/org/walkmod/walkmod-imports-cleaner-plugin/2.0.3/walkmod-imports-cleaner-plugin-2.0.3-javadoc.jar ...
        [SUCCESSFUL ] org.walkmod#walkmod-imports-cleaner-plugin;2.0.3!walkmod-imports-cleaner-plugin.jar(javadoc) (1478ms)
:: resolution report :: resolve 97595ms :: artifacts dl 4625ms
        :: evicted modules:
        org.walkmod#javalang;3.2.0 by [org.walkmod#javalang;4.8.8] in [default]
        junit#junit;4.5 by [junit#junit;4.12] in [default]
        org.apache.maven.wagon#wagon-provider-api;2.6 by [org.apache.maven.wagon#wagon-provider-api;2.8] in [default]
        log4j#log4j;1.2.16 by [log4j#log4j;1.2.17] in [default]
        org.walkmod#javalang-compiler;[2.0, 3.0) by [org.walkmod#javalang-compiler;2.3.10] in [default]
        org.apache.httpcomponents#httpclient;4.5.1 by [org.apache.httpcomponents#httpclient;4.5.2] in [default]
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |      default     |   87  |   11  |   3   |   6   ||   89  |   3   |
        ---------------------------------------------------------------------
 INFO [main] - ** STARTING TRANSFORMATIONS CHAINS **
--------------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< com.example.fidelity:employee >--------------------
[INFO] Building employee 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ employee ---
[INFO] Deleting C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\target
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ employee ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ employee ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ employee ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ employee ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ employee ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ employee ---
[INFO] Building jar: C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\target\employee-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ employee ---
[INFO] Installing C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\target\employee-0.0.1-SNAPSHOT.jar to C:\Users\User\.m2\repository\com\example\fidelity\employee\0.0.1-SNAPSHOT\employee-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\pom.xml to C:\Users\User\.m2\repository\com\example\fidelity\employee\0.0.1-SNAPSHOT\employee-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.924 s
[INFO] Finished at: 2021-08-16T08:29:06+05:30
[INFO] ------------------------------------------------------------------------
>> com.example.walkmod.employee.controllers.EmployeeController
>> com.example.walkmod.employee.controllers.HomeController
>> com.example.walkmod.employee.dto.EmployeeDatabase
>> com.example.walkmod.employee.services.EmployeeService
--------------------------------------------------------------------------------

 INFO [main] - TRANSFORMATION CHAIN SUCCESS
--------------------------------------------------------------------------------
 INFO [main] - Total time: 8.887 seconds
 INFO [main] - Finished at: Mon, 16 Aug 2021 08:29:07
 INFO [main] - Final memory: 109 M/ 168 M
 INFO [main] - Total modified files: 4

But the issue is that when I tried to add this in eclipse as plugin, same dependency issue from previous installation shows The steps followed in plugin installation are

Added the plugin inside the POM.xml

<plugin>
  <groupId>org.walkmod.maven.plugins</groupId>
  <artifactId>walkmod-maven-plugin</artifactId>
  <version>2.0.1</version>
  <executions>
    <execution>
      <goals>
        <goal>apply</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Right click the project where you need to perform Walmod operation, go to Run ,6 Maven Build you need to provide this mvn command at Goals text field that do the same functionality as $ walkmod apply

org.walkmod.maven.plugins:walkmod-maven-plugin:apply

Now I am getting this output in the console

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building employee 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- walkmod-maven-plugin:1.0.3:apply (default-cli) @ employee ---
 INFO [main] - C:\Users\User\Drive\Desktop\Project\Walkmode\Employee-Sample-App-master\Employee-Sample-App-master\walkmod.xml [ok]
:: loading settings :: url = jar:file:/C:/Users/User/.m2/repository/org/walkmod/walkmod-cmd/3.0.0/walkmod-cmd-3.0.0.jar!/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Users/User/.m2/repository/org/apache/ivy/ivy/2.4.0-rc1/ivy-2.4.0-rc1.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: org.walkmod#walkmod-imports-cleaner-plugin-caller;working
    confs: [default]
:: resolution report :: resolve 44263ms :: artifacts dl 0ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      default     |   4   |   0   |   0   |   0   ||   0   |   0   |
    ---------------------------------------------------------------------

For full console output

By comparing these two lines in the output from cmd

:: loading settings :: url = file:/C:/Soft/Walkmod/walkmod-3.0.0-installer/walkmod-3.0.0/config/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Soft/Walkmod/walkmod-3.0.0-installer/walkmod-3.0.0/lib/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml

and console of eclipse

:: loading settings :: url = jar:file:/C:/Users/User/.m2/repository/org/walkmod/walkmod-cmd/3.0.0/walkmod-cmd-3.0.0.jar!/ivysettings.xml
:: loading settings :: url = jar:file:/C:/Users/User/.m2/repository/org/apache/ivy/ivy/2.4.0-rc1/ivy-2.4.0-rc1.jar!/org/apache/ivy/core/settings/ivysettings.xml

It can be seen that Issue is with ivy-2.4.0-rc1.jar. But this jar can't be directly replaced as previous installation for walkmod-sonar-plugin. First we need to change walkmod-cmd-3.0.0.jar!/ivysettings.xml to make it look into ivy-2.5.0

How to change the ivy-2.4.0 to ivy-2.5.0 for maven-walkmod-plugin ?


Solution

  • How to change the ivy-2.4.0 to ivy-2.5.0 for maven-walkmod-plugin?

    Try this:

    <plugin>
      <groupId>org.walkmod.maven.plugins</groupId>
      <artifactId>walkmod-maven-plugin</artifactId>
      <version>2.0.1</version>
      <executions>
        <execution>
          <goals>
            <goal>apply</goal>
          </goals>
        </execution>
      </executions>
      <dependencies>
        <dependency>
          <groupId>org.apache.ivy</groupId>
          <artifactId>ivy</artifactId>
          <version>2.5.0</version>
        </dependency>
      </dependencies>
    </plugin>