代码之家  ›  专栏  ›  技术社区  ›  Victor

我试图找到eclipse的jsdt jar存储库

  •  0
  • Victor  · 技术社区  · 6 年前

    尽管org.eclipse.jdt:org.eclipse.jdt.core:3.14.0'非常容易定位,我的Gradle版本没有jsdt的外观。我需要一些网络工具。

    当我下载eclipse时,我可以在里面找到jar,并且我能够找到组和工件id。但不是用来声明依赖关系的存储库。

    捆绑包符号名称:org.eclipse.wst网站.jsdt核心 似乎它的团队org.eclipse.webtools.jsdt.bundles

    有什么想法吗?

    2 回复  |  直到 6 年前
        1
  •  1
  •   howlger df778899    6 年前

    只有一些Eclipse插件jar也打算在Eclipse以外的普通(非OSGi)应用程序中使用,它们由Eclipse项目自己发布到Maven或Gradle存储库(例如。 Eclipse JGit

    p2 repositories target platforms 建造和运行 爪哇语 .

    你要找的文物就在 latest simultaneous release update site 但无法从Maven或Gradle访问。

    请注意,一些Eclipse插件jar只在OSGi应用程序中工作(例如。g。当使用bundle activator类时)或在基于Eclipse的应用程序中(例如。g。当使用Eclipse扩展点时)。

        2
  •  1
  •   Victor    6 年前

    import java.io.IOException;
    import java.net.URI;
    import java.nio.charset.StandardCharsets;
    import java.nio.file.*;
    import java.util.*;
    import java.util.regex.*;
    
    public final class DirToRepoStructure {
    
        private static final Pattern jarNamePattern = Pattern.compile( "(.*)_(\\d+\\.\\d+\\.\\d+)\\.v?(\\d+)\\.jar" );
    
        public static void main( String[] args ) throws IOException {
    
            Path root = Paths.get( args[ 0 ] );
            int rootNameCount = root.getNameCount( );
    
            String rootName = root.getFileName( )
                                  .toString( );
    
            Path tempDir = Files.createTempDirectory( Paths.get( "." ), rootName );
            System.out.println( "using temporary directory: " + tempDir );
    
            Path achievePath = tempDir.getParent( )
                                      .resolve( rootName + ".zip" );
            System.out.println( "Archiving at: " + achievePath );
    
            DirectoryStream< Path > stream = Files.newDirectoryStream( root, "*.jar" );
    
            stream.forEach( jar -> {
                String fullName = jar.getFileName( )
                                     .toString( );
    
                System.out.println( fullName );
                Matcher matcher = jarNamePattern.matcher( fullName );
    
                if ( matcher.matches( ) ) {
    
                    String jarName = matcher.group( 1 );
    
                    String version = matcher.group( 2 );
    
                    String snap = matcher.group( 3 );
    
                    System.out.println( "reading: " + jarName + ", " + version );
    
                    createJarStructure( tempDir, jar, jarName, version, snap );
    
                }
                else {
                    throw new IllegalArgumentException( "file name does not match regex" );
                }
    
            } );
    
            try ( FileSystem zipFs = getZipFs( achievePath ) ) {
    
                Files.walk( tempDir )
                     .skip( rootNameCount )
                     .forEach( source -> copyIntoZip( zipFs, source, rootNameCount ) );
            }
        }
    
        private static void copyIntoZip( FileSystem zipFs, Path source, int rootNameCount ) {
    
            try {
                Path zipRoot = zipFs.getPath( "/" );
    
                int tempRootNameCount = rootNameCount + 1;
                int sourceNameCount = source.getNameCount( );
    
                String newPathName = source.subpath( tempRootNameCount, sourceNameCount )
                                           .toString( );
    
                Path pathInZipFile = zipRoot.resolve( newPathName );
                Files.copy( source, pathInZipFile, StandardCopyOption.REPLACE_EXISTING );
            }
            catch ( IOException e ) {
                throw new RuntimeException( e );
            }
        }
    
        private static void createJarStructure( Path tempDir, Path jar, String jarName, String version, String snap ) {
    
            try {
    
                Path jarRoot = jar.getParent( )
                                  .resolve( jarName )
                                  .resolve( version + "-SNAPSHOT" );
    
                Path jarDirectory = Files.createDirectories( tempDir.resolve( jarRoot ) );
    
                String shortSnap = snap.substring( 0,8 );
                Path jarTarget = jarDirectory.resolve( jarName + "-" + version + "-"+ shortSnap + ".jar" ); Files.copy( jar, jarTarget );
    
            }
            catch ( IOException e ) {
                throw new RuntimeException( e );
            }
        }
    
        private static FileSystem getZipFs( Path archivePath ) throws IOException {
    
            Map< String, String > env = new HashMap<>( );
            env.put( "create", "true" );
            env.put( "encoding", StandardCharsets.UTF_8.toString( ) );
    
            System.out.println( archivePath );
            URI uri = URI.create( "jar:file:" + archivePath.toAbsolutePath( ) );
            return FileSystems.newFileSystem( uri, env );
    
        }
    }
    
    推荐文章