Skipping Maven Test Dependency

2019-04-26 00:00发布

问题:

I am working on a project that use maven for building. What I am trying to do is to skip the test dependency. Basically running the maven build without the presence of artifact in my maven repository.

eg

<artifactId>example</artifactId>
<scope>test</scope>

This is from the pom file of my project and I have to maven build my project without having artifact example.

I have searched for solution such as use "-DskipTests=true" or "-Dmaven.test.skip=true". In my case they did skip the running of the tests but it still complains missing dependency file.

Does anyone know a way to run maven build without having to have test artifact in the maven repository?

Thanks.

回答1:

See http://jira.codehaus.org/browse/MNG-4192. I think the only way around it is to move the test-scoped dependency into a Maven profile.