/*
* Copyright 2012 Objectos, Fábrica de Software LTDA.
*
* Licensed 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.
*/
package br.com.objectos.rio.kdo.dots;
import java.util.Map;
import br.com.objectos.rio.Jdbc;
import br.com.objectos.rio.kdo.KdoDirs;
import br.com.objectos.way.base.io.Directory;
import br.com.objectos.way.etc.Etcs;
import br.com.objectos.way.etc.WayEtc;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
/**
* @author marcio.endo@objectos.com.br (Marcio Endo)
*/
class DotsMaven extends AbstractDots {
private final Etcs etcs;
@Inject
public DotsMaven(KdoDirs dirs, Etcs etcs) {
super(dirs);
this.etcs = etcs;
}
@Override
protected boolean shouldExecute(DotsOptions options) {
return options.maven;
}
@Override
protected Messages configureMessages(Messages messages) {
return super.configureMessages(messages)
.actionName("maven")
.actionDescription("Applying objectos settings to your ~/.m2/settings.xml file.");
}
@Override
protected void execute0(DotsOptions options) {
Jdbc jdbc = etcs.read(Jdbc.class);
Map<String, Object> ctx = ImmutableMap.<String, Object> of("jdbc", jdbc);
Directory m2 = dirs.mavenSettings();
WayEtc.resourcesAt("/kdo/dots/maven")
.add("settings.xml")
.evalWith(ctx)
.copyTo(m2);
}
}