This repository has been archived by the owner on May 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
amckenzie
committed
Jan 31, 2017
1 parent
4bd0c85
commit 5245ec5
Showing
22 changed files
with
194 additions
and
369 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...cker-core/src/main/java/uk/gov/justice/raml/maven/lintchecker/LintCheckConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package uk.gov.justice.raml.maven.lintchecker; | ||
|
||
/** | ||
* Contains any configuration needed by any of the {@link LintCheckRule}s. Currently this class | ||
* contains nothing, but to future proof the {@link LintCheckRule} interface we pass this class | ||
* in the execute() method. Add any configuration your rule may need here. | ||
*/ | ||
public class LintCheckConfiguration { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...hecker-core/src/main/java/uk/gov/justice/raml/maven/lintchecker/LintCheckerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...en-plugin/src/main/java/uk/gov/justice/raml/maven/lintchecker/LintCheckGoalProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package uk.gov.justice.raml.maven.lintchecker; | ||
|
||
import uk.gov.justice.raml.io.FileTreeScanner; | ||
import uk.gov.justice.raml.io.files.parser.RamlFileParser; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.raml.model.Raml; | ||
|
||
public class LintCheckGoalProcessor { | ||
|
||
private final RamlFileParser ramlFileParser; | ||
private final FileTreeScanner fileTreeScanner; | ||
|
||
public LintCheckGoalProcessor( | ||
final RamlFileParser ramlFileParser, | ||
final FileTreeScanner fileTreeScanner) { | ||
this.ramlFileParser = ramlFileParser; | ||
this.fileTreeScanner = fileTreeScanner; | ||
} | ||
|
||
public void execute( | ||
final File sourceDirectory, | ||
final List<LintCheckRule> rules, | ||
final List<String> includes, | ||
final List<String> excludes) throws MojoExecutionException { | ||
|
||
final Collection<Path> paths = getPaths(sourceDirectory, includes, excludes); | ||
final Collection<Raml> ramls = ramlFileParser.ramlOf(sourceDirectory.toPath(), paths); | ||
|
||
for (final Raml raml : ramls) { | ||
for (final LintCheckRule rule : rules) { | ||
try { | ||
rule.execute(raml, new LintCheckConfiguration()); | ||
} catch (final LintCheckerException e) { | ||
throw new MojoExecutionException("Lint checker rule failed for rule " + rule.getClass().getSimpleName(), e); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private Collection<Path> getPaths( | ||
final File sourceDirectory, | ||
final List<String> includes, | ||
final List<String> excludes) throws MojoExecutionException { | ||
try { | ||
return fileTreeScanner.find(sourceDirectory.toPath(), toArray(includes), toArray(excludes)); | ||
} catch (final IOException e) { | ||
throw new MojoExecutionException("Failed to find paths from source directory " + sourceDirectory.getAbsolutePath()); | ||
} | ||
} | ||
|
||
private String[] toArray(final List<String> list) { | ||
return list.toArray(new String[list.size()]); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
raml-maven-plugin/src/main/java/uk/gov/justice/raml/maven/lintchecker/LintCheckMojo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package uk.gov.justice.raml.maven.lintchecker; | ||
|
||
import uk.gov.justice.raml.io.FileTreeScanner; | ||
import uk.gov.justice.raml.io.files.parser.RamlFileParser; | ||
import uk.gov.justice.raml.maven.common.BasicMojo; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
|
||
|
||
@Mojo(name = "lint-check") | ||
public class LintCheckMojo extends BasicMojo { | ||
|
||
private final RamlFileParser ramlFileParser = new RamlFileParser(); | ||
private final FileTreeScanner fileTreeScanner = new FileTreeScanner(); | ||
|
||
/** | ||
* Array of objects that implement the LintCheckerRule interface to execute. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Parameter(required = true) | ||
protected List<LintCheckRule> rules; | ||
|
||
|
||
@Override | ||
public void execute() throws MojoExecutionException { | ||
|
||
final LintCheckGoalProcessor lintCheckGoalProcessor = new LintCheckGoalProcessor( | ||
ramlFileParser, | ||
fileTreeScanner); | ||
|
||
lintCheckGoalProcessor.execute( | ||
sourceDirectory, | ||
rules, | ||
includes, | ||
excludes | ||
); | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
raml-maven-plugin/src/main/java/uk/gov/justice/raml/maven/lintchecker/LintCheckerMojo.java
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
...n-plugin/src/main/java/uk/gov/justice/raml/maven/lintchecker/LintCheckerMojoDelegate.java
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
raml-maven-plugin/src/main/java/uk/gov/justice/raml/maven/lintchecker/PathsProvider.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
raml-maven-plugin/src/main/java/uk/gov/justice/raml/maven/lintchecker/RamlProvider.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.