List of usage examples for org.apache.maven.project MavenProject MavenProject
public MavenProject()
From source file:com.autentia.mvn.plugin.release.bugzilla.BugzillaReleaseMojo.java
License:Open Source License
public static void main(final String[] args) { try {/* w w w .jav a 2 s.c om*/ if (args == null || args.length < 4) { printUsage(); } final MavenProject project = new MavenProject(); final IssueManagement issueManagement = new IssueManagement(); project.setIssueManagement(issueManagement); final BugzillaReleaseMojo mojo = new BugzillaReleaseMojo(); mojo.setProject(project); Prompter prompter = null; prompter = new com.autentia.mvn.plugin.release.bugzilla.Prompter(); mojo.setPrompter(prompter); int argsIndex = 0; while (argsIndex < args.length) { argsIndex = processArgs(argsIndex, mojo, args); } mojo.execute(); } catch (final InitializationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (final MojoExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.github.born2snipe.maven.plugin.idea.BaseMojoTestCase.java
License:Apache License
@Before public void baseSetUp() throws Exception { buildOutputDir = temporaryFolder.newFolder("project-output-dir"); buildDir = temporaryFolder.newFolder("build-dir"); mavenRepoDir = temporaryFolder.newFolder("maven-repo"); Build build = new Build(); build.setOutputDirectory(buildOutputDir.getAbsolutePath()); mavenProject = new MavenProject(); mavenProject.setName("plugin-name"); mavenProject.setArtifacts(new HashSet<>()); mavenProject.setBuild(build);/*from w ww .j av a 2 s.c om*/ }
From source file:com.thoughtworks.gauge.maven.tests.GaugeExecutionMojoTestCase.java
License:Open Source License
public void testGetCommandWithDirProjectBaseDir() throws Exception { File testPom = getPomFile("simple-config.xml"); MavenProject project = new MavenProject(); project.setFile(testPom);/*from w ww . j a v a 2s. c o m*/ GaugeExecutionMojo mojo = (GaugeExecutionMojo) lookupConfiguredMojo(project, GaugeExecutionMojo.GAUGE_EXEC_MOJO_NAME); ArrayList<String> actual = mojo.createGaugeCommand(); String directory = testPom.getParentFile().getAbsolutePath(); List<String> expected = Arrays.asList("gauge", "--dir=" + directory, "specs"); assertEquals(expected, actual); }
From source file:org.andromda.maven.plugin.bootstrap.install.BootstrapInstallMojo.java
/** * Clears the POM's model of its parent or any dependencies * it may have so that we can write a POM that isn't dependent on anything * (which we need for bootstrap artifacts). * * @param bootstrapPomFile the bootstrap POM file to write. *///from w ww .j a va 2 s.c o m private void writeMinimalPom(final File bootstrapPomFile) throws IOException { final Model model = this.project.getModel(); final MavenProject minimalProject = new MavenProject(); final Model minModel = minimalProject.getModel(); minModel.setGroupId(getBootstrapGroupId(this.project.getArtifact())); minModel.setArtifactId(model.getArtifactId()); minModel.setVersion(model.getVersion()); minModel.setName(model.getName()); minModel.setPackaging("jar"); minModel.setDescription(model.getDescription()); minModel.setModelEncoding(model.getModelEncoding()); minModel.setModelVersion(model.getModelVersion()); minModel.setUrl(model.getUrl()); minModel.setScm(model.getScm()); minModel.setDevelopers(model.getDevelopers()); minModel.setCiManagement(model.getCiManagement()); minModel.setIssueManagement(model.getIssueManagement()); minModel.setPrerequisites(model.getPrerequisites()); minModel.setOrganization(model.getOrganization()); minModel.setInceptionYear(model.getInceptionYear()); minModel.setLicenses(model.getLicenses()); final List<Dependency> dependencies = new ArrayList<Dependency>(model.getDependencies()); // filter all of andromda dependencies away CollectionUtils.filter(dependencies, new Predicate() { public boolean evaluate(Object object) { Dependency dependency = (Dependency) object; final String lGroupId = dependency.getGroupId(); return !lGroupId.startsWith("org.andromda") || lGroupId.startsWith("org.andromda.thirdparty"); } }); minModel.setDependencies(dependencies); final FileWriter fileWriter = new FileWriter(bootstrapPomFile); minimalProject.writeModel(fileWriter); fileWriter.flush(); }
From source file:org.apache.openejb.maven.plugin.TomEEMavenPluginRule.java
License:Apache License
protected static <T extends AbstractTomEEMojo> T defaults(final T tomEEMojo) { // settings/*from w w w .j a va 2 s .c o m*/ final File settingsXml = new File(System.getProperty("user.home") + "/.m2/settings.xml"); if (settingsXml.exists()) { try { final FileReader reader = new FileReader(settingsXml); try { tomEEMojo.settings = new SettingsXpp3Reader().read(reader, false); } finally { reader.close(); } } catch (final Exception e) { // no-op } } tomEEMojo.project = new MavenProject() { @Override public Set getArtifacts() { return Collections.emptySet(); } }; if (tomEEMojo.settings == null) { tomEEMojo.settings = new Settings(); } tomEEMojo.settings.setOffline(true); if (tomEEMojo.settings.getLocalRepository() == null || "".equals(tomEEMojo.settings.getLocalRepository())) { tomEEMojo.settings.setLocalRepository( System.getProperty("openejb.m2.home", System.getProperty("user.home") + "/.m2/repository")); } // we don't deploy anything by default tomEEMojo.skipCurrentProject = true; // our well known web profile ;) tomEEMojo.tomeeGroupId = "org.apache.tomee"; tomEEMojo.tomeeArtifactId = "apache-tomee"; tomEEMojo.tomeeVersion = OpenEjbVersion.get().getVersion(); tomEEMojo.tomeeClassifier = "webprofile"; tomEEMojo.tomeeType = "zip"; // target config tomEEMojo.catalinaBase = new File("target/mvn-test"); Files.mkdirs(tomEEMojo.catalinaBase); // some defaults tomEEMojo.simpleLog = true; tomEEMojo.quickSession = true; tomEEMojo.libDir = "lib"; tomEEMojo.webappDir = "webapps"; tomEEMojo.appDir = "apps"; tomEEMojo.bin = new File(tomEEMojo.catalinaBase.getPath() + "-bin"); tomEEMojo.config = new File(tomEEMojo.catalinaBase.getPath() + "-conf"); tomEEMojo.lib = new File(tomEEMojo.catalinaBase.getPath() + "-lib"); tomEEMojo.tomeeHttpPort = Integer.toString(NetworkUtil.getNextAvailablePort()); tomEEMojo.tomeeAjpPort = Integer.toString(NetworkUtil.getNextAvailablePort()); tomEEMojo.tomeeShutdownPort = Integer.toString(NetworkUtil.getNextAvailablePort()); tomEEMojo.tomeeShutdownCommand = "SHUTDOWN"; tomEEMojo.tomeeHost = "localhost"; tomEEMojo.useConsole = true; tomEEMojo.checkStarted = true; tomEEMojo.overrideOnUnzip = true; tomEEMojo.skipRootFolderOnUnzip = true; // we mock all the artifact resolution in test tomEEMojo.remoteRepos = new LinkedList<ArtifactRepository>(); tomEEMojo.local = new DefaultArtifactRepository("local", tomEEMojo.settings.getLocalRepository(), new DefaultRepositoryLayout()); tomEEMojo.factory = ArtifactFactory.class .cast(Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[] { ArtifactFactory.class }, new InvocationHandler() { @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { return new DefaultArtifact(String.class.cast(args[0]), String.class.cast(args[1]), VersionRange.class.cast(args[2]), String.class.cast(args[5]), String.class.cast(args[3]), args[4] == null ? "" : String.class.cast(args[4]), null) { @Override public File getFile() { return new File(tomEEMojo.settings.getLocalRepository(), getGroupId().replace('.', '/') + '/' + getArtifactId().replace('.', '/') + '/' + getVersion() + '/' + getArtifactId().replace('.', '/') + '-' + getVersion() + (args[4] == null ? "" : '-' + getClassifier()) + '.' + getType()); } }; } })); tomEEMojo.resolver = ArtifactResolver.class .cast(Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[] { ArtifactResolver.class }, new InvocationHandler() { @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { return null; } })); return tomEEMojo; }
From source file:org.codehaus.griffon.maven.plugin.tools.DefaultGriffonServices.java
License:Apache License
public MavenProject createPOM(String groupId, GriffonProject griffonProjectDescriptor, String mtgGroupId, String griffonPluginArtifactId, String mtgVersion, boolean addEclipseSettings) { MavenProject pom = new MavenProject(); if (pom.getBuild().getPluginManagement() == null) { pom.getBuild().setPluginManagement(new PluginManagement()); }// w ww.j ava 2 s . com PluginManagement pluginMgt = pom.getPluginManagement(); // Those four properties are needed. pom.setModelVersion("4.0.0"); pom.setPackaging("griffon-app"); // Specific for GRAILS pom.getModel().getProperties().setProperty("griffonHome", "${env.GRIFFON_HOME}"); pom.getModel().getProperties().setProperty("griffonVersion", griffonProjectDescriptor.getAppGriffonVersion()); // Add our own plugin Plugin griffonPlugin = new Plugin(); griffonPlugin.setGroupId(mtgGroupId); griffonPlugin.setArtifactId(griffonPluginArtifactId); griffonPlugin.setVersion(mtgVersion); griffonPlugin.setExtensions(true); pom.addPlugin(griffonPlugin); // Add compiler plugin settings Plugin compilerPlugin = new Plugin(); compilerPlugin.setGroupId("org.apache.maven.plugins"); compilerPlugin.setArtifactId("maven-compiler-plugin"); Xpp3Dom compilerConfig = new Xpp3Dom("configuration"); Xpp3Dom source = new Xpp3Dom("source"); source.setValue("1.5"); compilerConfig.addChild(source); Xpp3Dom target = new Xpp3Dom("target"); target.setValue("1.5"); compilerConfig.addChild(target); compilerPlugin.setConfiguration(compilerConfig); pom.addPlugin(compilerPlugin); // Add eclipse plugin settings if (addEclipseSettings) { Plugin eclipsePlugin = new Plugin(); eclipsePlugin.setGroupId("org.apache.maven.plugins"); eclipsePlugin.setArtifactId("maven-eclipse-plugin"); Xpp3Dom configuration = new Xpp3Dom("configuration"); Xpp3Dom projectnatures = new Xpp3Dom("additionalProjectnatures"); Xpp3Dom projectnature = new Xpp3Dom("projectnature"); projectnature.setValue("org.codehaus.groovy.eclipse.groovyNature"); projectnatures.addChild(projectnature); configuration.addChild(projectnatures); Xpp3Dom additionalBuildcommands = new Xpp3Dom("additionalBuildcommands"); Xpp3Dom buildcommand = new Xpp3Dom("buildcommand"); buildcommand.setValue("org.codehaus.groovy.eclipse.groovyBuilder"); additionalBuildcommands.addChild(buildcommand); configuration.addChild(additionalBuildcommands); Xpp3Dom packaging = new Xpp3Dom("packaging"); packaging.setValue("zip"); configuration.addChild(packaging); eclipsePlugin.setConfiguration(configuration); pluginMgt.addPlugin(eclipsePlugin); } // Change the default output directory to generate classes pom.getModel().getBuild().setOutputDirectory("web-app/WEB-INF/classes"); pom.setArtifactId(griffonProjectDescriptor.getAppName()); pom.setName(griffonProjectDescriptor.getAppName()); pom.setGroupId(groupId); pom.setVersion(griffonProjectDescriptor.getAppVersion()); if (!griffonProjectDescriptor.getAppVersion().endsWith("SNAPSHOT")) { getLogger().warn("====================================================================="); getLogger().warn("If your project is currently in development, in accordance with maven "); getLogger().warn("standards, its version must be " + griffonProjectDescriptor.getAppVersion() + "-SNAPSHOT and not " + griffonProjectDescriptor.getAppVersion() + "."); getLogger().warn("Please, change your version in the application.properties descriptor"); getLogger().warn("and regenerate your pom."); getLogger().warn("====================================================================="); } return pom; }
From source file:org.eclipse.m2e.editor.xml.AbstractPOMEditorTestCase.java
License:Open Source License
protected void initializeSourceViewer() { // some test environments might not have a "real" display if (Display.getCurrent() != null) { Shell shell = null;//from www.j a v a2 s.c o m Composite parent = null; if (PlatformUI.isWorkbenchRunning()) { shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); } else { shell = new Shell(Display.getCurrent()); } parent = new Composite(shell, SWT.NONE); // dummy viewer sourceViewer = new DummyStructuredTextViewer(parent, null, null, false, SWT.NONE); sourceViewer.setMavenProject(new MavenProject()); } else { Assert.fail("Unable to run the test as a display must be available."); } configureSourceViewer(); }
From source file:org.grails.maven.plugin.tools.DefaultGrailsServices.java
License:Apache License
public MavenProject createPOM(final String groupId, final GrailsProject grailsProjectDescriptor, final String mtgGroupId, final String grailsPluginArtifactId, final String mtgVersion, final boolean addEclipseSettings) { final MavenProject pom = new MavenProject(); if (pom.getBuild().getPluginManagement() == null) { pom.getBuild().setPluginManagement(new PluginManagement()); }// w w w. jav a 2 s .c o m final PluginManagement pluginMgt = pom.getPluginManagement(); // Those four properties are needed. pom.setModelVersion("4.0.0"); pom.setPackaging("grails-app"); // Specific for GRAILS pom.getModel().getProperties().setProperty("grailsHome", "${env.GRAILS_HOME}"); pom.getModel().getProperties().setProperty("grailsVersion", grailsProjectDescriptor.getAppGrailsVersion()); // Add our own plugin final Plugin grailsPlugin = new Plugin(); grailsPlugin.setGroupId(mtgGroupId); grailsPlugin.setArtifactId(grailsPluginArtifactId); grailsPlugin.setVersion(mtgVersion); grailsPlugin.setExtensions(true); pom.addPlugin(grailsPlugin); // Add compiler plugin settings final Plugin compilerPlugin = new Plugin(); compilerPlugin.setGroupId("org.apache.maven.plugins"); compilerPlugin.setArtifactId("maven-compiler-plugin"); final Xpp3Dom compilerConfig = new Xpp3Dom("configuration"); final Xpp3Dom source = new Xpp3Dom("source"); source.setValue("1.5"); compilerConfig.addChild(source); final Xpp3Dom target = new Xpp3Dom("target"); target.setValue("1.5"); compilerConfig.addChild(target); compilerPlugin.setConfiguration(compilerConfig); pom.addPlugin(compilerPlugin); // Add eclipse plugin settings if (addEclipseSettings) { final Plugin warPlugin = new Plugin(); warPlugin.setGroupId("org.apache.maven.plugins"); warPlugin.setArtifactId("maven-war-plugin"); final Xpp3Dom warConfig = new Xpp3Dom("configuration"); final Xpp3Dom warSourceDirectory = new Xpp3Dom("warSourceDirectory"); warSourceDirectory.setValue("web-app"); warConfig.addChild(warSourceDirectory); warPlugin.setConfiguration(warConfig); pluginMgt.addPlugin(warPlugin); final Plugin eclipsePlugin = new Plugin(); eclipsePlugin.setGroupId("org.apache.maven.plugins"); eclipsePlugin.setArtifactId("maven-eclipse-plugin"); final Xpp3Dom configuration = new Xpp3Dom("configuration"); final Xpp3Dom projectnatures = new Xpp3Dom("additionalProjectnatures"); final Xpp3Dom projectnature = new Xpp3Dom("projectnature"); projectnature.setValue("org.codehaus.groovy.eclipse.groovyNature"); projectnatures.addChild(projectnature); configuration.addChild(projectnatures); final Xpp3Dom additionalBuildcommands = new Xpp3Dom("additionalBuildcommands"); final Xpp3Dom buildcommand = new Xpp3Dom("buildcommand"); buildcommand.setValue("org.codehaus.groovy.eclipse.groovyBuilder"); additionalBuildcommands.addChild(buildcommand); configuration.addChild(additionalBuildcommands); // Xpp3Dom additionalProjectFacets = new Xpp3Dom( // "additionalProjectFacets"); // Xpp3Dom jstWeb = new Xpp3Dom("jst.web"); // jstWeb.setValue("2.5"); // additionalProjectFacets.addChild(jstWeb); // configuration.addChild(additionalProjectFacets); final Xpp3Dom packaging = new Xpp3Dom("packaging"); packaging.setValue("war"); configuration.addChild(packaging); eclipsePlugin.setConfiguration(configuration); pluginMgt.addPlugin(eclipsePlugin); } // Change the default output directory to generate classes pom.getModel().getBuild().setOutputDirectory("web-app/WEB-INF/classes"); pom.setArtifactId(grailsProjectDescriptor.getAppName()); pom.setName(grailsProjectDescriptor.getAppName()); pom.setGroupId(groupId); pom.setVersion(grailsProjectDescriptor.getAppVersion()); if (!grailsProjectDescriptor.getAppVersion().endsWith("SNAPSHOT")) { getLogger().warn("====================================================================="); getLogger().warn("If your project is currently in development, in accordance with maven "); getLogger().warn("standards, its version must be " + grailsProjectDescriptor.getAppVersion() + "-SNAPSHOT and not " + grailsProjectDescriptor.getAppVersion() + "."); getLogger().warn("Please, change your version in the application.properties descriptor"); getLogger().warn("and regenerate your pom."); getLogger().warn("====================================================================="); } return pom; }
From source file:org.metaeffekt.dcc.bundle.maven.FilterLibsMojo.java
License:Apache License
public static void main(String[] args) throws MojoExecutionException, MojoFailureException { FilterLibsMojo mojo = new FilterLibsMojo(); mojo.setLibDir(// w w w. j av a 2 s .c om "C:/dev/workspace/ehi-system-integration-trunk/bundles/ehi-atna-integration/target/tmp/bundle-artifact/lib"); mojo.setLibPattern("*.jar"); mojo.setMetaDataDir( "C:/dev/workspace/ehi-system-integration-trunk/bundles/ehi-atna-integration/target/tmp/filter"); mojo.setMetaDataPattern("**/lib.metadata"); mojo.setProject(new MavenProject()); mojo.setLog(new Log() { @Override public void warn(CharSequence arg0, Throwable arg1) { } @Override public void warn(Throwable arg0) { } @Override public void warn(CharSequence arg0) { } @Override public boolean isWarnEnabled() { return false; } @Override public boolean isInfoEnabled() { return false; } @Override public boolean isErrorEnabled() { return false; } @Override public boolean isDebugEnabled() { return false; } @Override public void info(CharSequence arg0, Throwable arg1) { System.out.println(arg0); } @Override public void info(Throwable arg0) { System.out.println(arg0); } @Override public void info(CharSequence arg0) { System.out.println(arg0); } @Override public void error(CharSequence arg0, Throwable arg1) { System.out.println(arg0); } @Override public void error(Throwable arg0) { } @Override public void error(CharSequence arg0) { } @Override public void debug(CharSequence arg0, Throwable arg1) { } @Override public void debug(Throwable arg0) { } @Override public void debug(CharSequence arg0) { } }); mojo.execute(); }
From source file:org.opencredo.maven.plugins.enforcer.MockPlexusContainer.java
License:Apache License
public Object lookup(String theComponentKey) throws ComponentLookupException { if (theComponentKey.equals(MavenProject.class.getName())) { return new MavenProject(); } else if (theComponentKey.equals(RuntimeInformation.class.getName())) { return new MockRuntimeInformation(); }//from w w w . ja va 2 s.com return registeredComponents.get(theComponentKey); }