Files
2016-07-20 15:03:20 +02:00

70 lines
4.7 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>CopyContracts.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Spring Cloud Contract Maven Plugin</a> &gt; <a href="index.source.html" class="el_package">org.springframework.cloud.contract.maven.verifier</a> &gt; <span class="el_source">CopyContracts.java</span></div><h1>CopyContracts.java</h1><pre class="source lang-java linenums">/*
* Copyright 2013-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.maven.verifier;
import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.Collections;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.filtering.MavenFilteringException;
import org.apache.maven.shared.filtering.MavenResourcesExecution;
import org.apache.maven.shared.filtering.MavenResourcesFiltering;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CopyContracts {
<span class="fc" id="L33"> private static final Logger log = LoggerFactory</span>
<span class="fc" id="L34"> .getLogger(MethodHandles.lookup().lookupClass());</span>
private final MavenProject project;
private final MavenSession mavenSession;
private final MavenResourcesFiltering mavenResourcesFiltering;
public CopyContracts(MavenProject project, MavenSession mavenSession,
<span class="fc" id="L40"> MavenResourcesFiltering mavenResourcesFiltering) {</span>
<span class="fc" id="L41"> this.project = project;</span>
<span class="fc" id="L42"> this.mavenSession = mavenSession;</span>
<span class="fc" id="L43"> this.mavenResourcesFiltering = mavenResourcesFiltering;</span>
<span class="fc" id="L44"> }</span>
public void copy(File contractsDirectory, File outputDirectory)
throws MojoExecutionException {
<span class="fc" id="L48"> log.info(&quot;Copying Spring Cloud Contract Verifier contracts&quot;);</span>
<span class="fc" id="L49"> Resource resource = new Resource();</span>
<span class="fc" id="L50"> resource.setDirectory(contractsDirectory.getAbsolutePath());</span>
<span class="fc" id="L51"> MavenResourcesExecution execution = new MavenResourcesExecution();</span>
<span class="fc" id="L52"> execution.setResources(Collections.singletonList(resource));</span>
<span class="fc" id="L53"> execution.setOutputDirectory(new File(outputDirectory, &quot;contracts&quot;));</span>
<span class="fc" id="L54"> execution.setMavenProject(project);</span>
<span class="fc" id="L55"> execution.setEncoding(&quot;UTF-8&quot;);</span>
<span class="fc" id="L56"> execution.setMavenSession(mavenSession);</span>
<span class="fc" id="L57"> execution.setInjectProjectBuildFilters(false);</span>
<span class="fc" id="L58"> execution.setOverwrite(true);</span>
<span class="fc" id="L59"> execution.setIncludeEmptyDirs(false);</span>
<span class="fc" id="L60"> execution.setFilterFilenames(false);</span>
try {
<span class="fc" id="L62"> mavenResourcesFiltering.filterResources(execution);</span>
}
<span class="nc" id="L64"> catch (MavenFilteringException e) {</span>
<span class="nc" id="L65"> throw new MojoExecutionException(e.getMessage(), e);</span>
<span class="fc" id="L66"> }</span>
<span class="fc" id="L68"> }</span>
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.4.201502262128</span></div></body></html>