Coder Social home page Coder Social logo

j2objc-maven-plugin's Introduction

Maven plugin for J2ObjC library

Build Status Maven Central

Installation

Add the following plugin entry into your pom's plugins section:

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.4</version>
    <configuration>
        <j2objcPath>path/to/j2objc</j2objcPath>
    </configuration>
</plugin>

In order to run the plugin, execute the following command: mvn j2objc:convert.

Once you want to try a snapshot version, don't forget to add the following section as well:

<pluginRepositories>
    <pluginRepository>
        <id>sonatype-nexus-snapshots</id>
        <name>sonatype-nexus-snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </pluginRepository>
</pluginRepositories>
...
<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.5-SNAPSHOT</version>
    <configuration>
        <j2objcPath>path/to/j2objc</j2objcPath>
    </configuration>
</plugin>

Please note, that plugin supports Maven versions >= 3.1.x.

Usage

After you added the plugin to project, the only required parameter you have to specify is j2objcPath, which is path to J2ObjC's executable file. All the other plugin's parameters are proxies of J2ObjC's original parameters.

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.2</version>
    <configuration>
        <j2objcPath>${J2OBJC_DISTRIBUTION}/j2objc</j2objcPath>
        <useArc>true</useArc>
        <noPackageDirectories>true</noPackageDirectories>
        <!-- default value -->
        <sourcePath>${project.basedir}/src/main/java</sourcePath>
        <!-- default value -->
        <d>${project.build.directory}/j2objc</d>
    </configuration>
</plugin>

Full list of parameters you can find at J2ObjC library home page.

The example above shows how you can externalize the path to J2ObjC library. Don't forget to add the parameter definition to call: mvn j2objc:convert -DJ2OBJC_DISTRIBUTION=/folder/of/j2obc.

Sometimes, the code you want to convert to Objective-C contains dependencies, which should be converted as well. In this case you have to add all those dependencies into appropriate configuration section:

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.2</version>
    <configuration>
        <j2objcPath>${J2OBJC_DISTRIBUTION}/j2objc</j2objcPath>
        <useArc>true</useArc>
        <noPackageDirectories>true</noPackageDirectories>
        <dependencies>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.3.1</version>
            </dependency>
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>2.8.1</version>
            </dependency>
        </dependencies>
    </configuration>
</plugin>

This mechanism doesn't support nested dependencies recognition which means you have to specify every nested dependency separately. For example, joda-time library depends on joda-convert, so in order to have all the necessary dependencies in your Xcode project, you have to specify it as well:

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.2</version>
    <configuration>
        <j2objcPath>${J2OBJC_DISTRIBUTION}/j2objc</j2objcPath>
        <useArc>true</useArc>
        <noPackageDirectories>true</noPackageDirectories>
        <dependencies>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.3.1</version>
            </dependency>
            <dependency>
                <groupId>org.joda</groupId>
                <artifactId>joda-convert</artifactId>
                <version>1.8</version>
            </dependency>
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>2.8.1</version>
            </dependency>
        </dependencies>
    </configuration>
</plugin>

Please note, that in order to make it work your local repository must contain the sources version of every dependency.

Advanced Options

Skip parent project

The configuration <skipParent>true</skipParent> in parent pom can be used to only translate child projects.

Fail on errors

By default the plugin will throw the exception in case of any error occured during the conversion. The configuration <failOnErrors>false</skipParent> prevents such behavior.

Translate dependencies only

<dependenciesOnly>true</dependenciesOnly> configuration allows to translate dependencies only and ignore the parent project.

j2objc-maven-plugin's People

Contributors

kenwdelong avatar ozirissp avatar spike83 avatar vicmosin avatar

Watchers

 avatar  avatar

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.