erikabruni73 / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Include in Maven #199

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm building my Android app using Maven, and so far, it's worked pretty well.

I'd like to use osmdroid, but it isn't in any Maven repository, which makes 
things challenging (don't get me wrong - it's not impossible, so I will still 
use it of course!).

Could you add osmdroid to Maven central? Instructions are here: 
https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage
+Guide

Thanks!

Original issue reported on code.google.com by candrews...@gmail.com on 8 Apr 2011 at 6:05

GoogleCodeExporter commented 9 years ago

Original comment by neilboyd on 28 Apr 2011 at 2:09

GoogleCodeExporter commented 9 years ago
Is there anything that the project maintainers need to do that you couldn't do 
yourself to accomplish this? I didn't look too in-depth but it seems like you 
just need to sign up and provide a source repository. Is there anything we need 
to put in the repository?

Original comment by kurtzm...@gmail.com on 3 Jun 2011 at 9:29

GoogleCodeExporter commented 9 years ago
Releasing artifacts to maven central repository is definitive. So maintainers 
shouldn't let anyone do it :) 

Here is a sample pom to build osmdroid-android with maven instead of ant. 
Anyone who want to use it just have to copy the pom.xml file under the 
"osmdroid-android" directory and run mvn.

Original comment by huchet.j...@gmail.com on 19 Nov 2011 at 3:53

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry, here is the generic file... 

Original comment by huchet.j...@gmail.com on 19 Nov 2011 at 3:56

Attachments:

GoogleCodeExporter commented 9 years ago
I included this pom in revision 1005

Original comment by neilboyd on 22 Nov 2011 at 6:05

GoogleCodeExporter commented 9 years ago
This issue isn't fixed - having the pom included is one step towards solving 
the issue. The issue is to get osmdroid on Maven central. Can you please reopen 
this issue and and we can work towards that goal?

Really, only the project itself can upload the artifact to maven central. The 
instructions are here: 
https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage
+Guide Now that the pom.xml is in the project, it seems like a fairly 
straightforward process (register an account, run some commands, ...)

Original comment by candrews...@gmail.com on 22 Nov 2011 at 5:09

GoogleCodeExporter commented 9 years ago
I don't use Maven so I didn't know that I had to do that huge page of actions. 
I'll reopen and continue later.

Original comment by neilboyd on 23 Nov 2011 at 6:19

GoogleCodeExporter commented 9 years ago
I've been having another look at Maven and it would be good to convert osmdroid 
to use it.  Perhaps someone with more knowledge about it could create pom's for 
all the projects. I'll be happy to upload to the central repository.  Do I need 
to repeat the process for each project, or can it be done with a single 
top-level pom?

Original comment by neilboyd on 16 Jan 2012 at 10:14

GoogleCodeExporter commented 9 years ago
You won't have to repeat the process for each project, the top level pom will 
build the sub modules and deploy them to the Maven central repository. 

You should know it is better to use the default maven layout to benefit from 
maven conventions. For instance, the project layout you are using is: 

osmdroid-android
 + assets
 + docs
 + ext (not required anymore)
 + lib (not required anymore)
 + src
 + tests

Maven conventions advice you to use this layout:
osmdroid-android
 + src
   + main
     + java
     + resources (former assets directory)
   + test
     + java
     + resources

I can find some time to write missing poms, I will let you know.

Original comment by huchet.j...@gmail.com on 16 Jan 2012 at 11:02

GoogleCodeExporter commented 9 years ago
That would be great. I also found this guide.
http://maven.apache.org/guides/mini/guide-central-repository-upload.html

Original comment by neilboyd on 17 Jan 2012 at 6:02

GoogleCodeExporter commented 9 years ago
I started by creating an issue on Sonatype: 
http://issues.sonatype.org/browse/OSSRH-2725

Original comment by neilboyd on 17 Jan 2012 at 6:12

GoogleCodeExporter commented 9 years ago
Here is a diff patch with the following modifications: 
- I renamed some projects to use only lowercase letters
- I added pom.xml files

