0

To work on a project I am trying to locate a reliable repository where the jsdt core file is available.

Although the 'org.eclipse.jdt:org.eclipse.jdt.core:3.14.0' was extremely easy to locate, I am not having the same look with the jsdt for my Gradle build. And I need some of the webtools.

When I download eclipse I can find the jar inside and I am able to locate the group and artifact ids. But not a repository to declare a dependency.

I found Jabylon and Alfresco, but they are from 2013, I also found one under other name from 2007. But I am trying to locate where they actually put those jars to be able to choose among current versions.

This is the bundle I am looking for: Bundle-SymbolicName: org.eclipse.wst.jsdt.core It seems its group is org.eclipse.webtools.jsdt.bundles

any ideas?

Victor
  • 3,520
  • 3
  • 38
  • 58
  • Only one idea that is not helpful for you : your question is off topic here. – GhostCat Sep 16 '18 at 18:41
  • I am not trying to ask to "recommend or find a book, tool, software library, tutorial or other off-site". I know exacly what library to use and how to use it. however, eclipse's codes evolves a lot, and the main download page is not helpfull for maven/gradle. the group id has other names that I might have missed when looking into jcenter and others. I am looking for a way to declare that specific library in gradle. – Victor Sep 16 '18 at 18:45
  • (this is a missing dependency problem, I don't know how could this be of topic of fit in: "recommend or find a book, tool, software library, tutorial or other off-site") – Victor Sep 16 '18 at 18:53
  • So a reliable repository is not an off site resource? Your question would be answered by a link, correct? Only a link, to be precise. Which exactly puts it in that off topic category. – GhostCat Sep 16 '18 at 19:07
  • ' I am trying to locate where they actually put those jars', not a recommendation for any link', in your view any android o modern java dependency issue would be of topic. My group id my be wrong too. – Victor Sep 16 '18 at 19:14
  • like https://stackoverflow.com/questions/15654475/how-to-download-eclipses-source-code -> the diff is that I need artifacts – Victor Sep 16 '18 at 19:21
  • 1
    Only some Eclipse plug-in JARs that are intended also be used outside of Eclipse in plain (non-OSGi) applications are published to Maven or Gradle repositories (e. g. Eclipse JGit). In the Eclipse world p2 instead of Maven/Gradle repositories are used (the artifacts you're looking for are [here](http://download.eclipse.org/releases/photon/) but cannot be accessed from Maven or Gradle). – howlger Sep 16 '18 at 21:44
  • that was what I was afraid of. it is sad cause it is an OSGI environment and the app is for an equinox based platform. that is why that lib would be perfect for it. well, if you could put it in an answer I will accept it. I was waiting for confirmation before building an uber. – Victor Sep 16 '18 at 22:35
  • @GhostCat The answer is not a link. Please do not close this question as off-topic. – howlger Sep 17 '18 at 06:12
  • @howlger Well, you need 5 votes for an off topic close to work out. Right now, I am there is only my vote. So probably this will stay open. And please ask yourself: would your answer "work" for future users without the links in it? – GhostCat Sep 17 '18 at 06:43
  • 1
    @GhostCat Which link are you talking about? See my answer, why there is no such link here as in most cases. – howlger Sep 17 '18 at 06:50
  • @howlger Like the one to the NEON update site? Which is kinda outdated already, because isn't Photon the latest thing? – GhostCat Sep 17 '18 at 06:51
  • @GhostCat That was regarding version 3.14.0. To make it clearer, I added _"e. g."_ and now refer to the new latest release update site instead. On Wednesday Photon will become outdated and 2018-09 will be the latest. – howlger Sep 17 '18 at 07:06

2 Answers2

1

Only some Eclipse plug-in JARs that are intended also be used outside of Eclipse in plain (non-OSGi) applications are published by the Eclipse projects themselves to Maven or Gradle repositories (e. g. Eclipse JGit).

In the Eclipse world, p2 repositories or simple folders containing the OSGi bundle JARs are used for so-called target platforms to built and run a Java OSGi application.

The artifacts you're looking for are e. g. in the latest simultaneous release update site but cannot be accessed from Maven or Gradle.

Please note that some Eclipse plug-in JARs only work within an OSGi application (e. g. when a bundle activator class is used) or within an Eclipse-based application (e. g. when Eclipse extension points are used).

howlger
  • 31,050
  • 11
  • 59
  • 99
1

For future reference, I built a quick script to sort eclipse jars into a repository structure, so one can deploy if they can and have a server.

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 );

    }
}
Victor
  • 3,520
  • 3
  • 38
  • 58