[MRM-1263] creating an m2eclipse compatible index should be an optional component.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1384138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-09-12 21:45:27 +00:00
parent 838b6e957b
commit 8136dbe4d2
6 changed files with 57 additions and 17 deletions

View File

@ -648,6 +648,15 @@
</description>
<defaultValue>false</defaultValue>
</field>
<field>
<name>skipPackedIndexCreation</name>
<version>1.0.0+</version>
<type>boolean</type>
<description>
True to not generate packed index (note you won't be able to export your index.
</description>
<defaultValue>false</defaultValue>
</field>
</fields>
</class>
<class>

View File

@ -70,6 +70,11 @@ public class ManagedRepository
private boolean resetStats;
/**
* @since 1.4-M3
*/
private boolean skipPackedIndexCreation;
public ManagedRepository()
{
// no op
@ -96,17 +101,17 @@ public ManagedRepository( String id, String name, String location, String layout
}
/**
*
* @since 1.4-M3
*/
public ManagedRepository( String id, String name, String location, String layout, boolean snapshots,
boolean releases, boolean blockRedeployments, String cronExpression, String indexDir,
boolean scanned, int daysOlder, int retentionCount, boolean deleteReleasedSnapshots,
boolean stageRepoNeeded, String description )
boolean stageRepoNeeded, String description, boolean skipPackedIndexCreation )
{
this( id, name, location, layout, snapshots, releases, blockRedeployments, cronExpression, indexDir, scanned,
daysOlder, retentionCount, deleteReleasedSnapshots, stageRepoNeeded );
setDescription( description );
setSkipPackedIndexCreation( skipPackedIndexCreation );
}
public String getCronExpression()
@ -237,6 +242,16 @@ public void setResetStats( boolean resetStats )
this.resetStats = resetStats;
}
public boolean isSkipPackedIndexCreation()
{
return skipPackedIndexCreation;
}
public void setSkipPackedIndexCreation( boolean skipPackedIndexCreation )
{
this.skipPackedIndexCreation = skipPackedIndexCreation;
}
@Override
public String toString()
{
@ -255,6 +270,7 @@ public String toString()
sb.append( ", deleteReleasedSnapshots=" ).append( deleteReleasedSnapshots );
sb.append( ", stageRepoNeeded=" ).append( stageRepoNeeded );
sb.append( ", resetStats=" ).append( resetStats );
sb.append( ", skipPackedIndexCreation=" ).append( skipPackedIndexCreation );
sb.append( '}' );
return sb.toString();
}

View File

@ -72,7 +72,7 @@
*
* @author Olivier Lamy
*/
@Service ( "managedRepositoryAdmin#default" )
@Service ("managedRepositoryAdmin#default")
public class DefaultManagedRepositoryAdmin
extends AbstractRepositoryAdmin
implements ManagedRepositoryAdmin
@ -83,7 +83,7 @@ public class DefaultManagedRepositoryAdmin
public static final String STAGE_REPO_ID_END = "-stage";
@Inject
@Named ( value = "archivaTaskScheduler#repository" )
@Named (value = "archivaTaskScheduler#repository")
private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
@Inject
@ -171,6 +171,7 @@ public List<ManagedRepository> getManagedRepositories()
repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), false );
repo.setDescription( repoConfig.getDescription() );
repo.setSkipPackedIndexCreation( repoConfig.isSkipPackedIndexCreation() );
managedRepos.add( repo );
}
@ -219,7 +220,8 @@ public Boolean addManagedRepository( ManagedRepository managedRepository, boolea
managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
managedRepository.isDeleteReleasedSnapshots(), managedRepository.getDescription(),
auditInformation, getArchivaConfiguration().getConfiguration() ) != null;
managedRepository.isSkipPackedIndexCreation(), auditInformation,
getArchivaConfiguration().getConfiguration() ) != null;
createIndexContext( managedRepository );
return res;
@ -232,6 +234,7 @@ private ManagedRepositoryConfiguration addManagedRepository( String repoId, Stri
boolean stageRepoNeeded, String cronExpression,
String indexDir, int daysOlder, int retentionCount,
boolean deteleReleasedSnapshots, String description,
boolean skipPackedIndexCreation,
AuditInformation auditInformation,
Configuration config )
throws RepositoryAdminException
@ -253,6 +256,7 @@ private ManagedRepositoryConfiguration addManagedRepository( String repoId, Stri
repository.setDeleteReleasedSnapshots( deteleReleasedSnapshots );
repository.setIndexDir( indexDir );
repository.setDescription( description );
repository.setSkipPackedIndexCreation( skipPackedIndexCreation );
try
{
@ -482,7 +486,8 @@ public Boolean updateManagedRepository( ManagedRepository managedRepository, boo
managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
managedRepository.isDeleteReleasedSnapshots(), managedRepository.getDescription(),
auditInformation, getArchivaConfiguration().getConfiguration() );
managedRepository.isSkipPackedIndexCreation(), auditInformation,
getArchivaConfiguration().getConfiguration() );
// Save the repository configuration.
RepositorySession repositorySession = getRepositorySessionFactory().createSession();
@ -635,6 +640,7 @@ private ManagedRepositoryConfiguration getStageRepoConfig( ManagedRepositoryConf
stagingRepository.setRetentionCount( repository.getRetentionCount() );
stagingRepository.setScanned( repository.isScanned() );
stagingRepository.setSnapshots( repository.isSnapshots() );
stagingRepository.setSkipPackedIndexCreation( repository.isSkipPackedIndexCreation() );
// do not duplicate description
//stagingRepository.getDescription("")
return stagingRepository;

View File

@ -157,6 +157,8 @@ public void updateDeleteManagedRepo()
repo.setLocation( repoLocation );
repo.setCronExpression( "0 0 * * * ?" );
repo.setSkipPackedIndexCreation( true );
managedRepositoryAdmin.updateManagedRepository( repo, false, getFakeAuditInformation(), false );
repo = managedRepositoryAdmin.getManagedRepository( repoId );
@ -165,6 +167,7 @@ public void updateDeleteManagedRepo()
assertEquals( new File( repoLocation ).getCanonicalPath(), new File( repo.getLocation() ).getCanonicalPath() );
assertTrue( new File( repoLocation ).exists() );
assertEquals( description, repo.getDescription() );
assertTrue( repo.isSkipPackedIndexCreation() );
assertTemplateRoleExists( repoId );

View File

@ -236,17 +236,23 @@ private void finishIndexingTask( ArtifactIndexingTask indexingTask, ManagedRepos
context.optimize();
File managedRepository = new File( repository.getLocation() );
String indexDirectory = repository.getIndexDirectory();
final File indexLocation = StringUtils.isBlank( indexDirectory )
? new File( managedRepository, ".indexer" )
: new File( indexDirectory );
IndexPackingRequest request = new IndexPackingRequest( context, indexLocation );
indexPacker.packIndex( request );
context.updateTimestamp( true );
log.debug( "Index file packaged at '{}'.", indexLocation.getPath() );
if ( repository.isSkipPackedIndexCreation() )
{
File managedRepository = new File( repository.getLocation() );
String indexDirectory = repository.getIndexDirectory();
final File indexLocation = StringUtils.isBlank( indexDirectory )
? new File( managedRepository, ".indexer" )
: new File( indexDirectory );
IndexPackingRequest request = new IndexPackingRequest( context, indexLocation );
indexPacker.packIndex( request );
context.updateTimestamp( true );
log.debug( "Index file packaged at '{}'.", indexLocation.getPath() );
}
else
{
log.debug( "skip packed index creation" );
}
}
catch ( IOException e )
{

View File

@ -295,7 +295,7 @@ protected ManagedRepository getTestManagedRepository()
{
String location = new File( FileUtil.getBasedir(), "target/test-repo" ).getAbsolutePath();
return new ManagedRepository( "TEST", "test", location, "default", true, true, false, "2 * * * * ?", null,
false, 2, 3, true, false, "my nice repo" );
false, 2, 3, true, false, "my nice repo", false );
}