eclipse 清除Launch configuration的历史记录

用eclipse打包jar的时候,需要指定一个main函数。需要先运行一下main函数,eclipse的Runnable JAR File Specification 下的Launch configuration下拉列表才会有记录。

但是有时候下来列表里面的选项态度了,每次打包jar的时候都要花好长的时间去找要main函数的类。就很心累。

如果想要删除下拉列表里的历史记录,只需要进入到要打包的这个工程所在目录的(也就是工作空间目录)

/.metadata/.plugins/org.eclipse.debug.core/.launches

文件夹,清空这个文件夹里面的所有.launch文件就行了。这样下次导出的时候就很容易能找到要导出的类。

代码实现:

package eclipse.tools;

import java.io.File;
import java.io.IOException;
//Runnable JAR File Export Launch confiquration:列表太多
public class DeleteLaunchesFile
{
	/**
	 * 获取工作空间字符串路径。
	 * @return 工作空间字符串路劲。
	 */
	public static String getWorkspacePath()
	{
		//D:\dev\workspace\RunableTools---java工程路径
//		System.out.println(System.getProperty("user.dir"));
		File projectPathFile=new File(System.getProperty("user.dir"));
		File workspaceFile=projectPathFile.getParentFile();
//		D:\dev\workspace--->工作区间路径
//		System.out.println(workspaceFile);
		String workspace=null;
		try
		{
			workspace=workspaceFile.getCanonicalPath()+"\\";
		} catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return workspace;
	}
	/**
	 * 获取当前工作区间的导出配置列表目录的路径。
	 * @return 当前工作区间的导出配置列表目录的路径。
	 */
	public static String getlaunchesFileDir()
	{
		return getWorkspacePath()+".metadata\\.plugins\\org.eclipse.debug.core\\.launches";
	}
	public static void main(String[] args) throws IOException
	{
		String path=getlaunchesFileDir();
		System.out.println(path);
		File launchConfiqurationDir=new File(path);//获取工程目录下的导出配置列表文件夹
		if(launchConfiqurationDir.isDirectory())
		{
			File[] configlist=launchConfiqurationDir.listFiles();
			for (File file : configlist)
			{
				System.out.println(file.getName()+"已删除");
				file.delete();//删除.lanunch文件
			}
		}
	}
}

运行结果:

D:\dev\workspace\.metadata\.plugins\org.eclipse.debug.core\.launches
RunBat.launch已删除

好吧其实,手动删除是最便捷的,没必要写个代码来删除一下。




参考博客:

### 使用 `launch.substitutions.launchConfiguration` 的方法 在 ROS 2 中,`launch.substitutions.launchConfiguration` 是一种用于访问启动文件中的参数配置的方法[^1]。它允许开发者通过名称获取特定的启动参数值,并将其嵌入到启动流程中。 以下是关于如何使用 `launch.substitutions.launchConfiguration` 的具体说明: #### 参数声明与访问 为了能够使用 `launch.substitutions.launchConfiguration`,首先需要在启动文件中定义相应的参数。这可以通过 `LaunchDescription` 和 `DeclareLaunchArgument` 来实现。例如,在 Python 启动脚本中可以这样写: ```python from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration def generate_launch_description(): # 声明一个名为 'my_param' 的启动参数,默认值为 'default_value' declare_my_param_cmd = DeclareLaunchArgument( 'my_param', default_value='default_value', description='A parameter example.' ) # 获取已声明的参数值 my_param = LaunchConfiguration('my_param') ld = LaunchDescription() # 将声明的动作添加到启动描述中 ld.add_action(declare_my_param_cmd) return ld ``` 上述代码片段展示了如何声明一个启动参数并使用 `LaunchConfiguration` 访问其值。 #### 在节点或其他动作中应用参数 一旦参数被声明并通过 `LaunchConfiguration` 获得,就可以将其传递给节点或任何其他支持动态替换的操作。例如: ```python from launch_ros.actions import Node ... # 创建一个节点并将参数值作为参数传入 example_node = Node( package='example_package', executable='example_executable', name='example_node', parameters=[{'param_name': my_param}] # 使用 LaunchConfiguration 替换参数 ) ld.add_action(example_node) ``` 此部分演示了如何将 `LaunchConfiguration` 应用于实际的节点实例化过程。 #### 静态导入的相关性 虽然静态导入的概念主要适用于 Java 编程语言[^4],但在 ROS 2 的上下文中并不直接适用。然而,理解这种机制可以帮助开发人员更好地设计模块化的启动文件结构,类似于通过静态导入简化常量引用的方式。 --- ### 总结 `launch.substitutions.launchConfiguration` 提供了一种灵活的方式来管理启动文件中的参数配置。通过结合 `DeclareLaunchArgument` 动作和 `Node` 定义,可以在运行时动态调整节点的行为。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值