private File createApplicationProfile()

in taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/TavernaProfileGenerateMojo.java [146:193]


	private File createApplicationProfile() throws JAXBException, MojoExecutionException {
		String groupId = project.getGroupId();
		String artifactId = project.getArtifactId();
		String version = maven2OsgiConverter.getVersion(project.getVersion());
		if (version.endsWith("SNAPSHOT")) {
			version = version.substring(0, version.indexOf("SNAPSHOT")) + buildNumber;
		}

		tempDirectory.mkdirs();
		File applicationProfileFile = new File(tempDirectory, APPLICATION_PROFILE_FILE);

		ApplicationProfile applicationProfile = new ApplicationProfile();
		applicationProfile.setId(groupId + "." + artifactId);
		applicationProfile.setName(project.getName());
		applicationProfile.setVersion(version);

		Updates updates = new Updates();
		updates.setUpdateSite(updateSite);
		updates.setUpdatesFile(updatesFile);
		updates.setLibDirectory(libDirectory);
		updates.setPluginSite(pluginSite);
		updates.setPluginsFile(pluginsFile);
		applicationProfile.setUpdates(updates);

		List<FrameworkConfiguration> frameworkConfiguration = applicationProfile
				.getFrameworkConfiguration();
		for (FrameworkConfiguration configuration : frameworkConfigurations) {
			frameworkConfiguration.add(configuration);
		}

		Set<BundleArtifact> bundleDependencies = osgiUtils.getBundleDependencies(
				Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME);
		List<BundleInfo> runtimeBundles = osgiUtils.getBundles(bundleDependencies);
		if (!runtimeBundles.isEmpty()) {
			List<BundleInfo> bundles = applicationProfile.getBundle();
			for (BundleInfo bundle : runtimeBundles) {
				bundles.add(bundle);
			}
		}

		JAXBContext jaxbContext = JAXBContext.newInstance(ApplicationProfile.class);
		Marshaller marshaller = jaxbContext.createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, SCHEMA_LOCATION);
		marshaller.marshal(applicationProfile, applicationProfileFile);

		return applicationProfileFile;
	}