Some dependencies are not in the central repository, they must be added 
manually: 
- org.mapsforge:map:0.2.4
- com.google.android.maps:maps:3_r3

For org.mapsforge:map, you can set up an alternate repository hosted in your 
svn repository. Users will just have to define this repository in their 
settings.xml file.
For com.google.android.maps:maps, you could do the same, but I think there is 
licensing and redistribution limits. In addition, android maven users currently 
using the Google Maps API have to deal with this, so I don't think it's 
necessary. 

I was able to deploy the two android apps on my device, I issued one force 
close in google-wrapper-sample. 

I attached a sample settings.xml file you will need to deploy your artifacts to 
the sonatype repository. 

Original comment by huchet.j...@gmail.com on 18 Jan 2012 at 9:58

Attachments:

GoogleCodeExporter commented 9 years ago
Is there any reason you changed the projects to lowercase? It's better if I do 
that first and then you can make a patch with just the changes relevant to 
maven. Or maybe it would work if you simply do a svn rename, but don't do it by 
just renaming the folders because then you get a whole load of deletes and a 
whole load of adds.

I haven't tried the google sample for a while, so it's not surprising that it 
doesn't work any more.

Original comment by neilboyd on 18 Jan 2012 at 10:11

GoogleCodeExporter commented 9 years ago
No, there isn't really a reason to that. It's just to make the project 
directory match the name of the artifactId (see 
http://maven.apache.org/pom.html#Maven_Coordinates). 
It's possible to use uppercase letters in the artifactIds, but most of the of 
projects I saw always use lowercase names. 

I used "svn move" command to rename directories and "svn diff" to generate the 
diff file. 
Ok, move directories, then I will generate the diff. 

I forgot to tell you I didn't tested the openstreetmap tile packager. 
Compilation is successful but I'm pretty sure it doesn't work anymore. Maybe 
you should create a branch to do maven tests. 

Original comment by huchet.j...@gmail.com on 18 Jan 2012 at 11:02

GoogleCodeExporter commented 9 years ago
I was already thinking I should do a branch for this.
The jars are already lower case, and the other stuff doesn't need to be in 
maven, does it?

Original comment by neilboyd on 19 Jan 2012 at 7:53

GoogleCodeExporter commented 9 years ago
I created a branch and started moving stuff, but I don't have time to finish it 
right now. Next thing to do is to adjust the classpaths to make it build.

I still think the apps should keep the mixed-case names they have now.

Original comment by neilboyd on 19 Jan 2012 at 9:02

GoogleCodeExporter commented 9 years ago
Okay, I've done some of the re-organising. I think it's best if you now do the 
Maven stuff again. It should be a small patch this time to just fix the 
classpath and add the poms.

Original comment by neilboyd on 19 Jan 2012 at 12:25

GoogleCodeExporter commented 9 years ago
I attached a patch to add 3 pom.xml files to build osmdroid-android and 
osmdroid-third-party. 
I recommend you to try to get a successful build in command line before trying 
to integrate with eclipse.
You have to set up your settings.xml like the sample I posted yesterday (with 
your credentials do deploy to the Sonatype repository). 

Do you plan to always release osmdroid-android and osmdroid-third-party at the 
same time ? If not, I will have to modify them. 
Note that the <scm/> element of the parent pom is set to work with the trunk. 
The maven-release-plugin will not work from the branch. 

For eclipse integration:
You should remove osmdroid-android/.classpath, osmdroid-android/.project, 
osmdroid-third-party/.classpath and osmdroid-third-party/.project files. As you 
should know, those files are used by eclipse to display source packages, set up 
build path, etc...
You have to install the m2eclipse plugin in your Eclipse installation (don't 
confuse with maven-eclipse-plugin) and import the 2 modules as "maven 
projects". The plugin will generate .project and .classpath metadata files. You 
should also add them to svn:ignore property. 
See http://eclipse.org/m2e/.

You don't need it, but I attached the pom files I wrote for all the modules in 
osmdroid-maven.tar to keep a track. 

Original comment by huchet.j...@gmail.com on 19 Jan 2012 at 8:50

Attachments:

GoogleCodeExporter commented 9 years ago
I think I've finished and am ready to merge back into trunk.
I couldn't deploy, but you told me that wouldn't work on the branch.
I didn't touch OSMMapTilePackager because it doesn't really fit the model. I'm 
happy to keep it as legacy.
OpenStreetMapViewer compiles and runs.
GoogleWrapperSample compiles but I didn't try running it.

I think we'll need to update the wiki because there's a few non-obvious steps.
http://code.google.com/p/osmdroid/wiki/HowToEclipse

Original comment by neilboyd on 19 Jan 2012 at 10:44

GoogleCodeExporter commented 9 years ago
What command did you run ? What error did you got ?
Running "mvn deploy" will deploy artifacts to the sonatype snapshots 
repository. This should work in the branch. 
I wanted to warn you about the fact that when you run "mvn release:prepare" 
from the branch, I think maven will fail creating the tag in svn. 
You should be able to run "mvn deploy" successfully. But this will not deploy 
artifacts to the maven central repository. 
To deploy them to maven central, you must sign the artifacts, sources and 
javadoc, then upload them to the Sonatype "staging" repository. 
This can be done manually using the Nexus web interface or automatically with 
the maven-release-plugin. Are you familiar with it ? 

I you have a working environment in the branch, you can safely merge back to 
the trunk. In the worse case, you just use maven as a simple build tool. 
You can also update or delete TODO tags I let in pom.xml files.

Original comment by huchet.j...@gmail.com on 20 Jan 2012 at 2:00

GoogleCodeExporter commented 9 years ago
I didn't try release yet. I tried "mvn deploy" and got this error:

[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on 
project osmdr
oid-android: Failed to deploy artifacts: Could not transfer artifact 
org.osmdroid:osmdroid-android:jar:3.0.7-20120120.05
5549-1 from/to sonatype-nexus-snapshots 
(https://oss.sonatype.org/content/repositories/snapshots/): Failed to transfer f
ile: 
https://oss.sonatype.org/content/repositories/snapshots/org/osmdroid/osmdroid-an
droid/3.0.7-SNAPSHOT/osmdroid-andro
id-3.0.7-20120120.055549-1.jar. Return code is: 401 -> [Help 1]

Then next thing I should do, which was how this whole issue started out, was to 
build the apps using Maven. I see there are two plugins - maven-android-plugin 
and m2eclipse-android-integration.  Which should I use?

Original comment by neilboyd on 20 Jan 2012 at 5:59

GoogleCodeExporter commented 9 years ago
Forget my last question ;-)  I found the manual: 
http://www.sonatype.com/books/mvnref-book/reference/android-dev.html

Original comment by neilboyd on 20 Jan 2012 at 7:43

GoogleCodeExporter commented 9 years ago
I merged it back into trunk in revision 1045.
And then deleted the branch.

Original comment by neilboyd on 20 Jan 2012 at 7:59

GoogleCodeExporter commented 9 years ago
In comment 18 you said I should add .project and .classpath to svn:ignore. Why?

Original comment by neilboyd on 20 Jan 2012 at 9:07

GoogleCodeExporter commented 9 years ago
I tried running
mvn release:prepare -DdryRun=true
and it seemed to go okay,  but it stopped at a prompt(?) for
GPG Passphrase

Do you know the normal process, in a nutshell?

My previous process was:
 * create branch
 * change debuggable=false in the manifest
 * build everything and release it
 * switch back to trunk and increase the version numbers

With Maven, where do the branches get created? Where do the version numbers get 
incremented? Where do you specify the release key for the apk? How do you 
deploy a snapshot?

Original comment by neilboyd on 20 Jan 2012 at 9:42

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Or maybe I shouldn't use Maven to release apk?

Original comment by neilboyd on 20 Jan 2012 at 9:48

GoogleCodeExporter commented 9 years ago
> In comment 18 you said I should add .project and .classpath to svn:ignore. 
Why?
The main goal of the m2eclipse plugin is to generate these files automatically 
so you won't have to set up project configuration (buildpath, source folders, 
etc...).
When you make changes to the pom.xml, you just have to right click > maven > 
update project configuration and .classpath, .project and others are 
regenerated.

You must also distinguish (1) pure-java project (osmdroid-android, 
osmdroid-third-party, osm-maptile-packager) and (2) android projects 
(GoogleWrapperSample, OpenStreetMapViewer)

(1) I recommend you to use M2eclipse to work in eclipse
So remove .classpath/.project files and generate them with the m2 eclipse 
plugin (see http://eclipse.org/m2e/).

(2) I recommend you to NOT use the m2eclipse plugin but use what you usually do.
So keep .classpath/.project, you updated them the right way linking 
dependencies to your local maven repository. And continue using the Android 
Plugin in Eclipse. You will use maven only to release the projects, not during 
development.

> Do you know the normal process, in a nutshell?
With the poms.xml I wrote, you will be forced to release all your projects at 
the same time, with the same version.
In a nutshell...
 * got a clean working copy
 * go to /trunk
 * run mvn release:prepare -DdryRun=true
 * check release.properties files
 * run mvn release:prepare (/!\ this will do "svn cp http://[...]/svn/trunk http://[...]/svn/tags/[tagname you specified])
 * run mvn release:perform (this will checkout the previously created tag, build and deploy to the nexus staging repository)
 * run mvn release:clean (only if everithing is OK, else you should run mvn release:rollback to remove the created tag)

If you're not familiar, I recommend you to set up a test svn repository and 
test it.
Maybe we could set up a meeting on gtalk to discuss ? 

Original comment by huchet.j...@gmail.com on 22 Jan 2012 at 10:42

GoogleCodeExporter commented 9 years ago
I'm not sure that the fact that .classpath and .project are automatically 
updated is a reason to exclude them. I think Eclipse needs them to open the 
project, so it's a bit unhandy if they're not there to start with.

I originally had (2) the way you described, but then I converted to Maven 
projects in revision 1050. The advantage of being a Maven project is that 
m2eclipse handles the config, the disadvantage is that you need to run from the 
command line - it doesn't work from Eclipse. However that disadvantage is also 
an advantage because you make sure the Maven build keeps working instead of 
waiting until release to discover it's broken.

I ran it as far as successfully doing
mvn release:prepare -DdryRun=true
I guess I should just go ahead and publish it. It's not the end of the world if 
it goes wrong!

Original comment by neilboyd on 23 Jan 2012 at 9:19

GoogleCodeExporter commented 9 years ago
I had a better idea:
mvn clean deploy
to publish a snapshot

What next? Can people now see the snapshot? I couldn't see it in 
http://search.maven.org/#search%7Cga%7C1%7Cosmdroid

Original comment by neilboyd on 23 Jan 2012 at 9:43

GoogleCodeExporter commented 9 years ago
Take a look at this project, for instance, 
https://github.com/SonarSource/jenkins-sonar-plugin
.project and .classpath aren't commited. These files/directories depends on 
your IDE and your platform. 
M2Eclipse generate the files when you import the project as a maven project or 
when you "right click > maven > update project configuration". 
You can keep them, it won't cause you any trouble. 

For the (2) case, I don't know which one is the best way. I'm also starting 
using the maven-android-plugin and my android app next release will be the 
first one with it. 

Your snapshots seems to have been successfully deployed : 
https://oss.sonatype.org/content/groups/public. 

Original comment by huchet.j...@gmail.com on 23 Jan 2012 at 12:52

GoogleCodeExporter commented 9 years ago
I followed the instructions in comment 28, but when I did

mvn release:perform

I got an error 401. That doesn't make sense to me because I should be able to 
do that.

Check the description in the issue: 
https://issues.sonatype.org/browse/OSSRH-2725

and the error log:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project o
smdroid-parent: Failed to deploy artifacts: Could not transfer artifact 
org.osmdroid:osmdroid-parent:pom:3.0.7 from/to s
onatype-nexus-staging 
(https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to 
transfer file: https://
oss.sonatype.org/service/local/staging/deploy/maven2/org/osmdroid/osmdroid-paren
t/3.0.7/osmdroid-parent-3.0.7.pom. Retur
n code is: 401 -> [Help 1]

Any ideas?

Original comment by neilboyd on 24 Jan 2012 at 10:35

GoogleCodeExporter commented 9 years ago
PS. After
mvn release:prepare -DdryRun=true
then you should do
mvn release:prepare -Dresume=false
or
mvn release:clean release:prepare

Original comment by neilboyd on 24 Jan 2012 at 10:43

GoogleCodeExporter commented 9 years ago
Check the credentials you're using. 
Can you remove your credentials from the settings.xml file and send it to me ? 
I will try your configuration. 

Original comment by huchet.j...@gmail.com on 24 Jan 2012 at 12:54

GoogleCodeExporter commented 9 years ago
I think this is all done now.  Someone just needs to update the wiki's.  I'd 
appreciate if someone impartial could do that.

https://oss.sonatype.org/content/groups/public/org/osmdroid/

Original comment by neilboyd on 30 Jan 2012 at 8:58

GoogleCodeExporter commented 9 years ago
I got this exception when using the library in my project. 
I'll get back to you after investigation.

Original comment by huchet.j...@gmail.com on 2 Feb 2012 at 11:06

Attachments:

GoogleCodeExporter commented 9 years ago
See also issue 305.

Original comment by neilboyd on 2 Feb 2012 at 11:12

GoogleCodeExporter commented 9 years ago
I'm glad that OSMdroid is moving into Maven Central!

When I tried it out with the osmdroid-third-party lib (because I use the google 
wrapper), I ran into an unresolved dependency: mapsforge-map.
It appears, the mapsforge-map is not in maven central.

I could resolve it by explicitly excluding the mapsforge-map reference as I 
don't need the code. However, other people might run into this issue, too.

Original comment by stefan.simroth on 2 Feb 2012 at 5:58

GoogleCodeExporter commented 9 years ago
I wonder why mapsforge isn't in central repository.  They use Maven.  It's in 
my local repository.
I suggest you take it up with them.

Original comment by neilboyd on 2 Feb 2012 at 7:24

GoogleCodeExporter commented 9 years ago
See comment #12

Original comment by huchet.j...@gmail.com on 2 Feb 2012 at 7:33

GoogleCodeExporter commented 9 years ago
The reason I haven't closed this issue yet is because we need a wiki to explain 
all this stuff.

Original comment by neilboyd on 2 Feb 2012 at 7:41

GoogleCodeExporter commented 9 years ago
Neil - can we please add some instructions to the wiki? I'm still using the old 
svn structure in Eclipse because I can't figure out how to use it with Maven. I 
added maven central to eclipse, but osmdroid never shows in the list. I tried 
to import an existing  maven project, but it doesn't add the Android stuff. I'm 
not even sure which direction to go down, so just some general guidance would 
be helpful.

Original comment by kurtzm...@gmail.com on 8 Aug 2012 at 9:23

GoogleCodeExporter commented 9 years ago
What do you want to know? Perhaps you could do the document outline and I could 
fill in the details.

Original comment by neilboyd on 10 Aug 2012 at 5:23

GoogleCodeExporter commented 9 years ago
I just added this to my pom, and it worked:

        <dependency>
            <groupId>org.osmdroid</groupId>
            <artifactId>osmdroid-android</artifactId>
            <version>3.0.8</version>
        </dependency>

Original comment by cbain...@gmail.com on 22 Aug 2012 at 3:14

GoogleCodeExporter commented 9 years ago
I started on a HowToMaven wiki

Original comment by neilboyd on 23 Aug 2012 at 7:00

GoogleCodeExporter commented 9 years ago

Original comment by neilboyd on 25 Jan 2014 at 6:12