Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
apply code style
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceko committed May 6, 2016
1 parent 0e9f6d9 commit 18bb0ef
Show file tree
Hide file tree
Showing 34 changed files with 199 additions and 188 deletions.
4 changes: 2 additions & 2 deletions io-utils/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>raml-maven</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import org.reflections.scanners.ResourcesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -58,8 +56,8 @@ public Collection<Path> find(final Path baseDir, final String[] includes, final

private Collection<URL> urlsToScan(final Path baseDir) throws MalformedURLException {
return shouldSearchOnClasspath(baseDir)
? ClasspathHelper.forClassLoader()
: asList(baseDir.toUri().toURL());
? ClasspathHelper.forClassLoader()
: asList(baseDir.toUri().toURL());
}

private boolean shouldSearchOnClasspath(final Path baseDir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.nio.file.Paths;
import java.util.Collection;


import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
Expand Down
4 changes: 2 additions & 2 deletions raml-for-testing-io/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>raml-maven</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions raml-generator-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>raml-maven</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions raml-generator-for-testing/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>raml-maven</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package uk.gov.justice.raml.maven.test;

import org.raml.model.Raml;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.util.Arrays.asList;

import uk.gov.justice.raml.core.Generator;
import uk.gov.justice.raml.core.GeneratorConfig;

Expand All @@ -9,11 +14,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;

import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.util.Arrays.asList;
import org.raml.model.Raml;

/**
* Generator for testing - RAML titles are appended to a text file.
Expand Down
20 changes: 13 additions & 7 deletions raml-maven-plugin-it/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -29,9 +29,12 @@
<execution>
<id>external-ramls</id>
<configuration>
<generatorName>uk.gov.justice.raml.maven.test.RamlTitleAppendingGenerator</generatorName>
<generatorName>
uk.gov.justice.raml.maven.test.RamlTitleAppendingGenerator
</generatorName>
<basePackageName>uk.gov.justice.api</basePackageName>
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
<outputDirectory>${project.build.directory}/generated-sources
</outputDirectory>
<sourceDirectory>CLASSPATH</sourceDirectory>
<includes>
<include>**/*external-*.raml</include>
Expand All @@ -48,10 +51,13 @@
<execution>
<id>internal-ramls</id>
<configuration>
<generatorName>uk.gov.justice.raml.maven.test.RamlTitleAppendingGenerator</generatorName>
<generatorName>
uk.gov.justice.raml.maven.test.RamlTitleAppendingGenerator
</generatorName>
<basePackageName>uk.gov.justice.api</basePackageName>
<sourceDirectory>${basedir}/src/raml</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
<outputDirectory>${project.build.directory}/generated-sources
</outputDirectory>
<includes>
<include>**/*internal-*.raml</include>
</includes>
Expand Down Expand Up @@ -110,6 +116,6 @@
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package uk.gov.justice.maven.raml.plugin.it;


import org.junit.Test;
import static org.apache.commons.lang.StringUtils.substringBefore;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;

import uk.gov.justice.raml.maven.test.RamlTitleAppendingGenerator;

import java.net.URI;
Expand All @@ -12,9 +15,7 @@
import java.nio.file.Paths;
import java.util.List;

import static org.apache.commons.lang.StringUtils.substringBefore;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.*;
import org.junit.Test;

public class RamlFilesScanningIT {

Expand Down
5 changes: 3 additions & 2 deletions raml-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>uk.gov.justice.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.List;

/**
* POJO to hold config for maven plugin goal.
*/
* POJO to hold config for maven plugin goal.
*/

public class BasicGoalConfig {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package uk.gov.justice.raml.maven.common;

import java.io.File;
import java.util.List;

import com.google.common.collect.ImmutableList;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import java.io.File;
import java.util.List;

public abstract class BasicMojo extends AbstractMojo {
private static final String DEFAULT_INCLUDE = "**/*.raml";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package uk.gov.justice.raml.maven.generator;

import org.apache.commons.io.FileUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE_PLUS_RUNTIME;

import uk.gov.justice.raml.io.FileTreeScannerFactory;
import uk.gov.justice.raml.maven.common.BasicMojo;

import java.io.File;
import java.util.Map;

import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE_PLUS_RUNTIME;
import org.apache.commons.io.FileUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

@Mojo(name = "generate", requiresDependencyResolution = COMPILE_PLUS_RUNTIME, defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class GenerateMojo extends BasicMojo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package uk.gov.justice.raml.maven.validator;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.raml.parser.rule.ValidationResult;
import uk.gov.justice.raml.io.FileTreeScannerFactory;
import uk.gov.justice.raml.maven.common.BasicGoalConfig;
import uk.gov.justice.raml.maven.common.BasicMojo;
Expand All @@ -13,6 +9,11 @@
import java.nio.file.Path;
import java.util.Map;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.raml.parser.rule.ValidationResult;

@Mojo(name = "check-syntax")
public class RamlSyntaxCheckMojo extends BasicMojo {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package uk.gov.justice.raml.maven.validator;

import org.raml.parser.loader.FileResourceLoader;
import org.raml.parser.rule.ValidationResult;
import org.raml.parser.visitor.RamlValidationService;
import uk.gov.justice.raml.io.FileTreeScannerFactory;
import uk.gov.justice.raml.maven.common.BasicGoalConfig;

Expand All @@ -13,6 +10,10 @@
import java.util.List;
import java.util.Map;

import org.raml.parser.loader.FileResourceLoader;
import org.raml.parser.rule.ValidationResult;
import org.raml.parser.visitor.RamlValidationService;

public class RamlSyntaxValidator {

private final FileTreeScannerFactory scannerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package uk.gov.justice.raml.maven.generator;

import java.io.File;
import java.util.Arrays;

import org.apache.maven.DefaultMaven;
import org.apache.maven.Maven;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
Expand All @@ -17,22 +20,16 @@
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;

import java.io.File;
import java.util.Arrays;

/** Use this as you would {@link AbstractMojoTestCase},
* where you want more of the standard maven defaults to be set
* (and where the {@link AbstractMojoTestCase} leaves them as null or empty).
* This includes:
* <li> local repo, repo sessions and managers configured
* <li> maven default remote repos installed (NB: this does not use your ~/.m2 local settings)
* <li> system properties are copies
* <p>
* No changes to subclass code is needed; this simply intercepts the {@link #newMavenSession(MavenProject)} method
* used by the various {@link #lookupMojo(String, File)} methods.
* <p>
* This also provides new methods, {@link #newMavenSession()} to conveniently create a maven session,
* and {@link #lookupConfiguredMojo(File, String)} so you don't have to always build the project yourself.
/**
* Use this as you would {@link AbstractMojoTestCase}, where you want more of the standard maven
* defaults to be set (and where the {@link AbstractMojoTestCase} leaves them as null or empty).
* This includes: <li> local repo, repo sessions and managers configured <li> maven default remote
* repos installed (NB: this does not use your ~/.m2 local settings) <li> system properties are
* copies <p> No changes to subclass code is needed; this simply intercepts the {@link
* #newMavenSession(MavenProject)} method used by the various {@link #lookupMojo(String, File)}
* methods. <p> This also provides new methods, {@link #newMavenSession()} to conveniently create a
* maven session, and {@link #lookupConfiguredMojo(File, String)} so you don't have to always build
* the project yourself.
*/
public abstract class BetterAbstractMojoTestCase extends AbstractMojoTestCase {

Expand All @@ -45,48 +42,52 @@ protected MavenSession newMavenSession() {

// populate sensible defaults, including repository basedir and remote repos
MavenExecutionRequestPopulator populator;
populator = getContainer().lookup( MavenExecutionRequestPopulator.class );
populator.populateDefaults( request );
populator = getContainer().lookup(MavenExecutionRequestPopulator.class);
populator.populateDefaults(request);

// this is needed to allow java profiles to get resolved; i.e. avoid during project builds:
// [ERROR] Failed to determine Java version for profile java-1.5-detected @ org.apache.commons:commons-parent:22, /Users/alex/.m2/repository/org/apache/commons/commons-parent/22/commons-parent-22.pom, line 909, column 14
request.setSystemProperties( System.getProperties() );
request.setSystemProperties(System.getProperties());

// and this is needed so that the repo session in the maven session
// has a repo manager, and it points at the local repo
// (cf MavenRepositorySystemUtils.newSession() which is what is otherwise done)
DefaultMaven maven = (DefaultMaven) getContainer().lookup( Maven.class );
DefaultMaven maven = (DefaultMaven) getContainer().lookup(Maven.class);
DefaultRepositorySystemSession repoSession =
(DefaultRepositorySystemSession) maven.newRepositorySession( request );
(DefaultRepositorySystemSession) maven.newRepositorySession(request);
repoSession.setLocalRepositoryManager(
new SimpleLocalRepositoryManagerFactory().newInstance(repoSession,
new LocalRepository( request.getLocalRepository().getBasedir() ) ));
new LocalRepository(request.getLocalRepository().getBasedir())));

@SuppressWarnings("deprecation")
MavenSession session = new MavenSession( getContainer(),
MavenSession session = new MavenSession(getContainer(),
repoSession,
request, result );
request, result);
return session;
} catch (Exception e) {
throw new RuntimeException(e);
}
}

/** Extends the super to use the new {@link #newMavenSession()} introduced here
* which sets the defaults one expects from maven; the standard test case leaves a lot of things blank */
/**
* Extends the super to use the new {@link #newMavenSession()} introduced here which sets the
* defaults one expects from maven; the standard test case leaves a lot of things blank
*/
@Override
protected MavenSession newMavenSession(MavenProject project) {
MavenSession session = newMavenSession();
session.setCurrentProject( project );
session.setProjects( Arrays.asList( project ) );
session.setCurrentProject(project);
session.setProjects(Arrays.asList(project));
return session;
}

/** As {@link #lookupConfiguredMojo(MavenProject, String)} but taking the pom file
* and creating the {@link MavenProject}. */
/**
* As {@link #lookupConfiguredMojo(MavenProject, String)} but taking the pom file and creating
* the {@link MavenProject}.
*/
protected Mojo lookupConfiguredMojo(File pom, String goal) throws Exception {
assertNotNull( pom );
assertTrue( pom.exists() );
assertNotNull(pom);
assertTrue(pom.exists());

ProjectBuildingRequest buildingRequest = newMavenSession().getProjectBuildingRequest();
ProjectBuilder projectBuilder = lookup(ProjectBuilder.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package uk.gov.justice.raml.maven.generator;

import org.raml.model.Raml;
import uk.gov.justice.raml.core.Generator;
import uk.gov.justice.raml.core.GeneratorConfig;

import org.raml.model.Raml;

/**
* Generator for testing - the RAML and configuration are captured by the DummyGeneratorCaptor singleton class to be further used in unit tests.
* Generator for testing - the RAML and configuration are captured by the DummyGeneratorCaptor
* singleton class to be further used in unit tests.
*/
public class DummyGenerator implements Generator {

Expand Down
Loading

0 comments on commit 18bb0ef

Please sign in to comment.