List of usage examples for org.apache.maven.project MavenProject getVersion
public String getVersion()
From source file:npanday.assembler.impl.AssemblerContextImpl.java
License:Apache License
public AssemblyInfo getAssemblyInfo(MavenProject mavenProject) { String basedir = mavenProject.getBasedir().toString(); AssemblyInfo assemblyInfo = new AssemblyInfo(); String description = (mavenProject.getDescription() != null) ? mavenProject.getDescription() : ""; String version = (mavenProject.getVersion() != null) ? mavenProject.getVersion() : ""; String name = mavenProject.getName(); Organization org = mavenProject.getOrganization(); String company = (org != null) ? org.getName() : ""; String copyright = ""; String informationalVersion = ""; String configuration = ""; File file = new File(basedir + "/COPYRIGHT.txt"); if (file.exists()) { logger.debug("NPANDAY-020-000: Found Copyright: " + file.getAbsolutePath()); FileInputStream fis = null; try {/* w w w . j av a 2s . c om*/ fis = new FileInputStream(file); copyright = IOUtil.toString(fis).replace("\r", " ").replace("\n", " ").replace("\"", "'"); } catch (IOException e) { logger.info("NPANDAY-020-001: Could not get copyright: File = " + file.getAbsolutePath(), e); } finally { if (fis != null) { IOUtil.close(fis); } } } informationalVersion = version; if (version.contains("-")) { version = version.split("-")[0]; } assemblyInfo.setCompany(company); assemblyInfo.setCopyright(copyright); assemblyInfo.setCulture(""); assemblyInfo.setDescription(description); assemblyInfo.setProduct(company + "-" + name); assemblyInfo.setTitle(name); assemblyInfo.setTrademark(""); assemblyInfo.setInformationalVersion(informationalVersion); assemblyInfo.setVersion(version); assemblyInfo.setConfiguration(configuration); return assemblyInfo; }
From source file:npanday.plugin.resolver.CopyDependenciesMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { String skipReason = ""; if (!skip) {//from w w w . j a v a 2 s .co m ArtifactType knownType = ArtifactType.getArtifactTypeForPackagingName(project.getPackaging()); if (knownType.equals(ArtifactType.NULL)) { skip = true; skipReason = ", because the current project (type:" + project.getPackaging() + ") is not built with NPanday"; } } if (skip) { getLog().info("NPANDAY-158-001: Mojo for copying dependencies was intentionally skipped" + skipReason); return; } SettingsUtil.applyCustomSettings(getLog(), repositoryRegistry, settingsPath); AndArtifactFilter includeFilter = new AndArtifactFilter(); OrArtifactFilter typeIncludes = new OrArtifactFilter(); typeIncludes.add(new DotnetExecutableArtifactFilter()); typeIncludes.add(new DotnetLibraryArtifactFilter()); if (includePdbs) { typeIncludes.add(new DotnetSymbolsArtifactFilter()); } includeFilter.add(typeIncludes); if (!Strings.isNullOrEmpty(includeScope)) { includeFilter.add(new ScopeArtifactFilter(includeScope)); } Set<Artifact> artifacts; try { artifacts = dependencyResolution.require(project, LocalRepositoryUtil.create(localRepository), includeFilter); } catch (ArtifactResolutionException e) { throw new MojoExecutionException( "NPANDAY-158-003: dependency resolution for scope " + includeScope + " failed!", e); } /** * Should be resolved, but then not copied */ if (!Strings.isNullOrEmpty(excludeScope)) { includeFilter.add(new InversionArtifactFilter(new ScopeArtifactFilter(excludeScope))); } if (skipReactorArtifacts) { getLog().info("NPANDAY-158-008: " + reactorProjects); includeFilter.add(new InversionArtifactFilter(new ArtifactFilter() { public boolean include(Artifact artifact) { for (MavenProject project : reactorProjects) { // we don't care about the type and the classifier here if (project.getGroupId().equals(artifact.getGroupId()) && project.getArtifactId().equals(artifact.getArtifactId()) && project.getVersion().equals(artifact.getVersion())) { return true; } } return false; } })); } for (Artifact dependency : artifacts) { if (!includeFilter.include(dependency)) { getLog().debug("NPANDAY-158-006: dependency " + dependency + " was excluded"); continue; } try { File targetFile = new File(outputDirectory, PathUtil.getPlainArtifactFileName(dependency)); if (!targetFile.exists() || targetFile.lastModified() != dependency.getFile().lastModified() || targetFile.length() != dependency.getFile().length()) { getLog().info("NPANDAY-158-004: copy " + dependency.getFile() + " to " + targetFile); FileUtils.copyFile(dependency.getFile(), targetFile); } else { getLog().debug("NPANDAY-158-007: dependency " + dependency + " is yet up to date"); } } catch (IOException ioe) { throw new MojoExecutionException("NPANDAY-158-005: Error copying dependency " + dependency, ioe); } } }
From source file:npanday.plugin.resolver.ListDependenciesMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { String skipReason = ""; if (skip) {/*from ww w .j a va 2s . c om*/ getLog().info("NPANDAY-161-001: Mojo for listing dependencies was intentionally skipped" + skipReason); return; } SettingsUtil.applyCustomSettings(getLog(), repositoryRegistry, settingsPath); AndArtifactFilter includeFilter = new AndArtifactFilter(); if (!Strings.isNullOrEmpty(includeScope)) { includeFilter.add(new ScopeArtifactFilter(includeScope)); } Set<Artifact> artifacts; try { // TODO: Workarround. Somehow in the first run, PDBs wont be part of the result! dependencyResolution.require(project, LocalRepositoryUtil.create(localRepository), includeFilter); artifacts = dependencyResolution.require(project, LocalRepositoryUtil.create(localRepository), includeFilter); } catch (ArtifactResolutionException e) { throw new MojoExecutionException( "NPANDAY-161-003: dependency resolution for scope " + includeScope + " failed!", e); } /** * Should be resolved, but then not shown */ if (!Strings.isNullOrEmpty(excludeScope)) { includeFilter.add(new InversionArtifactFilter(new ScopeArtifactFilter(excludeScope))); } if (skipReactorArtifacts) { getLog().info("NPANDAY-161-008: " + reactorProjects); includeFilter.add(new InversionArtifactFilter(new ArtifactFilter() { public boolean include(Artifact artifact) { for (MavenProject project : reactorProjects) { // we don't care about the type and the classifier here if (project.getGroupId().equals(artifact.getGroupId()) && project.getArtifactId().equals(artifact.getArtifactId()) && project.getVersion().equals(artifact.getVersion())) { return true; } } return false; } })); } getLog().info("The following files have been resolved:"); for (Artifact dependency : artifacts) { if (!includeFilter.include(dependency)) { getLog().debug("NPANDAY-161-006: dependency " + dependency + " was excluded"); continue; } getLog().info(" " + dependency.getId() + ":" + dependency.getScope() + " -> " + dependency.getFile()); } }
From source file:org.apache.camel.maven.packaging.PackageComponentMojo.java
License:Apache License
public static void prepareComponent(Log log, MavenProject project, MavenProjectHelper projectHelper, File componentOutDir) throws MojoExecutionException { File camelMetaDir = new File(componentOutDir, "META-INF/services/org/apache/camel/"); StringBuilder buffer = new StringBuilder(); int count = 0; for (Resource r : project.getBuild().getResources()) { File f = new File(r.getDirectory()); if (!f.exists()) { f = new File(project.getBasedir(), r.getDirectory()); }/* w w w . java 2s . c om*/ f = new File(f, "META-INF/services/org/apache/camel/component"); if (f.exists() && f.isDirectory()) { File[] files = f.listFiles(); if (files != null) { for (File file : files) { // skip directories as there may be a sub .resolver directory if (file.isDirectory()) { continue; } String name = file.getName(); if (name.charAt(0) != '.') { count++; if (buffer.length() > 0) { buffer.append(" "); } buffer.append(name); } } } } } if (count > 0) { Properties properties = new Properties(); String names = buffer.toString(); properties.put("components", names); properties.put("groupId", project.getGroupId()); properties.put("artifactId", project.getArtifactId()); properties.put("version", project.getVersion()); properties.put("projectName", project.getName()); if (project.getDescription() != null) { properties.put("projectDescription", project.getDescription()); } camelMetaDir.mkdirs(); File outFile = new File(camelMetaDir, "component.properties"); try { properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin"); log.info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "components: " : "component: ") + names); if (projectHelper != null) { List<String> includes = new ArrayList<String>(); includes.add("**/component.properties"); projectHelper.addResource(project, componentOutDir.getPath(), includes, new ArrayList<String>()); projectHelper.attachArtifact(project, "properties", "camelComponent", outFile); } } catch (IOException e) { throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e); } } else { log.debug( "No META-INF/services/org/apache/camel/component directory found. Are you sure you have created a Camel component?"); } }
From source file:org.apache.camel.maven.packaging.PackageDataFormatMojo.java
License:Apache License
public static void prepareDataFormat(Log log, MavenProject project, MavenProjectHelper projectHelper, File dataFormatOutDir, File schemaOutDir) throws MojoExecutionException { File camelMetaDir = new File(dataFormatOutDir, "META-INF/services/org/apache/camel/"); Map<String, String> javaTypes = new HashMap<String, String>(); StringBuilder buffer = new StringBuilder(); int count = 0; for (Resource r : project.getBuild().getResources()) { File f = new File(r.getDirectory()); if (!f.exists()) { f = new File(project.getBasedir(), r.getDirectory()); }/*from w w w.j ava 2 s . c o m*/ f = new File(f, "META-INF/services/org/apache/camel/dataformat"); if (f.exists() && f.isDirectory()) { File[] files = f.listFiles(); if (files != null) { for (File file : files) { // skip directories as there may be a sub .resolver directory if (file.isDirectory()) { continue; } String name = file.getName(); if (name.charAt(0) != '.') { count++; if (buffer.length() > 0) { buffer.append(" "); } buffer.append(name); } // find out the javaType for each data format try { String text = loadText(new FileInputStream(file)); Map<String, String> map = parseAsMap(text); String javaType = map.get("class"); if (javaType != null) { javaTypes.put(name, javaType); } } catch (IOException e) { throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e); } } } } } // find camel-core and grab the data format model from there, and enrich this model with information from this artifact // and create json schema model file for this data format try { if (count > 0) { Artifact camelCore = findCamelCoreArtifact(project); if (camelCore != null) { File core = camelCore.getFile(); if (core != null) { URL url = new URL("file", null, core.getAbsolutePath()); URLClassLoader loader = new URLClassLoader(new URL[] { url }); for (Map.Entry<String, String> entry : javaTypes.entrySet()) { String name = entry.getKey(); String javaType = entry.getValue(); String modelName = asModelName(name); InputStream is = loader.getResourceAsStream( "org/apache/camel/model/dataformat/" + modelName + ".json"); if (is == null) { // use file input stream if we build camel-core itself, and thus do not have a JAR which can be loaded by URLClassLoader is = new FileInputStream( new File(core, "org/apache/camel/model/dataformat/" + modelName + ".json")); } String json = loadText(is); if (json != null) { DataFormatModel dataFormatModel = new DataFormatModel(); dataFormatModel.setName(name); dataFormatModel.setTitle(""); dataFormatModel.setModelName(modelName); dataFormatModel.setLabel(""); dataFormatModel.setDescription(project.getDescription()); dataFormatModel.setJavaType(javaType); dataFormatModel.setGroupId(project.getGroupId()); dataFormatModel.setArtifactId(project.getArtifactId()); dataFormatModel.setVersion(project.getVersion()); List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("model", json, false); for (Map<String, String> row : rows) { if (row.containsKey("title")) { String title = row.get("title"); dataFormatModel.setTitle(asModelTitle(name, title)); } if (row.containsKey("label")) { dataFormatModel.setLabel(row.get("label")); } if (row.containsKey("javaType")) { dataFormatModel.setModelJavaType(row.get("javaType")); } // override description for camel-core, as otherwise its too generic if ("camel-core".equals(project.getArtifactId())) { if (row.containsKey("description")) { dataFormatModel.setLabel(row.get("description")); } } } log.debug("Model " + dataFormatModel); // build json schema for the data format String properties = after(json, " \"properties\": {"); String schema = createParameterJsonSchema(dataFormatModel, properties); log.debug("JSon schema\n" + schema); // write this to the directory File dir = new File(schemaOutDir, schemaSubDirectory(dataFormatModel.getJavaType())); dir.mkdirs(); File out = new File(dir, name + ".json"); FileOutputStream fos = new FileOutputStream(out, false); fos.write(schema.getBytes()); fos.close(); log.debug("Generated " + out + " containing JSon schema for " + name + " data format"); } } } } } } catch (Exception e) { throw new MojoExecutionException("Error loading dataformat model from camel-core. Reason: " + e, e); } if (count > 0) { Properties properties = new Properties(); String names = buffer.toString(); properties.put("dataFormats", names); properties.put("groupId", project.getGroupId()); properties.put("artifactId", project.getArtifactId()); properties.put("version", project.getVersion()); properties.put("projectName", project.getName()); if (project.getDescription() != null) { properties.put("projectDescription", project.getDescription()); } camelMetaDir.mkdirs(); File outFile = new File(camelMetaDir, "dataformat.properties"); try { properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin"); log.info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "dataformats: " : "dataformat: ") + names); if (projectHelper != null) { List<String> includes = new ArrayList<String>(); includes.add("**/dataformat.properties"); projectHelper.addResource(project, dataFormatOutDir.getPath(), includes, new ArrayList<String>()); projectHelper.attachArtifact(project, "properties", "camelDataFormat", outFile); } } catch (IOException e) { throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e); } } else { log.debug( "No META-INF/services/org/apache/camel/dataformat directory found. Are you sure you have created a Camel data format?"); } }
From source file:org.apache.camel.maven.packaging.PackageLanguageMojo.java
License:Apache License
public static void prepareLanguage(Log log, MavenProject project, MavenProjectHelper projectHelper, File languageOutDir, File schemaOutDir) throws MojoExecutionException { File camelMetaDir = new File(languageOutDir, "META-INF/services/org/apache/camel/"); Map<String, String> javaTypes = new HashMap<String, String>(); StringBuilder buffer = new StringBuilder(); int count = 0; for (Resource r : project.getBuild().getResources()) { File f = new File(r.getDirectory()); if (!f.exists()) { f = new File(project.getBasedir(), r.getDirectory()); }//from w w w . j a v a 2 s . co m f = new File(f, "META-INF/services/org/apache/camel/language"); if (f.exists() && f.isDirectory()) { File[] files = f.listFiles(); if (files != null) { for (File file : files) { // skip directories as there may be a sub .resolver directory such as in camel-script if (file.isDirectory()) { continue; } String name = file.getName(); if (name.charAt(0) != '.') { count++; if (buffer.length() > 0) { buffer.append(" "); } buffer.append(name); } // find out the javaType for each data format try { String text = loadText(new FileInputStream(file)); Map<String, String> map = parseAsMap(text); String javaType = map.get("class"); if (javaType != null) { javaTypes.put(name, javaType); } } catch (IOException e) { throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e); } } } } } // find camel-core and grab the data format model from there, and enrich this model with information from this artifact // and create json schema model file for this data format try { if (count > 0) { Artifact camelCore = findCamelCoreArtifact(project); if (camelCore != null) { File core = camelCore.getFile(); if (core != null) { URL url = new URL("file", null, core.getAbsolutePath()); URLClassLoader loader = new URLClassLoader(new URL[] { url }); for (Map.Entry<String, String> entry : javaTypes.entrySet()) { String name = entry.getKey(); String javaType = entry.getValue(); String modelName = asModelName(name); InputStream is = loader .getResourceAsStream("org/apache/camel/model/language/" + modelName + ".json"); if (is == null) { // use file input stream if we build camel-core itself, and thus do not have a JAR which can be loaded by URLClassLoader is = new FileInputStream( new File(core, "org/apache/camel/model/language/" + modelName + ".json")); } String json = loadText(is); if (json != null) { LanguageModel languageModel = new LanguageModel(); languageModel.setName(name); languageModel.setTitle(""); languageModel.setModelName(modelName); languageModel.setLabel(""); languageModel.setDescription(""); languageModel.setJavaType(javaType); languageModel.setGroupId(project.getGroupId()); languageModel.setArtifactId(project.getArtifactId()); languageModel.setVersion(project.getVersion()); List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("model", json, false); for (Map<String, String> row : rows) { if (row.containsKey("title")) { languageModel.setTitle(row.get("title")); } if (row.containsKey("description")) { languageModel.setDescription(row.get("description")); } if (row.containsKey("label")) { languageModel.setLabel(row.get("label")); } if (row.containsKey("javaType")) { languageModel.setModelJavaType(row.get("javaType")); } } log.debug("Model " + languageModel); // build json schema for the data format String properties = after(json, " \"properties\": {"); String schema = createParameterJsonSchema(languageModel, properties); log.debug("JSon schema\n" + schema); // write this to the directory File dir = new File(schemaOutDir, schemaSubDirectory(languageModel.getJavaType())); dir.mkdirs(); File out = new File(dir, name + ".json"); FileOutputStream fos = new FileOutputStream(out, false); fos.write(schema.getBytes()); fos.close(); log.debug("Generated " + out + " containing JSon schema for " + name + " language"); } } } } } } catch (Exception e) { throw new MojoExecutionException("Error loading language model from camel-core. Reason: " + e, e); } if (count > 0) { Properties properties = new Properties(); String names = buffer.toString(); properties.put("languages", names); properties.put("groupId", project.getGroupId()); properties.put("artifactId", project.getArtifactId()); properties.put("version", project.getVersion()); properties.put("projectName", project.getName()); if (project.getDescription() != null) { properties.put("projectDescription", project.getDescription()); } camelMetaDir.mkdirs(); File outFile = new File(camelMetaDir, "language.properties"); try { properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin"); log.info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "languages: " : "language: ") + names); if (projectHelper != null) { List<String> includes = new ArrayList<String>(); includes.add("**/language.properties"); projectHelper.addResource(project, languageOutDir.getPath(), includes, new ArrayList<String>()); projectHelper.attachArtifact(project, "properties", "camelLanguage", outFile); } } catch (IOException e) { throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e); } } else { log.debug( "No META-INF/services/org/apache/camel/language directory found. Are you sure you have created a Camel language?"); } }
From source file:org.apache.cxf.maven_plugin.wadlto.AbstractCodeGeneratorMojo.java
License:Apache License
private Artifact resolveRemoteWadlArtifact(Artifact artifact) throws MojoExecutionException { /**/*from ww w . j ava 2s. c om*/ * First try to find the artifact in the reactor projects of the maven session. * So an artifact that is not yet built can be resolved */ List<MavenProject> rProjects = mavenSession.getProjects(); for (MavenProject rProject : rProjects) { if (artifact.getGroupId().equals(rProject.getGroupId()) && artifact.getArtifactId().equals(rProject.getArtifactId()) && artifact.getVersion().equals(rProject.getVersion())) { Set<Artifact> artifacts = rProject.getArtifacts(); for (Artifact pArtifact : artifacts) { if ("wadl".equals(pArtifact.getType())) { return pArtifact; } } } } ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setArtifact(artifact); request.setResolveRoot(true).setResolveTransitively(false); request.setServers(mavenSession.getRequest().getServers()); request.setMirrors(mavenSession.getRequest().getMirrors()); request.setProxies(mavenSession.getRequest().getProxies()); request.setLocalRepository(mavenSession.getLocalRepository()); request.setRemoteRepositories(mavenSession.getRequest().getRemoteRepositories()); ArtifactResolutionResult result = repositorySystem.resolve(request); return result.getOriginatingArtifact(); }
From source file:org.apache.cxf.maven_plugin.WSDL2JavaMojo.java
License:Apache License
@SuppressWarnings("unchecked") public Artifact resolveRemoteWsdlArtifact(List remoteRepos, Artifact artifact) throws MojoExecutionException { /**//from w ww .j a va 2s . c o m * First try to find the artifact in the reactor projects of the maven session. * So an artifact that is not yet built can be resolved */ List<MavenProject> rProjects = mavenSession.getSortedProjects(); for (MavenProject rProject : rProjects) { if (artifact.getGroupId().equals(rProject.getGroupId()) && artifact.getArtifactId().equals(rProject.getArtifactId()) && artifact.getVersion().equals(rProject.getVersion())) { Set<Artifact> artifacts = rProject.getArtifacts(); for (Artifact pArtifact : artifacts) { if ("wsdl".equals(artifact.getType())) { return pArtifact; } } } } /** * If this did not work resolve the artifact using the artifactResolver */ try { artifactResolver.resolve(artifact, remoteRepos, localRepository); } catch (ArtifactResolutionException e) { throw new MojoExecutionException("Error downloading wsdl artifact.", e); } catch (ArtifactNotFoundException e) { throw new MojoExecutionException("Resource can not be found.", e); } return artifact; }
From source file:org.apache.felix.bundleplugin.BundleAllPlugin.java
License:Apache License
/** * Bundle one project only without building its childre * //www . ja va 2 s .com * @param project * @throws MojoExecutionException */ protected BundleInfo bundle(MavenProject project) throws MojoExecutionException { Artifact artifact = project.getArtifact(); getLog().info("Bundling " + artifact); try { Map instructions = new LinkedHashMap(); instructions.put(Analyzer.IMPORT_PACKAGE, wrapImportPackage); project.getArtifact().setFile(getFile(artifact)); File outputFile = getOutputFile(artifact); if (project.getArtifact().getFile().equals(outputFile)) { /* TODO find the cause why it's getting here */ return null; // getLog().error( // "Trying to read and write " + artifact + " to the same file, try cleaning: " // + outputFile ); // throw new IllegalStateException( "Trying to read and write " + artifact // + " to the same file, try cleaning: " + outputFile ); } Analyzer analyzer = getAnalyzer(project, instructions, new Properties(), getClasspath(project)); Jar osgiJar = new Jar(project.getArtifactId(), project.getArtifact().getFile()); outputFile.getAbsoluteFile().getParentFile().mkdirs(); Collection exportedPackages; if (isOsgi(osgiJar)) { /* if it is already an OSGi jar copy it as is */ getLog().info("Using existing OSGi bundle for " + project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion()); String exportHeader = osgiJar.getManifest().getMainAttributes().getValue(Analyzer.EXPORT_PACKAGE); exportedPackages = analyzer.parseHeader(exportHeader).keySet(); FileUtils.copyFile(project.getArtifact().getFile(), outputFile); } else { /* else generate the manifest from the packages */ exportedPackages = analyzer.getExports().keySet(); Manifest manifest = analyzer.getJar().getManifest(); osgiJar.setManifest(manifest); osgiJar.write(outputFile); } BundleInfo bundleInfo = addExportedPackages(project, exportedPackages); // cleanup... analyzer.close(); osgiJar.close(); return bundleInfo; } /* too bad Jar.write throws Exception */ catch (Exception e) { throw new MojoExecutionException( "Error generating OSGi bundle for project " + getArtifactKey(project.getArtifact()), e); } }
From source file:org.apache.felix.bundleplugin.BundlePlugin.java
License:Apache License
/** * @param jar// w ww . j av a 2s .co m * @throws IOException */ private void doMavenMetadata(MavenProject currentProject, Jar jar) throws IOException { String path = "META-INF/maven/" + currentProject.getGroupId() + "/" + currentProject.getArtifactId(); File pomFile = new File(baseDir, "pom.xml"); jar.putResource(path + "/pom.xml", new FileResource(pomFile)); Properties p = new Properties(); p.put("version", currentProject.getVersion()); p.put("groupId", currentProject.getGroupId()); p.put("artifactId", currentProject.getArtifactId()); ByteArrayOutputStream out = new ByteArrayOutputStream(); p.store(out, "Generated by org.apache.felix.bundleplugin"); jar.putResource(path + "/pom.properties", new EmbeddedResource(out.toByteArray(), System.currentTimeMillis())); }