
io.fabric8.cxf.maven.Java2SwaggerJsonMojo Maven / Gradle / Ivy
/**
* Copyright 2005-2016 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); 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 "AS IS" 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 io.fabric8.cxf.maven;
import io.fabric8.cxf.endpoint.SwaggerFeature;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.Feature;
import org.apache.cxf.helpers.FileUtils;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
/**
* @goal java2swagger
* @description CXF Java To swagger json payload Tool
* @requiresDependencyResolution test
* @threadSafe
*/
public class Java2SwaggerJsonMojo extends AbstractMojo {
/**
* @parameter
*/
private String outputFile;
/**
* Attach the generated swagger json file to the list of files to be deployed
* on install. This means the swagger json file will be copied to the repository
* with groupId, artifactId and version of the project and type "json".
*
* With this option you can use the maven repository as a Service Repository.
*
* @parameter default-value="true"
*/
private Boolean attachSwagger;
/**
* @parameter
*/
private String classifier;
/**
* @parameter
* @required
*/
private List classResourceNames;
/**
* @parameter expression="${project}"
* @required
*/
private MavenProject project;
/**
* Maven ProjectHelper.
*
* @component
* @readonly
*/
private MavenProjectHelper projectHelper;
/**
* @parameter
*/
private String outputFileName;
/**
* @parameter default-value="json"
*/
private String outputFileExtension;
/**
* @parameter default-value="http://localhost:12333/cxf/swagger"
*/
private String address;
private ClassLoader resourceClassLoader;
public void execute() throws MojoExecutionException {
List> resourceClasses = loadResourceClasses();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy