These are chat archives for rgladwell/m2e-android

5th
Feb 2015
Matthias Stevens
@mstevens83
Feb 05 2015 17:15
Hello m2e-android guys
I have a question regarding android manifests...
I am using the AMP (v4.1.1) manifest-merger mojo to set the versionName and versionCode attributes. The source manifest file is in the project root (as in the old standard Android setup) and the resulting file (with versionName/Code changed) goes into target/AndroidManifest.xml. All of this works fine on mvn command line
I have go the manifest-merger running in Eclipse (through <execute><runOnIncremental>false</runOnIncremental></execute> lifecycle mapping) and the result still goes target/. But sadly the resulting file is not used when building an APK from eclipse
It seems eclipse/ADT copies the (unchanged) source manifest to bin/ and then packages that in the apk
Matthias Stevens
@mstevens83
Feb 05 2015 17:20
So my question is: is there a way to configure eclipse/m2e-android/ADT to use the manifest as processed by AMP/manifest-merger?
perhaps I should make eclipse use target/ instead of bin/ as the output dir?
or is that asking for trouble?
(I tried changing eclipse's output folder to target/classes instead of bin/classes but something (not sure what) changes it back to bin/classes)
Matthias Stevens
@mstevens83
Feb 05 2015 17:48
Any ideas?
Csaba Kozák
@WonderCsabo
Feb 05 2015 18:27
Sorry, but m2e-android does not support this. We just use the manifest which is configured by the androidManifestFile option of the AMP.
Eclipse output folder is changed back by us, because it is needed to be bin, otherwise ADT would not package your classes into the APK.
Matthias Stevens
@mstevens83
Feb 05 2015 18:45
aha
(in the meantime I had also posted an issue about this: rgladwell/m2e-android#320 )
do you have any other suggestion for me to work around the problem?
I guess that doing something like <destinationManifestFile>${project.basedir}/bin/AndroidManifest.xml</destinationManifestFile> is asking for trouble?
Ricardo Gladwell
@rgladwell
Feb 05 2015 18:50
Thanks for opening that ticket Mattias, I’ll mark it as an enhancement although I can’t say when we’ll get round to it.
Matthias Stevens
@mstevens83
Feb 05 2015 18:51
No prob
Ricardo Gladwell
@rgladwell
Feb 05 2015 18:53
Doing that might cause issues, maybe even break you command line build. In the meantime you could simply test your app using a Maven Build launcher:
Matthias Stevens
@mstevens83
Feb 05 2015 18:56
ah that's a good idea
didn't know that was possible
Ricardo Gladwell
@rgladwell
Feb 05 2015 18:57
np
Matthias Stevens
@mstevens83
Feb 05 2015 18:57
I know messing with the destination would mess up cmdlne build, but I would put it in a separate eclipse only profile
but still, it only complicates matters
Ricardo Gladwell
@rgladwell
Feb 05 2015 18:58
I agree
Matthias Stevens
@mstevens83
Feb 05 2015 19:03
Going to try it anyway for fun ;-)
    <profile>
        <id>eclipse</id>
        <activation>
            <property>
                <name>m2e.version</name>
            </property>
        </activation>
        <build>
            <plugin>
                <groupId>com.simpligility.maven.plugins</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <destinationManifestFile>${project.basedir}/bin/AndroidManifest.xml</destinationManifestFile>
                    <manifestMerger>
                        <versionName>${project.version}</versionName>
                        <versionCodeUpdateFromVersion>true</versionCodeUpdateFromVersion>
                    </manifestMerger>
                </configuration>
            </plugin>
        </build>
    </profile>
Ricardo Gladwell
@rgladwell
Feb 05 2015 19:03
lol did it work?
Matthias Stevens
@mstevens83
Feb 05 2015 19:04
Trying now, fingers crossed :)
Matthias Stevens
@mstevens83
Feb 05 2015 19:10
doesn't seem to do much
Ricardo Gladwell
@rgladwell
Feb 05 2015 19:10
probably isn’t updating the Android manifest at the correct point
if you try again do you get better results?
Matthias Stevens
@mstevens83
Feb 05 2015 19:11
oops there was a <plugins></plugins> missing
still no joy
I made it go to bin2/
just to make sure it does anything at all
but the bin2/ folder is never created
Ricardo Gladwell
@rgladwell
Feb 05 2015 19:17
weird
Matthias Stevens
@mstevens83
Feb 05 2015 19:20
this is what I have:
        <profile>
            <id>eclipse</id>
            <activation>
                <property>
                    <name>m2e.version</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.simpligility.maven.plugins</groupId>
                        <artifactId>android-maven-plugin</artifactId>
                        <configuration>
                            <destinationManifestFile>${project.basedir}/bin2/AndroidManifest.xml</destinationManifestFile>
                            <manifestMerger>
                                <versionName>${project.version}-eclipse</versionName>
                                <versionCodeUpdateFromVersion>true</versionCodeUpdateFromVersion>
                            </manifestMerger>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
Ricardo Gladwell
@rgladwell
Feb 05 2015 19:36
and it didn’t work?
Matthias Stevens
@mstevens83
Feb 05 2015 19:36
No, strangely not
that bin2/ folder never even gets created
Ricardo Gladwell
@rgladwell
Feb 05 2015 19:38
maybe the AMP needs the folder to be created first
Matthias Stevens
@mstevens83
Feb 05 2015 19:39
aha
you were right
ok now back to bin/, let's see if it gets created at the right time
(and not overwritten by ADT)
it seems to work
AMP runs last
so overwrites the bin/AndroidManifest.xml created by ADT
now checking which one will make it into an APK launched from eclipse (without maven launcher)
Ricardo Gladwell
@rgladwell
Feb 05 2015 19:47
sweet, you might want to add that as a workaround to the ticket you created for other users
also might point towards a code solution
Matthias Stevens
@mstevens83
Feb 05 2015 19:50
it seems to work
ok I will add it to the ticket
Ricardo Gladwell
@rgladwell
Feb 05 2015 19:50
thanks for that
Csaba Kozák
@WonderCsabo
Feb 05 2015 20:03
Sorry guys, can you tell me how it is exactly working? :)
OK great, i just see @mstevens83 posted a detailed example in the issue
Ricardo Gladwell
@rgladwell
Feb 05 2015 20:07
thanks @mstevens83
Matthias Stevens
@mstevens83
Feb 05 2015 20:07
You're welcome