jar 坐标系转换工具_java jar生成maven坐标
使用本地maven仓库地址,配合需要生成jar名进行匹配坐标
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
public class GenPom {
private static final String outputPath = "F:\\path.txt";
private static final String mavenProPath = "F:\\maven_repo";
private static final String libPath = "D:\\product\\MvnTest\\src\\main\\resources\\lib";
public static void main(String[] args) throws IOException {
//将本地坐标读取到文件中,此过程第一次运行较慢
readMaven();
//读取需要匹配的jar
Map map = readLib();
//读取上方写入的地址信息
List collect = new BufferedReader(new FileReader(new File(outputPath))).lines().collect(Collectors.toList());
List paths = getGenPaths(map, collect);
System.out.println(map.size());
System.out.println(paths.size());
genDependency(paths);
}
/**
* 获取需要生成的pom文件地址
* @param map
* @param collect
* @return
*/
private static List getGenPaths(Map map, List collect){
List result = new ArrayList<>();
//遍历所有需要匹配的文件
map.forEach((key, value) -> {
//遍历地址
for (String path : collect) {
//匹配规则 因为有些lib存在parent所有此处用于忽略parent,并且查找当前map 坐标名
if (path.contains(key) && !path.contains("parent")) {
//如果匹配上则匹配版本
if (path.contains(value)) {
//替换jar文件为pom文件
result.add(path.replace("jar", "pom"));
return;
}
}
}
//打印未匹配地址
System.out.println("未匹配到:" + key + value);
});
return result;
}
/**
* 生成坐标依赖,使用了Jsoup去分析pom文件
* @param paths
* @throws FileNotFoundException
*/
private static void genDependency(List paths) throws FileNotFoundException {
//将匹配的结果生成坐标
for (String path : paths) {
File file = new File(path);
String content = new BufferedReader(new FileReader(file)).lines().collect(Collectors.joining("\r\n"));
Document parse = Jsoup.parse(content);
String data = (" \n" +
" " + parse.getElementsByTag("groupId").get(0).text() + "\n" +
" " + parse.getElementsByTag("artifactId").get(0).text() + "\n" +
" " + parse.getElementsByTag("version").get(0).text() + "\n" +
" ");
System.out.println(data);
}
}
/**
* 读取lib路劲 结果是 名,版本 如 spring-context-5.1.jar 结果为 spring-context=>5.1
*/
private static Map readLib() throws IOException {
Map map = new HashMap<>();
File directory = new File(libPath);
if (!directory.isDirectory()) {
throw new RuntimeException("lib path must directory");
}
File[] files = directory.listFiles();
for (File file : files) {
int index = file.getName().lastIndexOf("-");
String artifactId = file.getName().substring(0, index);
String version = file.getName().substring(index);
map.put(artifactId, version);
}
return map;
}
/**
* 读取本地maven坐标,将所有jar pom 文件地址写入到 outputPath 中 结果: f:/maven_repo/org/spring/context/5.1/org-spring-context-5.1.jar
*
* @throws IOException
*/
private static void readMaven() throws IOException {
List read = read(new File(mavenProPath));
File file = new File(outputPath);
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file));
for (File x : read) {
String path = x.getPath().concat("\r\n");
outputStream.write(path.getBytes());
}
outputStream.flush();
outputStream.close();
}
/**
* 递归读取所有文件
*
* @param file
* @return
*/
private static List read(File file) {
List result = new ArrayList<>();
if (file.isDirectory()) {
File[] list = file.listFiles();
for (File s : list) {
List temp = read(s);
if (temp != null) {
result.addAll(temp);
}
}
return result;
}
return Collections.singletonList(file);
}
}
jar 坐标系转换工具_java jar生成maven坐标相关推荐
- jar 坐标系转换工具_MODIS数据处理工具HEG安装教程
MODIS数据在遥感领域广泛使用,对于新手而言,其特有的坐标系让人摸不着头脑.当新手好不容易理解了坐标系,并使用简单的仿射变换矩阵做了投影转换,却发现投影转换后的tif影像不够精确,进一步使用数据时就 ...
- html二维坐标系转换,旋转坐标系 转换工具
旋转坐标系转换工具 假设3D 点的坐标 P, 在已知 x-y-z坐标参考框架: (x,y,z). 1)我们现在想知道在 P 的坐标 x'-y'-z'坐标参考框架, 这是旋转θ 周围的弧度z/z' '轴 ...
- 【Java代码】坐标系说明+WGS84\GCJ02\BD09坐标系转换工具+Java坐标系转换及验证源代码分享(粘贴可用)
1. 坐标系说明 开发地图应用服务时,一定会接触到各种坐标系,而保证坐标系的正确与合理是一切数据分析的前提,总的来说,坐标系可以分为两大类:地理坐标系GCS(Geographic Coordinate ...
- 西安80坐标系转换工具
西安80坐标系转换工具 利用ARCGIS进行自定义坐标系和投影转换 ARCGIS种通过三参数和其参数进行精确投影转换 注意:投影转换成80坐标系需要下载无偏移卫星图像进行转换,有偏移的转换将导致转换后 ...
- java常用地图坐标系转换工具类,支持谷歌,腾讯,百度等主流的地理坐标转换
package com.shen.springboot.redis.util;import java.util.ArrayList; import java.util.HashMap; import ...
- GIS坐标系转换工具CoordSystemTransform使用教程
CoordSystemTransform CoordSystemTransform这款工具由" 阿拉灯Aladeng"编写,项目上传至Github分享,所有源码都可以下载和修改.C ...
- python坐标系转换函数_python WGS84和ECEF坐标的转换
地心地固坐标系(Earth-Centered, Earth-Fixed,ECEF),简称地心坐标系. 地理坐标系统(Geographic Coordinate System,GCS)1,坐标系是地心坐 ...
- wgs84坐标系转换工具_ArcGIS中不同坐标系之间的转换
用户经常会遇到这样的情况,现有的数据坐标不符合要求,为应对需求,不得不为数据转换坐标系.很多人认为转换坐标系只是单纯的使用工具箱中的[投影]工具,那就大错特错了.有很多情况下,只使用[投影]工具并不能 ...
- 坐标系转换工具_借助工具实现不同坐标系之间的转换
在设计院日常工作中避免不了不同坐标系之间矢量数据.栅格数据等的转换,由于涉及到不同的参考椭球可能在某些情况要转换需要额外的参数,实现转换.但是有时候却受限于一些原因需要我们自己进行转换,下面就工作中的 ...
最新文章
- 基于阿里云搭建的适合初创企业的轻量级架构--架构总结
- springframework包下的RequestContextHolder类和ServletRequestAttributes类的源码和使用
- java程序cpu突然飚高_Java 定位导致CPU飙升的代码过程
- win8 任务栏不合并隐藏标题
- extjs jquery使用场合
- linux提取声卡的codec教程,发个菜鸟提取声卡codec文件图文教程,老手就别看了,小心被骂!...
- exosip register代码
- container_of宏定义分析---linux内核
- 怎么让抠图融入背景_李现壁纸+头像+背景图+情侣头像抠图特辑来了
- C++类的成员函数(在类外定义成员函数、inline成员函数)
- pycharm appiunm 公众号测试_知道答案公众号_知到APP笔尖上的艺术——书法基础与赏析单元测试答案_知道答...
- clone ubuntu 启动不能启动网卡
- Seaborn学习记录(1)
- 微信小程序生成分享海报
- julia常用矩阵函数_Julia语言入门
- win10计算机切换用户,win10系统账户切换的三种方法
- 深度学习21天——卷积神经网络(CNN):实现mnist手写数字识别(第1天)
- 【软件工程】敏捷宣言
- Error:(1, 0) Plugin with id 'com.android.application' not found. a href=openFile:F:\AndroidCode\Ji
- StatsD与Graphite联合作战
热门文章
- Mooc多媒体技术与应用02-数字音频技术
- Redmine使用说明,比较详细并且有具体使用简单使用制度
- 对多边形边缘检测并拟合线段长度和角度(matlab实现)
- error: failed to push some refs to ‘https://github.com/bodokaiser/piwise.git‘
- PHP 头像上传到mysql数据库
- mysql binlog elk_利用MySQL的binlog日志文件恢复数据库
- 泛微 linux + mysql 部署+踩坑记
- java取北京时间_JAVA 获取北京时间 亲自验证
- iOS 5设备不能通过plist配置文件安装ipa程序
- mysql计算员工一年工资_一年平均工资怎么算