Java Code Examples for org.apache.maven.model.Model#setPackaging()
The following examples show how to use
org.apache.maven.model.Model#setPackaging() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExportServiceAction.java From tesb-studio-se with Apache License 2.0 | 6 votes |
protected ITalendProcessJavaProject createServiceJavaProject() { IProgressMonitor monitor = new NullProgressMonitor(); // temp model. Model model = new Model(); model.setModelVersion("4.0.0"); //$NON-NLS-1$ model.setGroupId(PomIdsHelper.getJobGroupId(serviceItem.getProperty())); model.setArtifactId(PomIdsHelper.getJobArtifactId(serviceItem.getProperty())); // $NON-NLS-1$ model.setVersion(PomIdsHelper.getProjectVersion()); model.setPackaging(TalendMavenConstants.PACKAGING_JAR); // always use temp model to avoid classpath problem final ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration(); IProject root = ResourcesPlugin.getWorkspace().getRoot() .getProject(ProjectManager.getInstance().getCurrentProject().getTechnicalLabel()); try { return createSimpleProject(monitor, root, model, importConfiguration); } catch (CoreException e) { e.printStackTrace(); } return null; }
Example 2
Source File: DefaultFileUploadService.java From archiva with Apache License 2.0 | 6 votes |
private StorageAsset createPom(StorageAsset targetPath, String filename, FileMetadata fileMetadata, String groupId, String artifactId, String version, String packaging) throws IOException { Model projectModel = new Model(); projectModel.setModelVersion("4.0.0"); projectModel.setGroupId(groupId); projectModel.setArtifactId(artifactId); projectModel.setVersion(version); projectModel.setPackaging(packaging); StorageAsset pomFile = targetPath.resolve(filename); MavenXpp3Writer writer = new MavenXpp3Writer(); try (Writer w = new OutputStreamWriter(pomFile.getWriteStream(true))) { writer.write(w, projectModel); } return pomFile; }
Example 3
Source File: PomChangePackaging.java From butterfly with MIT License | 5 votes |
@Override protected TOExecutionResult pomExecution(String relativePomFile, Model model) { model.setPackaging(packagingType); String details = String.format("Packaging for POM file %s has been changed to %s", relativePomFile, packagingType); return TOExecutionResult.success(this, details); }
Example 4
Source File: MavenUtils.java From developer-studio with Apache License 2.0 | 5 votes |
public static MavenProject createMavenProject(String groupId, String artifactId, String version, String packagingType) { Model model = new Model(); model.setGroupId(groupId); model.setArtifactId(artifactId); model.setVersion(version); model.setModelVersion("4.0.0"); model.setName(artifactId); model.setDescription(artifactId); if (packagingType!=null){ model.setPackaging(packagingType); } return new MavenProject(model); }
Example 5
Source File: BOMBuilderManipulator.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
private Model createModel( Project project, String s ) { final Model newModel = new Model(); newModel.setModelVersion( project.getModel().getModelVersion() ); newModel.setGroupId( project.getGroupId() + '.' + project.getArtifactId() ); newModel.setArtifactId( s ); newModel.setVersion( project.getVersion() ); newModel.setPackaging( "pom" ); return newModel; }
Example 6
Source File: PomIOTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test public void testRewritePOMs() throws Exception { URL resource = PomIOTest.class.getResource( filename ); assertNotNull( resource ); File pom = new File( resource.getFile() ); assertTrue( pom.exists() ); File targetFile = folder.newFile( "target.xml" ); FileUtils.writeStringToFile( targetFile, FileUtils.readFileToString( pom, StandardCharsets.UTF_8 ) .replaceAll( "dospom", "newdospom" ), StandardCharsets.UTF_8 ); FileUtils.copyFile( pom, targetFile ); List<Project> projects = pomIO.parseProject( targetFile ); Model model = projects.get( 0 ).getModel(); model.setGroupId( "org.commonjava.maven.ext.versioning.test" ); model.setArtifactId( "dospom" ); model.setVersion( "1.0" ); model.setPackaging( "pom" ); model.setModelVersion( "4.0.0" ); Project p = new Project( targetFile, model ); HashSet<Project> changed = new HashSet<>(); changed.add( p ); pomIO.rewritePOMs( changed ); assertTrue( FileUtils.contentEqualsIgnoreEOL( pom, targetFile, StandardCharsets.UTF_8.toString() ) ); assertTrue( FileUtils.contentEquals( targetFile, pom ) ); }
Example 7
Source File: PomIOTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test public void testGAVReturnPOMs() throws Exception { URL resource = PomIOTest.class.getResource( filename ); assertNotNull( resource ); File pom = new File( resource.getFile() ); assertTrue( pom.exists() ); File targetFile = folder.newFile( "target.xml" ); FileUtils.copyFile( pom, targetFile ); Model model = new Model(); model.setGroupId( "org.commonjava.maven.ext.versioning.test" ); model.setArtifactId( "dospom" ); model.setVersion( "1.0" ); model.setPackaging( "pom" ); model.setModelVersion( "4.0.0" ); Project p = new Project( targetFile, model ); p.setExecutionRoot(); HashSet<Project> changed = new HashSet<>(); changed.add( p ); ProjectVersionRef gav = pomIO.rewritePOMs( changed ); assertEquals( "1.0", gav.getVersionString() ); assertEquals( "org.commonjava.maven.ext.versioning.test", gav.getGroupId() ); assertEquals( "dospom", gav.getArtifactId() ); }
Example 8
Source File: PomIOTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test public void testWriteModel() throws Exception { // Thanks to http://www.buildmystring.com String sb = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\" xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + " <modelVersion>4.0.0</modelVersion>\n" + " <groupId>org.commonjava.maven.ext.versioning.test</groupId>\n" + " <artifactId>dospom</artifactId>\n" + " <version>1.0</version>\n" + " <packaging>pom</packaging>\n" + "</project>\n"; URL resource = PomIOTest.class.getResource( filename ); assertNotNull( resource ); File pom = new File( resource.getFile() ); assertTrue( pom.exists() ); File targetFile = folder.newFile( "target.xml" ); Model model = new Model(); model.setGroupId( "org.commonjava.maven.ext.versioning.test" ); model.setArtifactId( "dospom" ); model.setVersion( "1.0" ); model.setPackaging( "pom" ); model.setModelVersion( "4.0.0" ); pomIO.writeModel( model, targetFile ); assertTrue( targetFile.exists() ); assertEquals( sb, FileUtils.readFileToString( targetFile, StandardCharsets.UTF_8 ) ); }
Example 9
Source File: KumuluzeeServer.java From microprofile-starter with Apache License 2.0 | 4 votes |
@Override public void adaptMavenModel(Model pomFile, JessieModel model, boolean mainProject) { // KumuluzEE needs jar packaging pomFile.setPackaging("jar"); String kumuluzVersion = ""; String kumuluzeeConfigVersion = ""; String artifactId = ""; switch (model.getSpecification().getMicroProfileVersion()) { case NONE: break; case MP33: kumuluzVersion = "3.9.0"; kumuluzeeConfigVersion = "1.4.0"; artifactId = "kumuluzee-microProfile-3.3"; break; case MP32: kumuluzVersion = "3.7.0"; kumuluzeeConfigVersion = "1.3.0"; artifactId = "kumuluzee-microProfile-3.2"; break; case MP30: kumuluzVersion = "3.6.0"; kumuluzeeConfigVersion = "1.3.0"; artifactId = "kumuluzee-microProfile-3.0"; break; case MP22: kumuluzVersion = "3.5.0"; kumuluzeeConfigVersion = "1.3.0"; artifactId = "kumuluzee-microProfile-2.2"; break; case MP21: kumuluzVersion = "3.2.0"; kumuluzeeConfigVersion = "1.3.0"; artifactId = "kumuluzee-microProfile-2.1"; break; case MP20: kumuluzVersion = "3.2.0"; kumuluzeeConfigVersion = "1.3.0"; artifactId = "kumuluzee-microProfile-2.0"; break; case MP14: kumuluzVersion = "2.6.0"; kumuluzeeConfigVersion = "1.3.0"; artifactId = "kumuluzee-microProfile-1.4"; break; case MP13: kumuluzVersion = "2.6.0"; kumuluzeeConfigVersion = "1.3.0"; artifactId = "kumuluzee-microProfile-1.3"; break; case MP12: kumuluzVersion = "2.5.2"; kumuluzeeConfigVersion = "1.1.1"; artifactId = "kumuluzee-microProfile-1.2"; break; default: } pomFile.addProperty("kumuluz.version", kumuluzVersion); pomFile.addProperty("kumuluzee-config-mp.version", kumuluzeeConfigVersion); pomFile.addProperty("kumuluzee-microprofile.version", artifactId); }
Example 10
Source File: HelidonServer.java From microprofile-starter with Apache License 2.0 | 4 votes |
@Override public void adaptMavenModel(Model pomFile, JessieModel model, boolean mainProject) { // Helidon needs jar packaging pomFile.setPackaging("jar"); String packageName = model.getMaven().getGroupId() + '.' + model.getMaven().getArtifactId(); pomFile.addProperty("package", packageName); String helidonVersion = ""; String mpVersion = ""; switch (model.getSpecification().getMicroProfileVersion()) { case NONE: break; case MP32: helidonVersion = "1.4.1"; mpVersion = "3.2"; break; case MP30: helidonVersion = "1.3.1"; mpVersion = "3.0"; break; case MP22: helidonVersion = "1.2.0"; mpVersion = "2.2"; break; case MP21: break; case MP20: break; case MP14: break; case MP13: break; case MP12: helidonVersion = "1.0.1"; mpVersion = "1.2"; break; default: } pomFile.addProperty("helidonVersion", helidonVersion); pomFile.addProperty("mpVersion", mpVersion); }
Example 11
Source File: MavenCreator.java From microprofile-starter with Apache License 2.0 | 4 votes |
private Model createSingleModule(JessieModel model) { Model pomFile = new Model(); pomFile.setModelVersion("4.0.0"); pomFile.setGroupId(model.getMaven().getGroupId()); pomFile.setArtifactId(model.getMaven().getArtifactId()); pomFile.setVersion("1.0-SNAPSHOT"); pomFile.setPackaging("war"); addDependencies(pomFile, model); addJavaSEVersionProperties(pomFile, model); pomFile.addProperty("failOnMissingWebXml", "false"); pomFile.addProperty("final.name", model.getMaven().getArtifactId()); Build build = new Build(); build.setFinalName(model.getMaven().getArtifactId()); pomFile.setBuild(build); return pomFile; }
Example 12
Source File: PomProperty.java From flatten-maven-plugin with Apache License 2.0 | 4 votes |
@Override public void set( Model model, String value ) { model.setPackaging( value ); }