cuter44/wxpay-sdk

为什么不用maven管理?

ReymontLi opened this issue · 3 comments

为什么不用maven管理?

我都想.

我在初创这个项目的时候还没有使用 Maven, 所以...
现在为了 Maven 化需要作出的改动会相当大, 主要的麻烦在于挪动目录结构; 以及此项目有一个依赖项不是 maven 的, 如果不先将那个项目 maven 化的话, 此项目就算 maven 化也不是很和谐...

我的计划是确保条件成熟后, 开启一个新分支来完成这个工作.

如果您需要与 maven 相关的帮助, 请参见底部提供的一些 workaround.

感谢您对 Nyaguruware 的支持, 打得不错!

We do want it!

But there is still a little missions to do to mavenify it.
There is a dependency which is also, not, yet, mavenified. It is still a kick-ass if we don't provide a full-mavenified, isn't it?

After all, we will consider finish this thing while it comes a good time.

Thanks for your reliance on Nyaguruware.

Workaround with Maven

Here provides tips to integrate with maven.

  1. Download or generate binary of wxpay-sdk(this project) and nyafx

  2. Go through this 2 commands to install them in your local repository:

    mvn install:install-file -Dfile="nyafx-3.4.0.jar" -DgroupId=com.github.cuter44 -DartifactId=nyafx -Dversion=3.4.0 -Dpackaging=jar
    mvn install:install-file -Dfile="wxpay-sdk-0.7.3-dev.jar" -DgroupId=com.github.cuter44 -DartifactId=wxpay-sdk -Dversion=0.7.3-dev -Dpackaging=jar

    , where version code is denoted on the lib file name, it is from build.xml.

  3. Add to your pom:

      <!-- wxpay-sdk -->
        <dependency>
          <groupId>com.github.cuter44</groupId>
          <artifactId>wxpay-sdk</artifactId>
          <version>0.7.3-dev</version>
          <!--
            <systemPath>${project.basedir}/lib/wxpay-sdk-0.7.1.2-dev.jar</systemPath>
          -->
        </dependency>
    
        <dependency>
          <groupId>com.github.cuter44</groupId>
          <artifactId>nyafx</artifactId>
          <version>3.4.0</version>
          <!--
            <systemPath>${project.basedir}/lib/nyafx-3.4.0.jar</systemPath>
          -->
        </dependency>
    
        <dependency>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
          <version>[4.3.1,)</version>
          <scope>runtime</scope>
        </dependency>

    , also the commented systemPath is an alternative, if you don't want to pollute your local repo.

May these help.

Sorry but please no closing it.

From 0.9.0-dev, wxpay-sdk is release-managed using maven. Using Github self-hosted repository.

2 alternative methods to add dependency to you POM:

Install to local repository, using source code or pre-built

  1. Download/clone wxpay-sdk(0.9.0 or later) and nyafx(4.0.0 or later)(which wxpay-sdk depends on) source code respectively, from branch mavenify. Using latest version or whatever version you want.

  2. Run mvn install respectively to compile and install to your local repository.

  3. Add following snippet to your project's POM to state the dependency:

    <dependency>
      <groupId>com.github.cuter44</groupId>
      <artifactId>wxpay-sdk</artifactId>
      <version>0.9.0-dev</version><!-- or exact version you use -->
    </dependency>

That's ok. The shortage is that before you compile your project elsewhere, you have to repeat this precedure again and again. (If you are not using a nexus.)
Besides, you can also browse the existing repo and download and install without compiling.

Link to our Github distribution repo

  1. Add following repository descriptor and dependency:

    <project>
    <dependencies>
      <dependency>
        <groupId>com.github.cuter44</groupId>
        <artifactId>wxpay-sdk</artifactId>
        <version>0.9.0-dev</version><!-- or exact version you use -->
      </dependency>
      ...
    </dependencies>
    ...
    <repositories>
        <repository>
          <id>wxpay-sdk</id>
          <name>wxpay-sdk by Nyaguruware</name>
          <url>https://raw.github.com/cuter44/wxpay-sdk/mvn-repo/</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </snapshots>
        </repository>
        ...
    </repositories>
    ...
    </project>

Next time you inital a compile, Maven will try to download the dependency.
Shortage is: it may make your POM looks massive...

Other note about POM config and maven repo

  • Unlike Maven Central, we may not guarantee the releases are immutable, nor meeting other criteria the Maven Central requires. Mostly we can manage to reach it, but men cannot avoid making mistake, you know...
  • Both wxpay-sdk and nyafx are built for Java 7, but in fact they are compatible with Java 6, or even 5(theoretically). You may change the configuration and build your own.
  • Switching package to war (or specify cmd param -Dproject.package=war) can assemble previous "demo-mode" output.