本文整理汇总了Java中org.netbeans.modules.maven.model.pom.Project类的典型用法代码示例。如果您正苦于以下问题:Java Project类的具体用法?Java Project怎么用?Java Project使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Project类属于org.netbeans.modules.maven.model.pom包,在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUpgradePluginOperation
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
private static ModelOperation<POMModel> createUpgradePluginOperation() {
return new ModelOperation<POMModel>() {
public @Override
void performOperation(POMModel model) {
POMComponentFactory factory = model.getFactory();
Project project = model.getProject();
Build bld = project.getBuild();
if (bld == null) {
bld = factory.createBuild();
project.setBuild(bld);
}
Plugin plg = bld.findPluginById(MavenNbModuleImpl.GROUPID_MOJO, MavenNbModuleImpl.NBM_PLUGIN);
if (plg == null) {
plg = factory.createPlugin();
plg.setGroupId(MavenNbModuleImpl.GROUPID_MOJO);
plg.setArtifactId(MavenNbModuleImpl.NBM_PLUGIN);
plg.setExtensions(Boolean.TRUE);
bld.addPlugin(plg);
}
plg.setVersion(MavenNbModuleImpl.LATEST_NBM_PLUGIN_VERSION); //
}
};
}
示例2: createRemoveIdePropertyOperation
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
private static ModelOperation<POMModel> createRemoveIdePropertyOperation() {
return new ModelOperation<POMModel>() {
public @Override void performOperation(POMModel model) {
Project project = model.getProject();
Properties properties = project.getProperties();
if (properties != null) {
if (properties.getProperty(OLD_PROPERTY) != null) {
properties.setProperty(OLD_PROPERTY, null);
}
String args = properties.getProperty(MASTER_PROPERTY);
if (args != null) {
String ref = "${" + OLD_PROPERTY + "}"; // NOI18N
if (args.contains(ref)) {
args = args.replace(ref, "");
if (args.trim().length() == 0) {
args = null;
}
properties.setProperty(MASTER_PROPERTY, args);
}
}
}
}
};
}
示例3: performOperation
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
@Override
public void performOperation(POMModel model) {
String s = PluginPropertyUtils.getPluginProperty(handle.getProject(), Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER, "source", null, null);
String t = PluginPropertyUtils.getPluginProperty(handle.getProject(), Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER, "source", null, null);
if (s == null && t == null) {
Project p = model.getProject();
if (p != null) {
Properties prop = p.getProperties();
if (prop == null) {
prop = model.getFactory().createProperties();
p.setProperties(prop);
}
prop.setProperty("maven.compiler.source", sourceLevel);
prop.setProperty("maven.compiler.target", sourceLevel);
}
} else {
ModelUtils.setSourceLevel(model, sourceLevel);
}
}
示例4: checkModelDependency
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
public static Dependency checkModelDependency(POMModel pom, String groupId, String artifactId, boolean add) {
Project mdl = pom.getProject();
Dependency ret = mdl.findDependencyById(groupId, artifactId, null);
Dependency managed = null;
if (ret == null || ret.getVersion() == null) {
//check dependency management section as well..
DependencyManagement mng = mdl.getDependencyManagement();
if (mng != null) {
managed = mng.findDependencyById(groupId, artifactId, null);
}
}
if (add && ret == null) {
ret = mdl.getModel().getFactory().createDependency();
ret.setGroupId(groupId);
ret.setArtifactId(artifactId);
mdl.addDependency(ret);
}
// if managed dependency section is present, return that one for editing..
return managed == null ? ret : managed;
}
示例5: openAtPlugin
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
/**
* Opens pom at a plugin with the given groupId and artifactId.
*
* @param model the model to open
* @param groupId the plugin groupId
* @param artifactId the plugin artifactId
*/
public static void openAtPlugin(POMModel model, String groupId, String artifactId) {
int pos = -1;
org.netbeans.modules.maven.model.pom.Project p = model.getProject();
Build bld = p.getBuild();
if (bld != null) {
Plugin plg = bld.findPluginById(groupId, artifactId);
if (plg != null) {
pos = plg.findPosition();
}
}
if(pos == -1) {
pos = p.findPosition();
}
if(pos == -1) {
return;
}
openAtPosition(model, pos);
}
示例6: updateProjectNames
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
private void updateProjectNames( List<FileObject> allPoms, final String name )
{
// modify name for other projects
ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
@Override
public void performOperation( POMModel model ) {
Project project = model.getProject();
project.setName(name + NAME_SEPARATOR + project.getName());
}
};
for (FileObject pom : allPoms) {
Utilities.performPOMModelOperations(pom,
Collections.singletonList(operation));
}
}
示例7: getPackaging
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
private String getPackaging( FileObject pom ) {
final String[] packaging = new String[1];
ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
@Override
public void performOperation( POMModel model ) {
Project project = model.getProject();
if (project != null) {
packaging[0] = project.getPackaging();
}
}
};
Utilities.performPOMModelOperations(pom,
Collections.singletonList(operation));
return packaging[0];
}
示例8: getVaadinPlugin
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
private Plugin getVaadinPlugin( POMModel model ) {
Project project = model.getProject();
Build build = project.getBuild();
if (build == null) {
return null;
}
List<Plugin> plugins = build.getPlugins();
for (Plugin plugin : plugins) {
if (MAVEN_ARTIFACT_ID.equals(plugin.getArtifactId())
&& GROUP_ID.equals(plugin.getGroupId()))
{
return plugin;
}
}
return null;
}
示例9: performOperation
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
@Override
public void performOperation(POMModel model) {
Project p = model.getProject();
Build bld = p.getBuild();
if (bld == null) {
bld = model.getFactory().createBuild();
p.setBuild(bld);
}
Plugin plg = bld.findPluginById(MavenNbModuleImpl.GROUPID_MOJO, MavenNbModuleImpl.NBM_PLUGIN);
if (plg == null) {
//how come the plugin is not there? maybe using on wrong project?
//check plugin management first.
PluginManagement pm = bld.getPluginManagement();
if (pm != null) {
plg = pm.findPluginById(MavenNbModuleImpl.GROUPID_MOJO, MavenNbModuleImpl.NBM_PLUGIN);
}
if (plg == null) { // should not happen to begin with
plg = model.getFactory().createPlugin();
bld.addPlugin(plg);
plg.setGroupId(MavenNbModuleImpl.GROUPID_MOJO);
plg.setArtifactId(MavenNbModuleImpl.NBM_PLUGIN);
plg.setVersion(MavenNbModuleImpl.LATEST_NBM_PLUGIN_VERSION);
}
}
Configuration cnf = plg.getConfiguration();
if (cnf == null) {
cnf = model.getFactory().createConfiguration();
plg.setConfiguration(cnf);
}
cnf.setSimpleParameter("useOSGiDependencies", Boolean.toString(useOsgi));
}
示例10: BasicInfoPanel
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
/** Creates new form BasicInfoPanel */
public BasicInfoPanel(ModelHandle2 handle, Category category, org.netbeans.api.project.Project prj) {
initComponents();
this.handle = handle;
this.category = category;
this.prj = prj;
initValues();
}
示例11: testModelWrite
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
public void testModelWrite() throws Exception {
ModelSource source = createModelSource("sample.pom");
try {
POMModel model = POMModelFactory.getDefault().getModel(source);
assertNotNull(model.getRootComponent());
Project prj = model.getProject();
Parent parent = prj.getPomParent();
assertNotNull(parent);
assertNotNull(parent.getGroupId());
assertEquals("org.codehaus.mojo", parent.getGroupId());
model.startTransaction();
parent.setGroupId("foo.bar");
model.endTransaction();
assertEquals("foo.bar", parent.getGroupId());
//this test fails here.. cannot rollback single property changes..
model.startTransaction();
parent.setGroupId("bar.foo");
model.rollbackTransaction();
assertEquals("foo.bar", parent.getGroupId());
} finally {
File file = source.getLookup().lookup(File.class);
file.deleteOnExit();
}
}
示例12: updateWarProjectName
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
private void updateWarProjectName( FileObject warPom,
final boolean prefixName, final String name )
{
ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
@Override
public void performOperation( POMModel model ) {
Project project = model.getProject();
if (prefixName) {
project.setName(name + NAME_SEPARATOR + project.getName());
}
else {
project.setName(name);
}
try {
String uri = URLEncoder.encode(name, UTF_8);
setJettyContextPath(uri, model);
setScanInterval(5, model);
setRunTarget(uri, model);
}
catch (UnsupportedEncodingException ignore) {
LOG.log(Level.FINE, null, ignore);
}
}
};
Utilities.performPOMModelOperations(warPom,
Collections.singletonList(operation));
}
示例13: getPom
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
private FileObject getPom( FileObject projectFolder ) {
org.netbeans.api.project.Project project =
FileOwnerQuery.getOwner(projectFolder);
NbMavenProject mvnProject =
project.getLookup().lookup(NbMavenProject.class);
File file = mvnProject.getMavenProject().getFile();
return FileUtil.toFileObject(FileUtil.normalizeFile(file));
}
示例14: visit
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
@Override
public void visit(Project target) {
visitComponent(target);
}
示例15: ensureSourcesExist
import org.netbeans.modules.maven.model.pom.Project; //导入依赖的package包/类
private void ensureSourcesExist( org.netbeans.api.project.Project project )
{
JavaUtils.getJavaSourceGroups(project, true);
}