Exclude test folder from maven buildCreate ArrayList from arrayHow can I create an executable JAR with dependencies using Maven?How to add local jar files to a Maven project?IntelliJ inspection gives “Cannot resolve symbol” but still compiles codeExclude Test Classes in dependend Maven JARHow do you “Mavenize” a project using Intellij?Maven is not working in Java 8 when Javadoc tags are incompleteBuilding a maven jar for TestNG automation projectMaven - Wrong folder structureMaven spring-boot ueber-jar and lib
If infinitesimal transformations commute why dont the generators of the Lorentz group commute?
Why is it that I can sometimes guess the next note?
It grows, but water kills it
Why Shazam when there is already Superman?
What was this official D&D 3.5e Lovecraft-flavored rulebook?
Freedom of speech and where it applies
The screen of my macbook suddenly broken down how can I do to recover
How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?
Aragorn's "guise" in the Orthanc Stone
Offered money to buy a house, seller is asking for more to cover gap between their listing and mortgage owed
Yosemite Fire Rings - What to Expect?
The IT department bottlenecks progress. How should I handle this?
Non-trope happy ending?
Melting point of aspirin, contradicting sources
Longest common substring in linear time
How to indicate a cut out for a product window
C++ debug/print custom type with GDB : the case of nlohmann json library
What prevents the use of a multi-segment ILS for non-straight approaches?
Redundant comparison & "if" before assignment
Is there any references on the tensor product of presentable (1-)categories?
Has any country ever had 2 former presidents in jail simultaneously?
Is it possible to put a rectangle as background in the author section?
Why did the Mercure fail?
Open a doc from terminal, but not by its name
Exclude test folder from maven build
Create ArrayList from arrayHow can I create an executable JAR with dependencies using Maven?How to add local jar files to a Maven project?IntelliJ inspection gives “Cannot resolve symbol” but still compiles codeExclude Test Classes in dependend Maven JARHow do you “Mavenize” a project using Intellij?Maven is not working in Java 8 when Javadoc tags are incompleteBuilding a maven jar for TestNG automation projectMaven - Wrong folder structureMaven spring-boot ueber-jar and lib
This is one of the most asked questions here in so... but why any answer works for me? i believe i have somehow a wrong maven structure in my project
I have a project like
basedir
|-src
|--many many many packages
|-test
|--testpackages
|-pom.xml
So my pom.xml
is in the same level as src
and test
folders and it isn't the typical structure like java/main/ java/test... it is the root of the project folder
<build>
<sourceDirectory>$basedir/src</sourceDirectory>
<testSourceDirectory>$basedir/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<excludes>
<exclude>**/test/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
but when i run maven install and open the generated jar the folder test is in there...
how can i solve and make it ignore this folder?
java maven
add a comment |
This is one of the most asked questions here in so... but why any answer works for me? i believe i have somehow a wrong maven structure in my project
I have a project like
basedir
|-src
|--many many many packages
|-test
|--testpackages
|-pom.xml
So my pom.xml
is in the same level as src
and test
folders and it isn't the typical structure like java/main/ java/test... it is the root of the project folder
<build>
<sourceDirectory>$basedir/src</sourceDirectory>
<testSourceDirectory>$basedir/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<excludes>
<exclude>**/test/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
but when i run maven install and open the generated jar the folder test is in there...
how can i solve and make it ignore this folder?
java maven
1
<exclude>test/**</exclude>
– Micho Rizo
Mar 8 at 5:20
add a comment |
This is one of the most asked questions here in so... but why any answer works for me? i believe i have somehow a wrong maven structure in my project
I have a project like
basedir
|-src
|--many many many packages
|-test
|--testpackages
|-pom.xml
So my pom.xml
is in the same level as src
and test
folders and it isn't the typical structure like java/main/ java/test... it is the root of the project folder
<build>
<sourceDirectory>$basedir/src</sourceDirectory>
<testSourceDirectory>$basedir/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<excludes>
<exclude>**/test/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
but when i run maven install and open the generated jar the folder test is in there...
how can i solve and make it ignore this folder?
java maven
This is one of the most asked questions here in so... but why any answer works for me? i believe i have somehow a wrong maven structure in my project
I have a project like
basedir
|-src
|--many many many packages
|-test
|--testpackages
|-pom.xml
So my pom.xml
is in the same level as src
and test
folders and it isn't the typical structure like java/main/ java/test... it is the root of the project folder
<build>
<sourceDirectory>$basedir/src</sourceDirectory>
<testSourceDirectory>$basedir/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<excludes>
<exclude>**/test/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
but when i run maven install and open the generated jar the folder test is in there...
how can i solve and make it ignore this folder?
java maven
java maven
asked Mar 8 at 4:33
Rafael LimaRafael Lima
494418
494418
1
<exclude>test/**</exclude>
– Micho Rizo
Mar 8 at 5:20
add a comment |
1
<exclude>test/**</exclude>
– Micho Rizo
Mar 8 at 5:20
1
1
<exclude>test/**</exclude>
– Micho Rizo
Mar 8 at 5:20
<exclude>test/**</exclude>
– Micho Rizo
Mar 8 at 5:20
add a comment |
2 Answers
2
active
oldest
votes
Add -DskipTests
to mvn
command as a workaround. For instance:
mvn package -DskipTests
didn't work... i dont know if i wasn't clear, but the problem is that the test folder is INSIDE the final jar.... is not that maven is running test code
– Rafael Lima
Mar 8 at 4:51
@RafaelLima , if the folder is is final jar then it is already built, how and what you wanna achieve next with maven? Beside all Nilanjan's answer is correct in most cases.
– Common Man
Mar 8 at 5:45
@Common Man:-DskipTests
option will skip the test case run only, it won't prevent the test folder from getting packaged if it is at the same level as src and not inside it:(<testSourceDirectory>$basedir/test</testSourceDirectory>
)
– Alok Dubey
Mar 9 at 4:28
@AlokDubey, you are correct.
– Common Man
Mar 9 at 4:30
add a comment |
Yes, I believe your maven project structure is not correct. Maven excludes src/test/java
for packaging by default so test folder should be inside src and not in the same level as shown below:
For more details visit Maven doc
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056770%2fexclude-test-folder-from-maven-build%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Add -DskipTests
to mvn
command as a workaround. For instance:
mvn package -DskipTests
didn't work... i dont know if i wasn't clear, but the problem is that the test folder is INSIDE the final jar.... is not that maven is running test code
– Rafael Lima
Mar 8 at 4:51
@RafaelLima , if the folder is is final jar then it is already built, how and what you wanna achieve next with maven? Beside all Nilanjan's answer is correct in most cases.
– Common Man
Mar 8 at 5:45
@Common Man:-DskipTests
option will skip the test case run only, it won't prevent the test folder from getting packaged if it is at the same level as src and not inside it:(<testSourceDirectory>$basedir/test</testSourceDirectory>
)
– Alok Dubey
Mar 9 at 4:28
@AlokDubey, you are correct.
– Common Man
Mar 9 at 4:30
add a comment |
Add -DskipTests
to mvn
command as a workaround. For instance:
mvn package -DskipTests
didn't work... i dont know if i wasn't clear, but the problem is that the test folder is INSIDE the final jar.... is not that maven is running test code
– Rafael Lima
Mar 8 at 4:51
@RafaelLima , if the folder is is final jar then it is already built, how and what you wanna achieve next with maven? Beside all Nilanjan's answer is correct in most cases.
– Common Man
Mar 8 at 5:45
@Common Man:-DskipTests
option will skip the test case run only, it won't prevent the test folder from getting packaged if it is at the same level as src and not inside it:(<testSourceDirectory>$basedir/test</testSourceDirectory>
)
– Alok Dubey
Mar 9 at 4:28
@AlokDubey, you are correct.
– Common Man
Mar 9 at 4:30
add a comment |
Add -DskipTests
to mvn
command as a workaround. For instance:
mvn package -DskipTests
Add -DskipTests
to mvn
command as a workaround. For instance:
mvn package -DskipTests
answered Mar 8 at 4:37
Nilanjan BNilanjan B
2387
2387
didn't work... i dont know if i wasn't clear, but the problem is that the test folder is INSIDE the final jar.... is not that maven is running test code
– Rafael Lima
Mar 8 at 4:51
@RafaelLima , if the folder is is final jar then it is already built, how and what you wanna achieve next with maven? Beside all Nilanjan's answer is correct in most cases.
– Common Man
Mar 8 at 5:45
@Common Man:-DskipTests
option will skip the test case run only, it won't prevent the test folder from getting packaged if it is at the same level as src and not inside it:(<testSourceDirectory>$basedir/test</testSourceDirectory>
)
– Alok Dubey
Mar 9 at 4:28
@AlokDubey, you are correct.
– Common Man
Mar 9 at 4:30
add a comment |
didn't work... i dont know if i wasn't clear, but the problem is that the test folder is INSIDE the final jar.... is not that maven is running test code
– Rafael Lima
Mar 8 at 4:51
@RafaelLima , if the folder is is final jar then it is already built, how and what you wanna achieve next with maven? Beside all Nilanjan's answer is correct in most cases.
– Common Man
Mar 8 at 5:45
@Common Man:-DskipTests
option will skip the test case run only, it won't prevent the test folder from getting packaged if it is at the same level as src and not inside it:(<testSourceDirectory>$basedir/test</testSourceDirectory>
)
– Alok Dubey
Mar 9 at 4:28
@AlokDubey, you are correct.
– Common Man
Mar 9 at 4:30
didn't work... i dont know if i wasn't clear, but the problem is that the test folder is INSIDE the final jar.... is not that maven is running test code
– Rafael Lima
Mar 8 at 4:51
didn't work... i dont know if i wasn't clear, but the problem is that the test folder is INSIDE the final jar.... is not that maven is running test code
– Rafael Lima
Mar 8 at 4:51
@RafaelLima , if the folder is is final jar then it is already built, how and what you wanna achieve next with maven? Beside all Nilanjan's answer is correct in most cases.
– Common Man
Mar 8 at 5:45
@RafaelLima , if the folder is is final jar then it is already built, how and what you wanna achieve next with maven? Beside all Nilanjan's answer is correct in most cases.
– Common Man
Mar 8 at 5:45
@Common Man:
-DskipTests
option will skip the test case run only, it won't prevent the test folder from getting packaged if it is at the same level as src and not inside it:(<testSourceDirectory>$basedir/test</testSourceDirectory>
)– Alok Dubey
Mar 9 at 4:28
@Common Man:
-DskipTests
option will skip the test case run only, it won't prevent the test folder from getting packaged if it is at the same level as src and not inside it:(<testSourceDirectory>$basedir/test</testSourceDirectory>
)– Alok Dubey
Mar 9 at 4:28
@AlokDubey, you are correct.
– Common Man
Mar 9 at 4:30
@AlokDubey, you are correct.
– Common Man
Mar 9 at 4:30
add a comment |
Yes, I believe your maven project structure is not correct. Maven excludes src/test/java
for packaging by default so test folder should be inside src and not in the same level as shown below:
For more details visit Maven doc
add a comment |
Yes, I believe your maven project structure is not correct. Maven excludes src/test/java
for packaging by default so test folder should be inside src and not in the same level as shown below:
For more details visit Maven doc
add a comment |
Yes, I believe your maven project structure is not correct. Maven excludes src/test/java
for packaging by default so test folder should be inside src and not in the same level as shown below:
For more details visit Maven doc
Yes, I believe your maven project structure is not correct. Maven excludes src/test/java
for packaging by default so test folder should be inside src and not in the same level as shown below:
For more details visit Maven doc
edited Mar 9 at 4:36
answered Mar 8 at 5:37
Alok DubeyAlok Dubey
82211
82211
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056770%2fexclude-test-folder-from-maven-build%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
<exclude>test/**</exclude>
– Micho Rizo
Mar 8 at 5:20