-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added <skipDependencies> option to ApkMojo and DexMojo #632
Conversation
Should it somehow also be used in the lifecycle participant? Otherwise I am fine with this.. although I would think the approach to be more of a hack ;-) |
Hmm good point. It's always a hack to support new mechanics before they are available in On Wed, May 20, 2015 at 5:00 AM, Manfred Moser [email protected]
|
Yep, very specific use case. I'd like to see some documentation on the site too. That would be helpful for anyone in the same situation |
Yeah, it's more like a hack, because my intention to use Java 8 libraries might be resulted into a simplier solution than I suggested, but this is currently the only way I know to make it work. My home projects are split into a few dozens of modules and these modules are mostly not yet ported to Java 8 keeping source and binary compatibility with Android and GWT respectively. A few days ago I succeeded with not yet released GWT 2.8.0 that finally has Java 8 language features support, and thus I thought I could try to migrate my Android test apps to Java 8 too. Initially I thought that |
I would say that very few people are using Java8 mechanisms in the Android Your solution only works if ALL of the dependencies of the APK are Java On Wed, May 20, 2015 at 3:16 PM, Lyubomyr Shaydariv <
|
@william-ferguson-au <skipDependencies>true</skipDependencies>
<!-- supposed to have higher priority than skipDependencies -->
<includeArtifacts>
<includeArtifact>foo:bar</includeArtifact>
</includeArtifacts> and <excludeArtifacts>
<excludeArtifact>foo:bar<excludeArtifact> <!-- this one is excluded always -->
</excludeArtifacts> ? Or do I miss the whole point? |
In almost all cases skipDependnecies==false. So I'm starting to think that this might be more work than is worthwhile. On Wed, May 20, 2015 at 4:10 PM, Lyubomyr Shaydariv <
|
@william-ferguson-au |
The only way it could work would be to specify a list of dependencies to Not sure how the others feel about this direction though. ᐧ On Wed, May 20, 2015 at 5:11 PM, Lyubomyr Shaydariv <
|
… artifacts by type
I feel like we should just wait until the Android SDK and so on support Java 8 bytecode ...whatever we do before them will result in a throw away solution and it is potentially a lot of work. I would rather spend our efforts on other things. |
…ifacts by groupId, artifactId and version
…er priority than exclusion by artifact type
I've just pushed the They both support Something like this: <plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.2.2-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<androidManifestFile>${project.basedir}/src/main/android/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/src/main/android/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/src/main/android/res</resourceDirectory>
<sdk>
<platform>19</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<proguard>
<skip>true</skip>
<config>${project.basedir}/proguard.conf</config>
</proguard>
<!--<skipDependencies>true</skipDependencies>-->
<!--<artifactTypeSet>-->
<!--<excludes>-->
<!--<exclude>jar</exclude>-->
<!--</excludes>-->
<!--</artifactTypeSet>-->
<artifactSet>
<excludes>
<exclude>foo-group-id:foo-artifact-id</exclude> <!-- any version -->
<exclude>bar-group-id</exclude> <!-- excludes the whole group -->
</excludes>
</artifactSet>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<includeGroupIds>foo-group-id,bar-group-id</includeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.orfjackal.retrolambda</groupId>
<artifactId>retrolambda-maven-plugin</artifactId>
<version>1.8.1</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>process-main</goal>
<goal>process-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin> The result of my initial investigation for the This is actually my first Maven-related development attempt and I could probably violate Maven plugin development rules and practices. For example, I'm still not sure whether |
Guys, any chances this pull request to be merged to the master? I hope this contribution is helpful for someone else too, not just for the ones and me who want to use Java 8 dependencies. |
I think we are unsure of the worth of adding in a deviation like this. The On Mon, May 25, 2015 at 1:47 AM, Lyubomyr Shaydariv <
|
Even from the perspective that |
Hi Lyubomyr, I don't understand your comment. On Mon, May 25, 2015 at 9:07 AM, Lyubomyr Shaydariv <
|
Sorry for my English grammar/vocabulary (not a native speaker). I mean that I cannot control arguments passed to the |
From my understanding of the problem you are really looking for a way to There would only be a small number of use cases requiring this AndroidMaven committers - thoughts? On Mon, May 25, 2015 at 9:36 AM, Lyubomyr Shaydariv <
|
I think we can probably pull it in but I have to look at it in a bit more detail. Also having some documentation like in this issue in a separate page would be useful. |
…llection instance is better.
…files conflicts between Maven repo classes and ./target/classes directory classes
I finally merged this. Ideally you could take some of the docs from this PR and put it into a documentation asciidoc file in src/site/asciidoc and send another PR for it. I will release a new version of the plugin as soon I got through the rest of the open PRs. |
Thanks for pulling it. My |
Added Java 8 instrumentation scenario for PR #632
Problem: Use Java 8 libraries in Android applications.
The story
I have a small set of minilibs I have written in Java 6 to share them between "regular Java", GWT and Android applications. This works fine, but Java 8 is here, so I decided to migrate all of my internal projects to Java 8 to use Java 8 language features (lambda expressions, method references, etc), and not JDK 1.8 new features like Stream API or so. I succeeded with not yet released GWT 2.8.0 to use Java 8 language level libraries (source code compatiblity), but couldn't make this approach work for the Android environment with
android-maven-plugin
due to incompatible bytecode version (54). First I tried to useretrolambda-maven-plugin
hoping it helps, but then I figured out that it can only process./target/classes
directory.Then I investigated the DEBUG-level logs generated by the
android-maven-plugin
: it currently tries to include repository-based libraries that are not yet instrumented withretrolambda-maven-plugin
.This led me an idea of obtaining all application dependencies to the
./target/classes
directory and then instrumenting them withretrolambda-maven-plugin
to letandroid-maven-plugin
DEX-ify the local classes only that are supposed to include all the dependencies locally. Simply speaking, let thedx
tool invoke the previous snippet without lines07
,08
, and09
. However, I couldn't find a way to exclude dependencies from theandroid-maven-plugin
workflow.What was done
Thus, this pull request has a new option for
ApkMojo
andDexMojo
calledskipDependencies
that allows to ignore any JAR-files coming from the repo and configure thedx
tool to accept the./target/classes
directory only. An example workflow I made my Android demo application use Java 8 libraries:maven-compiler-plugin
to enablesource
andtarget
1.8 language support;maven-dependency-plugin
with goal set tounpack-dependencies
to obtain all classes and resources in./target/classes
;retrolambda-maven-plugin
to instrument Java 8 byte code;android-maven-plugin
with the new<skipDependencies>true</skipDependencies>
to process local./target/classes
only.A portion from
pom.xml
I used to test my application: