如何将 Walkmod 插件添加到 Eclipse?

Posted

技术标签:

【中文标题】如何将 Walkmod 插件添加到 Eclipse?【英文标题】:How to add Walkmod plugin to eclipse? 【发布时间】:2021-10-19 02:56:17 【问题描述】:

我按照this 文档将 Walkmod 添加到 Eclipse,但发现 ivy-2.4.0 存在问题。 以前我尝试过使用 CMD 及其工作的 Walkmod。 我在 CMD 中使 Walkmod 命令可识别的步骤是

    从https://walkmod.com下载walkmod-Installer 在环境变量中添加了“WALKMOD_HOME”和“MAVEN_HOME”,同时也添加了相应的系统路径变量。即“%WALKMOD_HOME/bin%” 在此 walkmod --version 将工作后,它会引发命令 $ walkmod apply 的问题。它显示了依赖性问题。可以通过将您从 https://walkmod.com 下载的 walkmod-Installer 中的 Walkmod_dir/Walkmod-3.0.0/lib/ivy-2.4.0 替换为 ivy-2.5.0 来解决此问题。

在上述三个步骤之后,Walkmod 正在根据要求进行更改。 $ walkmod check之后的CMD输出

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

但问题是,当我尝试在 eclipse 中将其添加为插件时,与先前安装相同的依赖问题显示 插件安装的步骤是

在 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>

右键单击需要执行 Walmod 操作的项目,转到 Run ,6 Maven Build 您需要在目标文本字段中提供此 mvn 命令,其功能与 $ walkmod apply 相同

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

现在我在控制台中得到这个输出

[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   |
    ---------------------------------------------------------------------

完整版console output

通过比较 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

和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

可以看出Issue是ivy-2.4.0-rc1.jar。但是这个jar不能直接替换为walkmod-sonar-plugin之前的安装。首先我们需要修改 walkmod-cmd-3.0.0.jar!/ivysettings.xml 让它看起来像 ivy-2.5.0

如何将maven-walkmod-plugin的ivy-2.4.0更改为ivy-2.5.0?

【问题讨论】:

【参考方案1】:

maven-walkmod-plugin如何将ivy-2.4.0改为ivy-2.5.0?

试试这个:

<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>

【讨论】:

以上是关于如何将 Walkmod 插件添加到 Eclipse?的主要内容,如果未能解决你的问题,请参考以下文章

如何将适用于 Android 的 Pushwoosh 插件添加到 Cordova IBM Worklight (@Eclipse)?

如何将 sbteclipse 插件添加到 SBT 0.10.x

将项目添加到 Eclipse 文本查看器上下文菜单

将语言包添加到 Eclipse RCP

如何在eclipse中安装svn插件并使用方法

如何将 Ivy 的依赖项添加到 Eclipse PDE 目标平台?