<commit_before>package aQute.bnd.maven;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Map.Entry;
import java.util.jar.Manifest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import aQute.bnd.header.Attrs;
import aQute.bnd.header.OSGiHeader;
import aQute.bnd.header.Parameters;
import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Domain;
import aQute.bnd.osgi.Processor;
import aQute.bnd.osgi.WriteResource;
import aQute.lib.io.IO;
import aQute.lib.tag.Tag;
import aQute.libg.glob.Glob;

public class PomResource extends WriteResource {
	private static final String	VERSION		= "version";
	private static final String	ARTIFACTID	= "artifactid";
	private static final String	GROUPID		= "groupid";
	private static final String	WHERE		= "where";
	final Manifest				manifest;
	private Map<String, String>	scm;
	final Processor				processor;
	final static Pattern		NAME_URL	= Pattern.compile("(.*)(https?://.*)", Pattern.CASE_INSENSITIVE);
	private final String		where;
	private final String		groupId;
	private final String		artifactId;
	private final String		version;
	private final String		name;

	public PomResource(Manifest manifest) {
		this(new Processor(), manifest);
	}

	public PomResource(Map<String, String> b, Manifest manifest) {
		this(asProcessor(b), manifest);
	}

	private static Processor asProcessor(Map<String, String> b) {
		Processor p = new Processor();
		p.addProperties(b);
		return p;
	}

	public PomResource(Processor b, Manifest manifest) {
		this(b, manifest, null, null, null);
	}

	public PomResource(Processor p, Manifest manifest, String groupId, String artifactId, String version) {
		this.processor = p;
		this.manifest = manifest;

		Domain domain = Domain.domain(manifest);

		String bsn = null;
		Entry<String, Attrs> bundleSymbolicName = domain.getBundleSymbolicName();
		if (bundleSymbolicName != null) {
			bsn = bundleSymbolicName.getKey();
		}

		if (groupId == null) {
			if (bsn == null) {
				throw new RuntimeException("Cannot create POM unless bsn is set");
			}
			groupId = augmentManifest(domain, bsn);
		}

		String where = processor.get(WHERE);

		if (groupId == null) {
			groupId = processor.get(GROUPID);
		}

		if (groupId == null) {
			groupId = processor.get(Constants.GROUPID);
		}

		if (groupId == null) {
			groupId = processor.get("groupId");
		}

		if (artifactId == null) {
			artifactId = processor.get(ARTIFACTID);
		}
		if (artifactId == null) {
			artifactId = processor.get("artifactId");
		}

		if (groupId != null) {
			if (artifactId == null) {
				if (bsn == null) {
					throw new RuntimeException("Cannot create POM unless bsn is set");
				}<commit_msg>pomresource: Always call augmentManifest of there is a bsn<commit_after>package aQute.bnd.maven;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Map.Entry;
import java.util.jar.Manifest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import aQute.bnd.header.Attrs;
import aQute.bnd.header.OSGiHeader;
import aQute.bnd.header.Parameters;
import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Domain;
import aQute.bnd.osgi.Processor;
import aQute.bnd.osgi.WriteResource;
import aQute.lib.io.IO;
import aQute.lib.tag.Tag;
import aQute.libg.glob.Glob;

public class PomResource extends WriteResource {
	private static final String	VERSION		= "version";
	private static final String	ARTIFACTID	= "artifactid";
	private static final String	GROUPID		= "groupid";
	private static final String	WHERE		= "where";
	final Manifest				manifest;
	private Map<String, String>	scm;
	final Processor				processor;
	final static Pattern		NAME_URL	= Pattern.compile("(.*)(https?://.*)", Pattern.CASE_INSENSITIVE);
	private final String		where;
	private final String		groupId;
	private final String		artifactId;
	private final String		version;
	private final String		name;

	public PomResource(Manifest manifest) {
		this(new Processor(), manifest);
	}

	public PomResource(Map<String, String> b, Manifest manifest) {
		this(asProcessor(b), manifest);
	}

	private static Processor asProcessor(Map<String, String> b) {
		Processor p = new Processor();
		p.addProperties(b);
		return p;
	}

	public PomResource(Processor b, Manifest manifest) {
		this(b, manifest, null, null, null);
	}

	public PomResource(Processor p, Manifest manifest, String groupId, String artifactId, String version) {
		this.processor = p;
		this.manifest = manifest;

		Domain domain = Domain.domain(manifest);

		String bsn = null;
		Entry<String, Attrs> bundleSymbolicName = domain.getBundleSymbolicName();
		if (bundleSymbolicName != null) {
			bsn = bundleSymbolicName.getKey();
		}

		if (bsn != null) {
			String g = augmentManifest(domain, bsn);
			if (groupId == null) {
				groupId = g;
			}
		}

		String where = processor.get(WHERE);

		if (groupId == null) {
			groupId = processor.get(GROUPID);
		}

		if (groupId == null) {
			groupId = processor.get(Constants.GROUPID);
		}

		if (groupId == null) {
			groupId = processor.get("groupId");
		}

		if (artifactId == null) {
			artifactId = processor.get(ARTIFACTID);
		}
		if (artifactId == null) {
			artifactId = processor.get("artifactId");
		}

		if (groupId != null) {
			if (artifactId == null) {
				if (bsn == null) {
					throw new RuntimeException("Cannot create POM unless bsn is set");
				}
{'fraction_non_alphanumeric': 0.11797133406835722, 'fraction_numerical': 0.0, 'mean_word_length': 4.223608445297505, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6884198', 'n_tokens_mistral': 2000, 'n_tokens_neox': 1783, 'n_words': 470}