Skip to content

Commit d8ecbdb

Browse files
committed
feat: make this plugin may run on non-maven project (wihtout pom.xml)
make this plugin goals 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 33f4e9f commit d8ecbdb

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()} */
@@ -219,6 +219,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
219219
} else {
220220
this.charset = Charsets.forName(this.encoding);
221221
}
222+
if (basedir == null) {
223+
basedir = new File(".").getAbsoluteFile();
224+
}
222225
this.basedirPath = basedir.toPath();
223226

224227
LinterRegistry linterRegistry = buildLinterRegistry();

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

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

3838
private static final Logger log = LoggerFactory.getLogger(CheckMojo.class);

editorconfig-maven-plugin/src/main/java/org/ec4j/maven/FormatMojo.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 FormatMojo extends AbstractEditorconfigMojo {
3434

3535
/**

0 commit comments

Comments
 (0)