Code Monkey home page Code Monkey logo

mercury's Introduction

Mercury

Mercury is a source code transformation library for Java codebases, with an included remapper - built on Eclipse's JDT and Lorenz. Mercury is licensed under the Eclipse Public License 2.0.

While Mercury is yet to see a proper release (we're working on it), it has been successfully used by the following projects:

Usage

Mercury is centred around the Mercury class, which is the effective control centre. See the following example, for a demonstration of remapping a codebase using Lorenz.

final Mercury mercury = new Mercury();

// Due to the nature of how mercury works, it is essential that we have
// the full binary classpath.
mercury.getClassPath().add(Paths.get("example.jar"));

// To remap the codebase using Lorenz, we must install a MercuryRemapper,
// with our MappingSet.
mercury.getProcessors().add(MercuryRemapper.create(mappings));

// Lets rewrite our codebase at "a/" to "b/".
mercury.rewrite(Paths.get("a"), Paths.get("b"));

Rewrite access transformers

Mercury also has an optional dependency on at, allowing access transformers to be applied to source, and be updated to reflect changes in the structure of the codebase. See the following example to see how this could work.

final Mercury mercury = new Mercury();
mercury.getClassPath().add(Paths.get("example.jar"));
mercury.getProcessors().add(MercuryRemapper.create(mappings));

// Since we run after MercuryRemapper, the access transformer needs to be
// remapped - fortunately, at provides an optional dependency on Lorenz,
// and a utility to do just that!
final AccessTransformSet remappedTransforms =
            AccessTransformSetMapper.remap(transforms, mappings);
// We can then use AccessTransformerRewriter with the remapped access
// transform set.
mercury.getProcessors()
            .add(AccessTransformerRewriter.create(remappedTransforms));

mercury.rewrite(Paths.get("a"), Paths.get("b"));

See Also

There is beginning to be tooling designed to work with Mercury, these may be helpful in your project:

Discuss

Found an issue with Mercury? Make an issue! We'd rather close invalid reports than have bugs go unreported :)

We have an IRC channel on EsperNet, #cadix, which is available for all registered users to join and discuss Mercury and other Cadix projects.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.