5

when i try to install maven, i get this error in intellij, itried all the solution proposed here "https://stackoverflow.com/questions/5074063/maven-error-failure-to-transfer" but it doesn't work

PS C:\Users\stagiaire1\Desktop\Vgc\vgc-backend>  mvn clean install -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.dzadvisory:bankapp >-----------------------
[INFO] Building bankapp 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.344 s
[INFO] Finished at: 2022-09-21T16:51:00+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".test.skip=true". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phas
es are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-com
pile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]   
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
Yas dev
  • 51
  • 1
  • 3

3 Answers3

16

It's because of PowerShell that interprets "-" as PowerShell params. ( your terminal shows "PS" in the first line )

so you should escape PowerShell params with --%, like

 mvn clean install --% -Dmaven.test.skip=true
sbouchet
  • 356
  • 3
  • 7
1

You can use this command instead.

mvn clean install -DskipTests 

Reference Doc - Maven CheatSheet

  • 1
    -DskipTests only skips the test execution, but -Dmaven.test.skip=true will skip the compilation of test classes, too – Steffen Jun 05 '23 at 09:47
0

Can't place this in a comment, not enough rep.

Few things here, the actions described below belong to the Maven Surefire Plugin which you will want to ensure is in the build entries inside your pom

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>x.x.x</version>
      <configuration>
        <skipTests>${skipTests}</skipTests>
      </configuration>
    </plugin>
  </plugins>
</build>

Now you'll have three options to skip tests.

  1. As you mentioned use -Dmaven.test.skip this will neither run, nor compile any of your tests meaning anything that relies on test artefacts being available will fail
  2. You can use -DskipTests which will compile but not run your tests meaning anything that relies on test artefacts will be able to proceed
  3. You can use the configuration property declared above (skipTests), which can be set in your pom properties
TedEllis
  • 66
  • 6
  • i tried what u say but it doesn't work – Yas dev Sep 22 '22 at 08:48
  • [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project bankapp: Input length = 1 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException – Yas dev Sep 22 '22 at 08:48
  • i have another error – Yas dev Sep 22 '22 at 08:48
  • This is a separate issue, however it should be able to be resolved by specifying your source encoding (most likely UTF-8) You can do this in the properties section of your pom.xml ` UTF-8 ` – TedEllis Sep 23 '22 at 02:21