本文整理汇总了Java中org.apache.maven.model.Plugin类的典型用法代码示例。如果您正苦于以下问题:Java Plugin类的具体用法?Java Plugin怎么用?Java Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Plugin类属于org.apache.maven.model包,在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToPomForIndexingTmpBundles
import org.apache.maven.model.Plugin; //导入依赖的package包/类
public void addToPomForIndexingTmpBundles(MavenProject project) throws MavenExecutionException {
Path genertedModules;
try {
genertedModules = Constants.getGeneratedModulesFolder(project);
} catch (IOException e) {
throw new MavenExecutionException(e.getMessage(), e);
}
String configuration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" //
+ "<configuration>" //
+ " <inputDir>" //
+ genertedModules //
+ " </inputDir>" //
+ " <outputFile>${project.build.directory}/index/index.xml</outputFile>" //
+ "</configuration>"; //
Plugin plugin = createPlugin("biz.aQute.bnd", "bnd-indexer-maven-plugin", VAL_BND_VERSION, configuration,
"index", "local-index", null);
project.getBuild().getPlugins().add(0, plugin);
logger.info("Added `bnd-indexer-maven-plugin` to genrate an index of detected modules!");
}
示例2: configureJarPlugin
import org.apache.maven.model.Plugin; //导入依赖的package包/类
private void configureJarPlugin(MavenProject project) throws MavenExecutionException {
Plugin jarPlugin = getPlugin(project, "org.apache.maven.plugins:maven-jar-plugin");
if (jarPlugin != null) {
StringBuilder jarConfig = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") //
.append("<configuration>") //
.append(" <archive>\n") //
.append(" <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>\n") //
.append(" </archive>") //
.append(" <annotationProcessorPaths>") //
.append(" <annotationProcessorPath>") //
.append(" <groupId>com.commsen.em</groupId>") //
.append(" <artifactId>em.annotation.processors</artifactId>") //
.append(" <version>").append(Constants.VAL_EXTENSION_VERSION).append("</version>") //
.append(" </annotationProcessorPath>") //
.append(" </annotationProcessorPaths>") //
.append("</configuration>");
configurePlugin(jarPlugin, "default-jar", jarConfig.toString());
}
}
示例3: createPlugin
import org.apache.maven.model.Plugin; //导入依赖的package包/类
protected Plugin createPlugin(String groupId, String artifactId, String version, String configuration,
String executionId, String goal, String phase) throws MavenExecutionException {
Plugin plugin = new Plugin();
plugin.setGroupId(groupId);
plugin.setArtifactId(artifactId);
plugin.setVersion(version);
PluginExecution execution = new PluginExecution();
execution.setId(executionId);
execution.addGoal(goal);
if (phase != null) {
execution.setPhase(phase);
}
if (configuration != null) {
execution.setConfiguration(mavenConfig.asXpp3Dom(configuration));
}
plugin.addExecution(execution);
return plugin;
}
示例4: findVersion
import org.apache.maven.model.Plugin; //导入依赖的package包/类
private String findVersion(String groupId, String artifactId) {
String key = groupId + ":" + artifactId;
List<Plugin> plugins = new ArrayList<Plugin>();
if (project != null) {
List<Plugin> bld = project.getOriginalMavenProject().getBuildPlugins();
if (bld != null) {
plugins.addAll(bld);
}
if (project.getOriginalMavenProject().getPluginManagement() != null) {
List<Plugin> pm = project.getOriginalMavenProject().getPluginManagement().getPlugins();
if (pm != null) {
plugins.addAll(pm);
}
}
}
for (Plugin plg : plugins) {
if (key.equals(plg.getKey())) {
return plg.getVersion();
}
}
return null;
}
示例5: getPluginExecutions
import org.apache.maven.model.Plugin; //导入依赖的package包/类
/** @see org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator */
private static @NonNull List<PluginExecution> getPluginExecutions(@NonNull Plugin plug, @NullAllowed String goal) {
if (goal == null) {
return Collections.emptyList();
}
List<PluginExecution> exes = new ArrayList<PluginExecution>();
for (PluginExecution exe : plug.getExecutions()) {
if (exe.getGoals().contains(goal) || /* #179328: Maven 2.2.0+ */ ("default-" + goal).equals(exe.getId())) {
exes.add(exe);
}
}
Collections.sort(exes, new Comparator<PluginExecution>() {
@Override public int compare(PluginExecution e1, PluginExecution e2) {
return e2.getPriority() - e1.getPriority();
}
});
return exes;
}
示例6: writePluginManagement
import org.apache.maven.model.Plugin; //导入依赖的package包/类
private void writePluginManagement(PluginManagement pluginManagement, String tagName, XmlSerializer serializer)
throws java.io.IOException {
serializer.startTag(NAMESPACE, tagName);
flush(serializer);
StringBuffer b = b(serializer);
int start = b.length();
if ((pluginManagement.getPlugins() != null) && (pluginManagement.getPlugins().size() > 0)) {
serializer.startTag(NAMESPACE, "plugins");
for (Iterator iter = pluginManagement.getPlugins().iterator(); iter.hasNext();) {
Plugin o = (Plugin) iter.next();
writePlugin(o, "plugin", serializer);
}
serializer.endTag(NAMESPACE, "plugins");
}
serializer.endTag(NAMESPACE, tagName).flush();
logLocation(pluginManagement, "", start, b.length());
}
示例7: resolve
import org.apache.maven.model.Plugin; //导入依赖的package包/类
@Override
public Artifact resolve(Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session) throws PluginResolutionException {
WorkspaceReader wr = session.getWorkspaceReader();
NbWorkspaceReader nbwr = null;
if (wr instanceof NbWorkspaceReader) {
nbwr = (NbWorkspaceReader)wr;
//this only works reliably because the NbWorkspaceReader is part of the session, not a component
nbwr.silence();
}
try {
return super.resolve(plugin, repositories, session);
} finally {
if (nbwr != null) {
nbwr.normal();
}
}
}
示例8: addPluginWithVersionTest
import org.apache.maven.model.Plugin; //导入依赖的package包/类
@Test
public void addPluginWithVersionTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().size(), 1);
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");
PomAddPlugin pomAddPlugin = new PomAddPlugin("org.apache.maven.plugins", "maven-javadoc-plugin", "2.10.4").relative("pom.xml");
TOExecutionResult executionResult = pomAddPlugin.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
Model pomModelAfterChange = getTransformedPomModel("pom.xml");
assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 2);
Plugin plugin = new Plugin();
plugin.setGroupId("org.apache.maven.plugins");
plugin.setArtifactId("maven-javadoc-plugin");
assertTrue(pomModelAfterChange.getBuild().getPlugins().contains(plugin));
assertEquals(pomModelAfterChange.getBuild().getPluginsAsMap().get("org.apache.maven.plugins:maven-javadoc-plugin").getVersion(), "2.10.4");
}
示例9: addPluginWithoutVersionTest
import org.apache.maven.model.Plugin; //导入依赖的package包/类
@Test
public void addPluginWithoutVersionTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().size(), 1);
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");
PomAddPlugin pomAddPlugin = new PomAddPlugin("org.apache.maven.plugins", "maven-javadoc-plugin").relative("pom.xml");
TOExecutionResult executionResult = pomAddPlugin.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
Model pomModelAfterChange = getTransformedPomModel("pom.xml");
assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 2);
Plugin plugin = new Plugin();
plugin.setGroupId("org.apache.maven.plugins");
plugin.setArtifactId("maven-javadoc-plugin");
assertTrue(pomModelAfterChange.getBuild().getPlugins().contains(plugin));
assertNull(pomModelAfterChange.getBuild().getPluginsAsMap().get("org.apache.maven.plugins:maven-javadoc-plugin").getVersion());
}
示例10: getNonFilteredFileExtensions
import org.apache.maven.model.Plugin; //导入依赖的package包/类
private List<String> getNonFilteredFileExtensions(List<Plugin> plugins) {
for (Plugin plugin : plugins) {
if (MAVEN_RESOURCES_PLUGIN.equals(plugin.getArtifactId())) {
final Object configuration = plugin.getConfiguration();
if (configuration != null) {
Xpp3Dom xpp3Dom = (Xpp3Dom) configuration;
final Xpp3Dom nonFilteredFileExtensions = xpp3Dom.getChild(NON_FILTERED_FILE_EXTENSIONS);
List<String> nonFilteredFileExtensionsList = new ArrayList<>();
final Xpp3Dom[] children = nonFilteredFileExtensions.getChildren();
for (Xpp3Dom child : children) {
nonFilteredFileExtensionsList.add(child.getValue());
}
return nonFilteredFileExtensionsList;
}
}
}
return null;
}
示例11: configureTestRunner
import org.apache.maven.model.Plugin; //导入依赖的package包/类
boolean configureTestRunner(Model model) {
final List<Plugin> effectiveTestRunnerPluginConfigurations = getEffectivePlugins(model);
if (!effectiveTestRunnerPluginConfigurations.isEmpty()) {
logger.debug("Enabling Smart Testing %s for plugin %s in %s module", ExtensionVersion.version().toString(),
effectiveTestRunnerPluginConfigurations.stream()
.map(Plugin::getArtifactId)
.collect(Collectors.toList()).toString(), model.getArtifactId());
dependencyResolver.addRequiredDependencies(model);
effectiveTestRunnerPluginConfigurations
.forEach(plugin -> {
dependencyResolver.removeAndRegisterFirstCustomProvider(model, plugin);
dependencyResolver.addAsPluginDependency(plugin);
});
return true;
} else {
logger.debug("Disabling Smart Testing %s in %s module. Reason: No executable test plugin is set.",
ExtensionVersion.version().toString(), model.getArtifactId());
return false;
}
}
示例12: should_remove_custom_provider_dependency_and_create_info_file_when_set_in_config
import org.apache.maven.model.Plugin; //导入依赖的package包/类
@Test
public void should_remove_custom_provider_dependency_and_create_info_file_when_set_in_config() {
// given
Configuration config = ConfigurationLoader.load(tmpFolder);
config.setCustomProviders(new String[] {"org.foo.provider:my-custom-provider=org.foo.impl.SurefireProvider"});
DependencyResolver dependencyResolver = new DependencyResolver(config);
Dependency customDep = createDependency("org.foo.provider", "my-custom-provider", "1.2.3");
Model model = Mockito.mock(Model.class);
Plugin plugin = prepareModelWithPluginDep(model, customDep);
// when
dependencyResolver.removeAndRegisterFirstCustomProvider(model, plugin);
// then
verifyDependencyIsRemovedAndFileCreated(plugin, customDep, "org.foo.impl.SurefireProvider");
}
示例13: merge
import org.apache.maven.model.Plugin; //导入依赖的package包/类
public void merge(
MavenProject project,
Plugin mergePlugin) {
if (mergePlugin.getArtifactId() == null || mergePlugin.getArtifactId().isEmpty()) {
return;
}
List<Plugin> plugins = project.getBuild().getPlugins();
Plugin foundPlugin = null;
for (Plugin plugin : plugins) {
if (mergePlugin.getGroupId().equals(plugin.getGroupId())
&& mergePlugin.getArtifactId().equals(plugin.getArtifactId())) {
foundPlugin = plugin;
break;
}
}
if (foundPlugin == null) {
plugins.add(mergePlugin);
} else {
mergeExecutions(foundPlugin.getExecutions(), mergePlugin.getExecutions());
}
}
示例14: getEnforcerPlugin
import org.apache.maven.model.Plugin; //导入依赖的package包/类
public Plugin getEnforcerPlugin(MavenProject project)
throws MavenExecutionException {
StringBuilder configString = new StringBuilder()
.append("<configuration><rules>")
.append("<requireReleaseDeps><message>No Snapshots Allowed!</message><excludes><exclude>"+project.getGroupId()+":*</exclude></excludes></requireReleaseDeps>")
.append("</rules></configuration>");
Xpp3Dom config = null;
try {
config = Xpp3DomBuilder.build(new StringReader(configString.toString()));
} catch (XmlPullParserException | IOException ex) {
throw new MavenExecutionException("Issue creating cofig for enforcer plugin", ex);
}
PluginExecution execution = new PluginExecution();
execution.setId("no-snapshot-deps");
execution.addGoal("enforce");
execution.setConfiguration(config);
Plugin result = new Plugin();
result.setArtifactId("maven-enforcer-plugin");
result.setVersion("1.4.1");
result.addExecution(execution);
return result;
}
示例15: testMerge_pluginFoundWithNoExecutions
import org.apache.maven.model.Plugin; //导入依赖的package包/类
@Test
public void testMerge_pluginFoundWithNoExecutions() {
Plugin buildPlugin = new Plugin();
buildPlugin.setArtifactId("merge-artifact");
List<Plugin> plugins = project.getBuild().getPlugins();
plugins.addAll(dummyPlugins);
plugins.add(buildPlugin);
PluginExecution exec = new PluginExecution();
exec.setId("merge-execution-id");
exec.setGoals(Arrays.asList("some-goal"));
exec.setPhase("random-phase");
exec.setPriority(1);
Plugin mergePlugin = new Plugin();
mergePlugin.setArtifactId("merge-artifact");
mergePlugin.getExecutions().add(exec);
item.merge(project, mergePlugin);
Assert.assertEquals("Plugins.Size", dummyPlugins.size() + 1, project.getBuildPlugins().size());
for (int i = 0; i < dummyPlugins.size(); i++) {
Assert.assertThat("Plugins["+i+"]", project.getBuildPlugins().get(i), Matchers.sameBeanAs(dummyPlugins.get(i)));
}
Assert.assertThat("Plugins["+dummyPlugins.size()+"]", project.getBuildPlugins().get(dummyPlugins.size()), Matchers.sameBeanAs(mergePlugin));
}