+ protected StringBuffer createPomFileHeader(String parentGroupId,
+ String parentArtifactId, String parentBaseVersion, String groupId,
+ String artifactId, String packaging) {
+ StringBuffer pom = new StringBuffer();
+ // not using append() systematically for the sake of clarity
+ pom.append("<project>\n");
+ pom.append("\t<modelVersion>4.0.0</modelVersion>\n");
+ pom.append("\t<parent>\n");
+ pom.append("\t\t<groupId>" + parentGroupId + "</groupId>\n");
+ pom.append("\t\t<artifactId>" + parentArtifactId + "</artifactId>\n");
+ pom.append("\t\t<version>" + parentBaseVersion + "</version>\n");
+ pom.append("\t</parent>\n");
+ pom.append("\t<groupId>" + groupId + "</groupId>\n");
+ pom.append("\t<artifactId>" + artifactId + "</artifactId>\n");
+ pom.append("\t<packaging>" + packaging + "</packaging>\n");
+ return pom;
+
+ // TODO: use the Model object e.g.: (from install plugin)
+ // Model model = new Model();
+ // model.setModelVersion( "4.0.0" );
+ // model.setGroupId( groupId );
+ // model.setArtifactId( artifactId );
+ // model.setVersion( version );
+ // model.setPackaging( packaging );
+ // model.setDescription( "POM was created from install:install-file" );
+ // fw = new FileWriter( tempFile );
+ // tempFile.deleteOnExit();
+ // new MavenXpp3Writer().write( fw, model );
+ // ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact,
+ // tempFile );
+ // artifact.addMetadata( metadata );
+
+ }
+
+ /** Simple close the project tag */
+ protected String closePomFile(StringBuffer pom) {
+ pom.append("</project>\n");
+ return pom.toString();
+ }
+
+ protected Manifest readManifest(File file) throws IOException {
+ Manifest manifest = new Manifest();
+ FileInputStream in = new FileInputStream(file);
+ manifest.read(in);
+ in.close();
+ return manifest;
+ }
+
+ protected int snapshotIndex() {
+ return project.getModel().getVersion().lastIndexOf("-SNAPSHOT");
+ }
+
+ protected String versionMain(int sIndex) {
+ return project.getVersion().substring(0, sIndex);
+ }
+
+ protected File getBundleDirectory() {
+ return bundlesDirectory;
+ }
+
+ protected FileFilter bundleFileFilter() {
+ return new FileFilter() {
+ public boolean accept(File file) {
+ if (!file.isDirectory())
+ return false;
+
+ return manifestFileFromDir(file).exists();
+ }
+ };
+ }
+