mirror of
https://gitee.com/dcren/initializr.git
synced 2025-08-01 10:10:19 +08:00
Configure gitignore negations more precisely
Previously we negated the exclusions for all of src/main and src/test. This was done to prevent any content under src/main or src/test that matched the build output directories (build/ out/, and target/) from being ignored. While concise, this approach has proven to be overly broad as it undoes all exclusions and not just those for the build output directories. This commit switches to individual negations for each of the build output directories that we ignore. While more verbose, this narrows the negations to match their original intent and perhaps also makes it easier to infer that intent from the generated .gitignore file. Closes gh-1106
This commit is contained in:
parent
31aad89a8a
commit
3ed1a1dd7e
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -49,9 +49,9 @@ public class GitProjectGenerationConfiguration {
|
||||
@ConditionalOnBuildSystem(MavenBuildSystem.ID)
|
||||
public GitIgnoreCustomizer mavenGitIgnoreCustomizer() {
|
||||
return (gitIgnore) -> {
|
||||
gitIgnore.getGeneral().add("target/", "!.mvn/wrapper/maven-wrapper.jar", "!**/src/main/**",
|
||||
"!**/src/test/**");
|
||||
gitIgnore.getNetBeans().add("build/");
|
||||
gitIgnore.getGeneral().add("target/", "!.mvn/wrapper/maven-wrapper.jar", "!**/src/main/**/target/",
|
||||
"!**/src/test/**/target/");
|
||||
gitIgnore.getNetBeans().add("build/", "!**/src/main/**/build/", "!**/src/test/**/build/");
|
||||
};
|
||||
}
|
||||
|
||||
@ -59,9 +59,9 @@ public class GitProjectGenerationConfiguration {
|
||||
@ConditionalOnBuildSystem(GradleBuildSystem.ID)
|
||||
public GitIgnoreCustomizer gradleGitIgnoreCustomizer() {
|
||||
return (gitIgnore) -> {
|
||||
gitIgnore.getGeneral().add(".gradle", "build/", "!gradle/wrapper/gradle-wrapper.jar", "!**/src/main/**",
|
||||
"!**/src/test/**");
|
||||
gitIgnore.getIntellijIdea().add("out/");
|
||||
gitIgnore.getGeneral().add(".gradle", "build/", "!gradle/wrapper/gradle-wrapper.jar",
|
||||
"!**/src/main/**/build/", "!**/src/test/**/build/");
|
||||
gitIgnore.getIntellijIdea().add("out/", "!**/src/main/**/out/", "!**/src/test/**/out/");
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -67,8 +67,9 @@ class GitProjectGenerationConfigurationTests {
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setBuildSystem(new GradleBuildSystem());
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
assertThat(generateGitIgnore(description)).contains(".gradle", "build/", "!gradle/wrapper/gradle-wrapper.jar",
|
||||
"out/", "!**/src/main/**", "!**/src/test/**")
|
||||
assertThat(generateGitIgnore(description))
|
||||
.contains(".gradle", "build/", "!gradle/wrapper/gradle-wrapper.jar", "out/", "!**/src/main/**/build/",
|
||||
"!**/src/test/**/build/", "!**/src/main/**/out/", "!**/src/test/**/out/")
|
||||
.doesNotContain("/target/", "!.mvn/wrapper/maven-wrapper.jar");
|
||||
}
|
||||
|
||||
@ -78,7 +79,8 @@ class GitProjectGenerationConfigurationTests {
|
||||
description.setBuildSystem(new MavenBuildSystem());
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
assertThat(generateGitIgnore(description))
|
||||
.contains("target/", "!.mvn/wrapper/maven-wrapper.jar", "!**/src/main/**", "!**/src/test/**")
|
||||
.contains("target/", "!.mvn/wrapper/maven-wrapper.jar", "!**/src/main/**/target/",
|
||||
"!**/src/test/**/target/")
|
||||
.doesNotContain(".gradle", "!gradle/wrapper/gradle-wrapper.jar", "/out/");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user