// Path: src/main/java/de/oppermann/pomutils/rules/Ruleset.java
// public class Ruleset {
// 
// 	private List<Rule> rules = new ArrayList<Rule>();
// 
// 	/**
// 	 * Creates the default Ruleset with the ProjectAndParentVersionRule.
// 	 */
// 	public Ruleset(SelectionStrategy strategy) {
// 		rules.add(new ProjectAndParentVersionRule(strategy));
// 	}
// 
// 	public Ruleset(File rulesetFile) {
// 		if (!rulesetFile.exists()) {
// 			throw new IllegalArgumentException("File [" + rulesetFile.getAbsolutePath() + "] does not exist");
// 		}
// 
// 		Yaml yaml = new Yaml();
// 
// 		FileInputStream is = null;
// 		try {
// 			is = new FileInputStream(rulesetFile);
// 			for (Object data : yaml.loadAll(is)) {
// 				rules.add((Rule) data);
// 			}
// 		} catch (FileNotFoundException e) {
// 			throw new RuntimeException(e);
// 		}
// 		finally {
// 			if (is != null) {
// 				try {
// 					is.close();
// 				} catch (IOException e) {
// 					throw new RuntimeException(e);
// 				}
// 			}
// 		}
// 	}
// 
// 	public void evaluate(POM basePom, POM ourPom, POM theirPom) throws IOException, XMLStreamException {
// 		for (Rule rule : rules) {
// 			rule.evaluate(basePom, ourPom, theirPom);
// 		}
// 	}
// 
// }
// 
// Path: src/main/java/de/oppermann/pomutils/select/SelectionStrategy.java
// public enum SelectionStrategy {
// 	
// 	/**
// 	 * Always select 'our' version (the default). 
// 	 */
// 	OUR(new OurVersionSelector()),
// 	
// 	/**
// 	 * Always select 'their' version. 
// 	 */
// 	THEIR(new TheirVersionSelector()),
// 	
// 	/**
// 	 * Prompt the user via stdout/stdin for them to select the version. 
// 	 */
// 	PROMPT(new PersistentVersionSelector(new StreamVersionSelector()));
// 	
// 	private final VersionSelector selector;
// 	
// 	private SelectionStrategy(VersionSelector selector) {
// 		this.selector = selector;
// 	}
// 
// 	/*
// 	 * Overridden so that the proper string appears in --help output. 
// 	 */
// 	public String toString() {
// 		return name().toLowerCase();
// 	}
// 	
// 	public VersionSelector getSelector() {
// 		return selector;
// 	}
// }


import java.io.File;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import de.oppermann.pomutils.rules.Ruleset;
import de.oppermann.pomutils.select.SelectionStrategy;
package de.oppermann.pomutils.commands;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */




/**
 * 
 * @author Sven Oppermann <sven.oppermann@gmail.com>
 * 
 */

@Parameters(separators = "=", commandDescription = "Used as merge driver in git.  Updates the version of 'our' pom or 'their' pom (based on the value of --select), and then does a normal 'git merge-file'")
public class CommandPomMergeDriver {

	@Parameter(names = { "-b", "--base" }, description = "Base Pom", required = true)
	private String basePom;

	@Parameter(names = { "-o", "--our" }, description = "Our Pom", required = true)
	private String ourPom;

	@Parameter(names = { "-t", "--their" }, description = "Their Pom", required = true)
	private String theirPom;

// Path: src/main/java/de/oppermann/pomutils/rules/Ruleset.java
// public class Ruleset {
// 
// 	private List<Rule> rules = new ArrayList<Rule>();
// 
// 	/**
// 	 * Creates the default Ruleset with the ProjectAndParentVersionRule.
// 	 */
// 	public Ruleset(SelectionStrategy strategy) {
// 		rules.add(new ProjectAndParentVersionRule(strategy));
// 	}
// 
// 	public Ruleset(File rulesetFile) {
// 		if (!rulesetFile.exists()) {
// 			throw new IllegalArgumentException("File [" + rulesetFile.getAbsolutePath() + "] does not exist");
// 		}
// 
// 		Yaml yaml = new Yaml();
// 
// 		FileInputStream is = null;
// 		try {
// 			is = new FileInputStream(rulesetFile);
// 			for (Object data : yaml.loadAll(is)) {
// 				rules.add((Rule) data);
// 			}
// 		} catch (FileNotFoundException e) {
// 			throw new RuntimeException(e);
// 		}
// 		finally {
// 			if (is != null) {
// 				try {
// 					is.close();
// 				} catch (IOException e) {
// 					throw new RuntimeException(e);
// 				}
// 			}
// 		}
// 	}
// 
// 	public void evaluate(POM basePom, POM ourPom, POM theirPom) throws IOException, XMLStreamException {
// 		for (Rule rule : rules) {
// 			rule.evaluate(basePom, ourPom, theirPom);
// 		}
// 	}
// 
// }
// 
// Path: src/main/java/de/oppermann/pomutils/select/SelectionStrategy.java
// public enum SelectionStrategy {
// 	
// 	/**
// 	 * Always select 'our' version (the default). 
// 	 */
// 	OUR(new OurVersionSelector()),
// 	
// 	/**
// 	 * Always select 'their' version. 
// 	 */
// 	THEIR(new TheirVersionSelector()),
// 	
// 	/**
// 	 * Prompt the user via stdout/stdin for them to select the version. 
// 	 */
// 	PROMPT(new PersistentVersionSelector(new StreamVersionSelector()));
// 	
// 	private final VersionSelector selector;
// 	
// 	private SelectionStrategy(VersionSelector selector) {
// 		this.selector = selector;
// 	}
// 
// 	/*
// 	 * Overridden so that the proper string appears in --help output. 
// 	 */
// 	public String toString() {
// 		return name().toLowerCase();
// 	}
// 	
// 	public VersionSelector getSelector() {
// 		return selector;
// 	}
// }


// Path: src/main/java/de/oppermann/pomutils/commands/CommandPomMergeDriver.java
import java.io.File;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import de.oppermann.pomutils.rules.Ruleset;
import de.oppermann.pomutils.select.SelectionStrategy;

package de.oppermann.pomutils.commands;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */




/**
 * 
 * @author Sven Oppermann <sven.oppermann@gmail.com>
 * 
 */

@Parameters(separators = "=", commandDescription = "Used as merge driver in git.  Updates the version of 'our' pom or 'their' pom (based on the value of --select), and then does a normal 'git merge-file'")
public class CommandPomMergeDriver {

	@Parameter(names = { "-b", "--base" }, description = "Base Pom", required = true)
	private String basePom;

	@Parameter(names = { "-o", "--our" }, description = "Our Pom", required = true)
	private String ourPom;

	@Parameter(names = { "-t", "--their" }, description = "Their Pom", required = true)
	private String theirPom;

	@Parameter(names = { "-s", "--select" }, description = "Which version to select to resolve conflicts.  'our', 'their', or 'prompt'.  If 'prompt' is specified, then you will be prompted via stdout/stdin to select a version.", required = false, converter = SelectionStrategyConverter.class)