Skip to content

Commit b510c3d

Browse files
qxo钱向鸥(qianxiangou)
authored andcommitted
feat: make this plugin can run on non-maven project (wihtout pom.xml)
make this plugin goals can run on any project which has .editorconfig on project basedir such as with -Deditorconfig.basedir ``` mvn org.ec4j.maven:editorconfig-maven-plugin:0.1.x:format -Deditorconfig.includes=**/*.xml -e -Deditorconfig.encoding=UTF-8 -Dproject.basedir=/any_dir_with_editorconfig ``` or without editorconfig.basedir means on current dir ``` mvn org.ec4j.maven:editorconfig-maven-plugin:0.1.x:format -Deditorconfig.includes=**/*.xml -e -Deditorconfig.encoding=UTF-8 ``` or
1 parent 08a89cc commit b510c3d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

editorconfig-maven-plugin/src/main/java/org/ec4j/maven/AbstractEditorConfigMojo.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public abstract class AbstractEditorConfigMojo extends AbstractMojo {
7575
*
7676
* @since 0.0.1
7777
*/
78-
@Parameter(defaultValue = "${project.basedir}", required = true, readonly = true)
78+
@Parameter(defaultValue = "${project.basedir}", required = false, readonly = true)
7979
private File basedir;
8080

8181
/** The result of {@code basedir.toPath()} */
@@ -216,6 +216,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
216216
} else {
217217
this.charset = Charsets.forName(this.encoding);
218218
}
219+
if (basedir == null) {
220+
basedir = new File(".").getAbsoluteFile();
221+
}
219222
this.basedirPath = basedir.toPath();
220223

221224
LinterRegistry linterRegistry = buildLinterRegistry();

editorconfig-maven-plugin/src/main/java/org/ec4j/maven/EditorConfigCheckMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @since 0.0.1
3232
* @author <a href="https://github.com/ppalaga">Peter Palaga</a>
3333
*/
34-
@Mojo(defaultPhase = LifecyclePhase.VERIFY, name = "check", threadSafe = true)
34+
@Mojo(requiresProject = false, defaultPhase = LifecyclePhase.VERIFY, name = "check", threadSafe = true)
3535
public class EditorConfigCheckMojo extends AbstractEditorConfigMojo {
3636

3737
/**

editorconfig-maven-plugin/src/main/java/org/ec4j/maven/EditorConfigFormatMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @since 0.0.1
3030
* @author <a href="https://github.com/ppalaga">Peter Palaga</a>
3131
*/
32-
@Mojo(defaultPhase = LifecyclePhase.NONE, name = "format", threadSafe = true)
32+
@Mojo(requiresProject = false, defaultPhase = LifecyclePhase.NONE, name = "format", threadSafe = true)
3333
public class EditorConfigFormatMojo extends AbstractEditorConfigMojo {
3434

3535
/**

0 commit comments

Comments
 (0)