yuchen931201 / maven-android-plugin

Automatically exported from code.google.com/p/maven-android-plugin
0 stars 0 forks source link

Can't run standalone goals (without pom) #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Get an apk to your hard drive somehow, for example by building one of 
the samples: See wiki page Samples.
2. Make sure the maven-android-plugin is in your local ~/.m2/repository, 
for example by building one of the samples in step 1, which will cause it 
to get downloaded. (When the synk to Maven Central is complete, this step 
would not be needed.)
3. Go to a directory with no pom.xml in it.
4. Try running the android:undeploy-file goal, like this:

mvn com.jayway.maven.plugins.android.generation2:maven-android-
plugin:2.0.0-alpha3:undeploy-file -Dfile=maven-android-plugin-
samples/apidemos-15/apidemos-15-platformtests/target/apidemos-15-
platformtests-2.0.0-alpha3.apk

What is the expected output? What do you see instead?
The plugin should look inside the apk and try undeploying it from a 
connected device.

Instead, I get this:

[INFO] Scanning for projects...
[INFO] --------------------------------------------------------------------
----
[INFO] Building Maven Default Project
[INFO]    task-segment: 
[com.jayway.maven.plugins.android.generation2:maven-android-plugin:2.0.0-
alpha3:undeploy-file] (aggregator-style)
[INFO] --------------------------------------------------------------------
----
[INFO] [android:undeploy-file]
[INFO] --------------------------------------------------------------------
----
[ERROR] FATAL ERROR
[INFO] --------------------------------------------------------------------
----
[INFO] null
[INFO] --------------------------------------------------------------------
----
[INFO] Trace
java.lang.NullPointerException
        at 
com.jayway.maven.plugins.android.AbstractAndroidMojo.extractPackageNameFrom
Apk(AbstractAndroidMojo.java:274)
        at 
com.jayway.maven.plugins.android.AbstractAndroidMojo.undeployApk(AbstractAn
droidMojo.java:218)
        at 
com.jayway.maven.plugins.android.AbstractAndroidMojo.undeployApk(AbstractAn
droidMojo.java:205)
        at 
com.jayway.maven.plugins.android.standalonemojos.UndeployFileMojo.execute(U
ndeployFileMojo.java:41)
        at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManag
er.java:453)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLif
ecycleExecutor.java:559)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(D
efaultLifecycleExecutor.java:513)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLife
cycleExecutor.java:483)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFai
lures(DefaultLifecycleExecutor.java:331)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(Def
aultLifecycleExecutor.java:228)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycl
eExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:301)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
9)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
l.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at 
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] --------------------------------------------------------------------
----
[INFO] Total time: 4 seconds
[INFO] Finished at: Thu Jun 18 21:30:20 CEST 2009
[INFO] Final Memory: 14M/133M
[INFO] --------------------------------------------------------------------
----

What version of maven-android-plugin are you using?
2.0.0-alpha3

What is the output of "mvn -version" on your machine?
Maven version: 2.0.10
Java version: 1.6.0_13
OS name: "linux" version: "2.6.28-11-generic" arch: "i386" Family: "unix"

Please use labels and text to provide additional information.

The problem is that in AbstractAndroidMojo, the config parameter "sdk" is 
only set to a non-null value if there is a pom.xml with an <sdk/> tag in 
the plugin configuration. Right now, we get this NPE when trying to read 
from the config parameter field we thought would refer to an Sdk 
configuration object.

Original issue reported on code.google.com by hugo.josefson.old@gmail.com on 18 Jun 2009 at 7:34

GoogleCodeExporter commented 9 years ago
Setting for example 'default-value="Sdk"' on the config param 'sdk', does not 
initialize the Sdk object with its parameters, 
such as reading ${android.sdk.path} and settings that to Sdk.path.

I think we should split up the Sdk config class into one that is used for just 
letting Plexus parse the config, and a separate 
one with all out logic. From the one with the logic, we could use whatever 
Plexus has collected from configuration (xml AND 
commandline) to make the best decisions.

Original comment by hugo.josefson.old@gmail.com on 18 Jun 2009 at 7:38

GoogleCodeExporter commented 9 years ago
Fixed on master branch.

Original comment by hugo.josefson.old@gmail.com on 20 Jun 2009 at 6:40

GoogleCodeExporter commented 9 years ago
Tested and releases 2.0.0-alpha4.

Original comment by hugo.josefson.old@gmail.com on 20 Jun 2009 at 9:26