2016-07-16 4 views
-1

私のオフィス(私は現在働いているソフトウェア会社)で私の開発作業に私のローカルマシンを使用します。彼らは別の設定を持っています。それは自分のMavenリポジトリに向けられます。 しかし、自宅で自分の仕事のために、私はデフォルトの設定にアクセスしたいです。ローカルMavenインストール用に2つのMavenプロファイルを維持するには?

だから、どうすればいいですか?オフィスと自分の作品のための2つの独立したMavenプロファイルを維持することによってこれを行うことは可能でしょうか?

企業固有の構成では、いくつかのサーバーとリポジトリが定義されています。別のsettings.xmlファイルを管理せずに自宅で作業しているときに、settings.xmlファイルをデフォルトのMavenリポジトリに接続するように設定するにはどうすればよいですか?

+0

どのような種類のIDEを使用していますか? –

+0

@AntonKoscejev私はEclipseを使用しています。しかし、私はコマンドラインを使用しても、私は問題があります。 – Hirantha

+0

ベストは、.m2/settings.xmlのローカルgit repoを作成し、Gitのブランチを自宅と会社で変更することです。 – khmarbaise

答えて

1

はい、いずれも~/.m2/settings.xmlファイルを使用できます。以下は、私が使っているものの例です。サーバーはプロファイルではなく、IDで参照されるときにのみ使用されるためです。

私のIDEには、企業プロジェクト向けにcompプロファイルが有効になっています。また、atlassian SDKプロジェクトのプロファイルはatlassianで、他のプロジェクトではプロファイルがありません。 IntelliJ IDEA you can do this via sidebarでは、Eclipseでこれを行う必要がありますvia Project Properties。コマンドラインからは、-Pで手動で起動する必要があります。ただし、プロパティベースの自動プロファイル有効化を試すことができます。

<?xml version="1.0" encoding="UTF-8"?> 
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
    <servers> 
     <server> 
      <id>comp-releases</id> 
      <username>me</username> 
      <password>secret</password> 
     </server> 
     <server> 
      <id>comp-snapshots</id> 
      <username>me</username> 
      <password>secret</password> 
     </server> 
    </servers> 

    <profiles> 
     <profile> 
      <id>comp</id> 
      <repositories> 
       <repository> 
        <id>comp-nexus</id> 
        <name>Nexus Public</name> 
        <url>https://www.example.com/nexus/content/groups/public/</url> 
       </repository> 
      </repositories> 
     </profile> 
     <profile> 
      <id>atlassian</id> 
      <repositories> 
       <repository> 
        <id>atlassian-public</id> 
        <url>https://maven.atlassian.com/repository/public</url> 
        <snapshots> 
         <enabled>true</enabled> 
        </snapshots> 
        <releases> 
         <enabled>true</enabled> 
        </releases> 
       </repository> 
      </repositories> 
      <pluginRepositories> 
       <pluginRepository> 
        <id>atlassian-public</id> 
        <url>https://maven.atlassian.com/repository/public</url> 
        <releases> 
         <enabled>true</enabled> 
        </releases> 
        <snapshots> 
         <updatePolicy>never</updatePolicy> 
        </snapshots> 
       </pluginRepository> 
      </pluginRepositories> 
     </profile> 
    </profiles> 
</settings> 
+0

うまく動作します。ありがとう。 – Hirantha

関連する問題