All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.choncms.maven.PluginCreatorMojo Maven / Gradle / Ivy

There is a newer version: 1.3
Show newest version
package com.choncms.maven;

import java.io.IOException;
import java.util.Map;

/**
 * Goal which creates new chon based OSGi bundle
 * 
 * @requiresProject false
 * @goal new-plugin
 */
public class PluginCreatorMojo extends AbstractCreatorMojo {
	private String projectGroupId = "org.choncms";
	private String projectPackage = "org.chon.my.plugin";
	private String projectName = "My Plugin";
	private String projectVersion = "1.0.0-SNAPSHOT";

	private String projectParentGroupId = "org.choncms";
	private String projectParentArtifactId = "bundles";
	private String projectParentVersion = "0.0.1-SNAPSHOT";
	private String projectParentPomRelPath = "../pom.xml";

	@Override
	protected Map getTemplateVariables() {
		Map tplVars = super.getTemplateVariables();
		try {
			System.out.println("Please enter values from your new plugin. "
					+ "Leave blank for default");

			projectGroupId = getValue("Project GroupId", projectGroupId);
			projectPackage = getValue("Project Package", projectPackage);
			projectName = getValue("Project Name", projectName);
			projectVersion = getValue("Project Version", projectVersion);

			System.out
					.println("Describe parent project. "
							+ "Chon plugin mush have parent pom where target platform is defined. "
							+ "Leave blank for default");
			projectParentGroupId = getValue("Parent GroupId",
					projectParentGroupId);
			projectParentArtifactId = getValue("Parent ArtifactId",
					projectParentArtifactId);
			projectParentVersion = getValue("Parent Verstion",
					projectParentVersion);
			projectParentPomRelPath = getValue("Parent Pom Relative Path",
					projectParentPomRelPath);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		populateTemplateVariables(tplVars);
		return tplVars;
	}

	private void populateTemplateVariables(Map templateVarsMap) {
		templateVarsMap.put("project-groupId", projectGroupId);
		templateVarsMap.put("project-package", projectPackage);
		templateVarsMap.put("project-name", projectName);
		templateVarsMap.put("project-version", projectVersion);

		templateVarsMap.put("project-parent-groupId", projectParentGroupId);
		templateVarsMap.put("project-parent-artifactId",
				projectParentArtifactId);
		templateVarsMap.put("project-parent-version", projectParentVersion);
		templateVarsMap.put("project-parent-pom-relativePath",
				projectParentPomRelPath);
	}

	@Override
	protected String getProjectType() {
		return "plugin";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy